OSDN Git Service

[Refactor] mysqrt() を削除し、std::sqrt に差し替えた
[hengbandforosx/hengbandosx.git] / src / term / z-util.h
1 #pragma once
2
3 /*
4  * Copyright (c) 1997 Ben Harrison
5  *
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.
9  */
10
11 #include "system/h-basic.h"
12 #include <string_view>
13
14 /*
15  * Extremely basic stuff, like global temp and constant variables.
16  * Also, some very useful low level functions, such as "streq()".
17  * All variables and functions in this file are "addressable".
18  */
19
20 /**** Available variables ****/
21
22 /* A concptr to the name of the program */
23 extern concptr argv0;
24
25 /* Aux functions */
26 extern void (*plog_aux)(concptr);
27 extern void (*quit_aux)(concptr);
28 extern void (*core_aux)(concptr);
29
30 /**** Available Functions ****/
31
32 /* Test equality, prefix, suffix */
33 bool streq(std::string_view s, std::string_view t);
34 bool prefix(std::string_view s, std::string_view t);
35 bool suffix(std::string_view s, std::string_view t);
36
37 /* Print an error message */
38 void plog(concptr str);
39
40 /* Exit, with optional message */
41 void quit(concptr str);
42
43 /* Dump core, with optional message */
44 void core(concptr str);
45
46 /* 64-bit integer operations */
47
48 /*!
49  * @brief 64bit非負整数を n 回左シフトする。
50  * @param hi 上位32bit。負であってはならない。
51  * @param lo 下位32bit。
52  * @param n  シフト量。[0,31] の範囲でなければならない。
53  *
54  * hi や n に範囲外の値を渡したり、オーバーフローした場合の動作は未定義。
55  */
56 void s64b_lshift(int32_t *hi, uint32_t *lo, int n);
57
58 /*!
59  * @brief 64bit非負整数を n 回右シフトする。
60  * @param hi 上位32bit。負であってはならない。
61  * @param lo 下位32bit。
62  * @param n シフト量。[0,31] の範囲でなければならない。
63  *
64  * hi や n に範囲外の値を渡した場合の動作は未定義。
65  */
66 void s64b_rshift(int32_t *hi, uint32_t *lo, int n);
67
68 void s64b_add(int32_t *A1, uint32_t *A2, int32_t B1, uint32_t B2);
69 void s64b_sub(int32_t *A1, uint32_t *A2, int32_t B1, uint32_t B2);
70 int s64b_cmp(int32_t A1, uint32_t A2, int32_t B1, uint32_t B2);
71 void s64b_mul(int32_t *A1, uint32_t *A2, int32_t B1, uint32_t B2);
72 void s64b_div(int32_t *A1, uint32_t *A2, int32_t B1, uint32_t B2);
73 void s64b_mod(int32_t *A1, uint32_t *A2, int32_t B1, uint32_t B2);
74
75 int count_bits(BIT_FLAGS x);