3 #ifndef INCLUDED_H_TYPE_H
4 #define INCLUDED_H_TYPE_H
9 * Note the attempt to make all basic types have 4 letters.
10 * This improves readibility and standardizes the code.
12 * Likewise, all complex types are at least 4 letters.
13 * Thus, almost every three letter word is a legal variable.
14 * But beware of certain reserved words ('for' and 'if' and 'do').
16 * Note that the type used in structures for bit flags should be uint.
17 * As long as these bit flags are sequential, they will be space smart.
19 * Note that on some machines, apparently "signed char" is illegal.
21 * It must be true that char/byte takes exactly 1 byte
22 * It must be true that sind/uind takes exactly 2 bytes
23 * It must be true that sbig/ubig takes exactly 4 bytes
25 * On Sparc's, a sint takes 4 bytes (2 is legal)
26 * On Sparc's, a uint takes 4 bytes (2 is legal)
27 * On Sparc's, a long takes 4 bytes (8 is legal)
28 * On Sparc's, a huge takes 4 bytes (8 is legal)
29 * On Sparc's, a vptr takes 4 bytes (8 is legal)
30 * On Sparc's, a real takes 8 bytes (4 is legal)
32 * Note that some files have already been included by "h-include.h"
33 * These include <stdio.h> and <sys/types>, which define some types
34 * In particular, uint is defined so we do not have to define it
36 * Also, see <limits.h> for min/max values for sind, uind, long, huge
37 * (SHRT_MIN, SHRT_MAX, USHRT_MAX, LONG_MIN, LONG_MAX, ULONG_MAX)
38 * These limits should be verified and coded into "h-constant.h".
43 /*** Special 4 letter names for some standard types ***/
46 /* A standard pointer (to "void" because ANSI C says so) */
49 /* A simple pointer (to unmodifiable strings) */
50 typedef const char *cptr;
53 /* Since float's are silly, hard code real numbers as doubles */
57 /* Error codes for function return values */
58 /* Success = 0, Failure = -N, Problem = +N */
63 * Hack -- prevent problems with non-MACINTOSH
66 #define uint uint_hack
69 * Hack -- prevent problems with MSDOS and WINDOWS
72 #define huge huge_hack
75 * Hack -- prevent problems with AMIGA
78 #define byte byte_hack
81 * Hack -- prevent problems with C++
84 #define bool bool_hack
87 /* Note that "signed char" is not always "defined" */
88 /* So always use "s16b" to hold small signed values */
89 /* A signed byte of memory */
90 /* typedef signed char syte; */
92 /* Note that unsigned values can cause math problems */
93 /* An unsigned byte of memory */
94 typedef unsigned char byte;
96 /* Note that a bool is smaller than a full "int" */
97 /* Simple True/False type */
101 /* A signed, standard integer (at least 2 bytes) */
104 /* An unsigned, "standard" integer (often pre-defined) */
105 typedef unsigned int uint;
108 /* The largest possible signed integer (pre-defined) */
109 /* typedef long long; */
111 /* The largest possible unsigned integer */
112 typedef unsigned long huge;
115 /* Signed/Unsigned 16 bit value */
116 typedef signed short s16b;
117 typedef unsigned short u16b;
119 /* Signed/Unsigned 32 bit value */
120 #ifdef L64 /* 64 bit longs */
121 typedef signed int s32b;
122 typedef unsigned int u32b;
124 typedef signed long s32b;
125 typedef unsigned long u32b;
131 /*** Pointers to all the basic types defined above ***/
133 typedef real *real_ptr;
134 typedef errr *errr_ptr;
135 typedef char *char_ptr;
136 typedef byte *byte_ptr;
137 typedef bool *bool_ptr;
138 typedef sint *sint_ptr;
139 typedef uint *uint_ptr;
140 typedef long *long_ptr;
141 typedef huge *huge_ptr;
142 typedef s16b *s16b_ptr;
143 typedef u16b *u16b_ptr;
144 typedef s32b *s32b_ptr;
145 typedef u32b *u32b_ptr;
146 typedef vptr *vptr_ptr;
147 typedef cptr *cptr_ptr;
151 /*** Pointers to Functions with simple return types and any args ***/
153 typedef void (*func_void)();
154 typedef errr (*func_errr)();
155 typedef char (*func_char)();
156 typedef byte (*func_byte)();
157 typedef bool (*func_bool)();
158 typedef sint (*func_sint)();
159 typedef uint (*func_uint)();
160 typedef real (*func_real)();
161 typedef vptr (*func_vptr)();
162 typedef cptr (*func_cptr)();
166 /*** Pointers to Functions of special types (for various purposes) ***/
168 /* A generic function takes a user data and a special data */
169 typedef errr (*func_gen)(vptr, vptr);
171 /* An equality testing function takes two things to compare (bool) */
172 typedef bool (*func_eql)(vptr, vptr);
174 /* A comparison function takes two things and to compare (-1,0,+1) */
175 typedef sint (*func_cmp)(vptr, vptr);
177 /* A hasher takes a thing (and a max hash size) to hash (0 to siz - 1) */
178 typedef uint (*func_hsh)(vptr, uint);
180 /* A key extractor takes a thing and returns (a pointer to) some key */
181 typedef vptr (*func_key)(vptr);