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".
46 /*** Special 4 letter names for some standard types ***/
49 /* A standard pointer (to "void" because ANSI C says so) */
52 /* A simple pointer (to unmodifiable strings) */
53 typedef const char *cptr;
56 /* Since float's are silly, hard code real numbers as doubles */
60 /* Error codes for function return values */
61 /* Success = 0, Failure = -N, Problem = +N */
66 * Hack -- prevent problems with non-MACINTOSH
69 #define uint uint_hack
72 * Hack -- prevent problems with MSDOS and WINDOWS
75 #define huge huge_hack
78 * Hack -- prevent problems with AMIGA
81 #define byte byte_hack
84 * Hack -- prevent problems with C++
87 #define bool bool_hack
90 /* Note that "signed char" is not always "defined" */
91 /* So always use "s16b" to hold small signed values */
92 /* A signed byte of memory */
93 /* typedef signed char syte; */
95 /* Note that unsigned values can cause math problems */
96 /* An unsigned byte of memory */
97 typedef unsigned char byte;
99 /* Note that a bool is smaller than a full "int" */
100 /* Simple True/False type */
104 /* A signed, standard integer (at least 2 bytes) */
107 /* An unsigned, "standard" integer (often pre-defined) */
108 typedef unsigned int uint;
111 /* The largest possible signed integer (pre-defined) */
112 /* typedef long long; */
114 /* The largest possible unsigned integer */
115 typedef unsigned long huge;
118 /* Signed/Unsigned 16 bit value */
120 typedef int16_t s16b;
121 typedef uint16_t u16b;
123 typedef signed short s16b;
124 typedef unsigned short u16b;
127 /* Signed/Unsigned 32 bit value */
129 typedef int32_t s32b;
130 typedef uint32_t u32b;
132 typedef signed long s32b;
133 typedef unsigned long u32b;
139 /*** Pointers to all the basic types defined above ***/
141 typedef real *real_ptr;
142 typedef errr *errr_ptr;
143 typedef char *char_ptr;
144 typedef byte *byte_ptr;
145 typedef bool *bool_ptr;
146 typedef sint *sint_ptr;
147 typedef uint *uint_ptr;
148 typedef long *long_ptr;
149 typedef huge *huge_ptr;
150 typedef s16b *s16b_ptr;
151 typedef u16b *u16b_ptr;
152 typedef s32b *s32b_ptr;
153 typedef u32b *u32b_ptr;
154 typedef vptr *vptr_ptr;
155 typedef cptr *cptr_ptr;
159 /*** Pointers to Functions of special types (for various purposes) ***/
161 /* A generic function takes a user data and a special data */
162 typedef errr (*func_gen)(vptr, vptr);
164 /* An equality testing function takes two things to compare (bool) */
165 typedef bool (*func_eql)(vptr, vptr);
167 /* A comparison function takes two things and to compare (-1,0,+1) */
168 typedef sint (*func_cmp)(vptr, vptr);
170 /* A hasher takes a thing (and a max hash size) to hash (0 to siz - 1) */
171 typedef uint (*func_hsh)(vptr, uint);
173 /* A key extractor takes a thing and returns (a pointer to) some key */
174 typedef vptr (*func_key)(vptr);