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 #ifndef INCLUDED_Z_UTIL_H
12 #define INCLUDED_Z_UTIL_H
18 * Extremely basic stuff, like global temp and constant variables.
19 * Also, some very useful low level functions, such as "streq()".
20 * All variables and functions in this file are "addressable".
24 /**** Available variables ****/
26 /* A cptr to the name of the program */
31 extern void (*plog_aux)(cptr);
32 extern void (*quit_aux)(cptr);
33 extern void (*core_aux)(cptr);
36 /**** Available Functions ****/
38 /* Test equality, prefix, suffix */
39 extern bool streq(cptr s, cptr t);
40 extern bool prefix(cptr s, cptr t);
41 extern bool suffix(cptr s, cptr t);
44 /* Print an error message */
45 extern void plog(cptr str);
47 /* Exit, with optional message */
48 extern void quit(cptr str);
50 /* Dump core, with optional message */
51 extern void core(cptr str);
54 /* 64-bit integer operations */
55 #define s64b_LSHIFT(V1, V2, N) {V1 = (V1<<(N)) | (V2>>(32-(N))); V2 <<= (N);}
56 #define s64b_RSHIFT(V1, V2, N) {V2 = (V1<<(32-(N))) | (V2>>(N)); V1 >>= (N);}
57 extern void s64b_add(s32b *A1, u32b *A2, s32b B1, u32b B2);
58 extern void s64b_sub(s32b *A1, u32b *A2, s32b B1, u32b B2);
59 extern int s64b_cmp(s32b A1, u32b A2, s32b B1, u32b B2);
60 extern void s64b_mul(s32b *A1, u32b *A2, s32b B1, u32b B2);
61 extern void s64b_div(s32b *A1, u32b *A2, s32b B1, u32b B2);
62 extern void s64b_mod(s32b *A1, u32b *A2, s32b B1, u32b B2);