4 * Copyright (c) 1997 Ben Harrison
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.
11 #include "system/h-basic.h"
12 #include <string_view>
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".
20 /**** Available variables ****/
22 /* A concptr to the name of the program */
26 extern void (*plog_aux)(concptr);
27 extern void (*quit_aux)(concptr);
28 extern void (*core_aux)(concptr);
30 /**** Available Functions ****/
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);
37 /* Print an error message */
38 void plog(concptr str);
40 /* Exit, with optional message */
41 void quit(concptr str);
43 /* Dump core, with optional message */
44 void core(concptr str);
46 /* 64-bit integer operations */
49 * @brief 64bit非負整数を n 回左シフトする。
50 * @param hi 上位32bit。負であってはならない。
52 * @param n シフト量。[0,31] の範囲でなければならない。
54 * hi や n に範囲外の値を渡したり、オーバーフローした場合の動作は未定義。
56 void s64b_lshift(int32_t *hi, uint32_t *lo, int n);
59 * @brief 64bit非負整数を n 回右シフトする。
60 * @param hi 上位32bit。負であってはならない。
62 * @param n シフト量。[0,31] の範囲でなければならない。
64 * hi や n に範囲外の値を渡した場合の動作は未定義。
66 void s64b_rshift(int32_t *hi, uint32_t *lo, int n);
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);
75 int count_bits(BIT_FLAGS x);