Angband
h-basic.h
Go to the documentation of this file.
1 
12 #ifndef INCLUDED_H_BASIC_H
13 #define INCLUDED_H_BASIC_H
14 
18 #ifdef HAVE_CONFIG_H
19 
20 # include "autoconf.h"
21 
22 #else
23 
24 /* Necessary? */
25 #ifdef NDS
26 # include <fat.h>
27 # include <unistd.h>
28 # include <reent.h>
29 # include <sys/iosupport.h>
30 # include <errno.h>
31 #endif
32 
36 # if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
37  || (defined(_MSC_VER) && _MSC_VER >= 1600L)
38 # define HAVE_STDINT_H
39 # endif
40 
41 # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
42 # define HAVE_STDbool_H
43 # endif
44 
48 #define HAVE_FCNTL_H
49 #define HAVE_STAT
50 
51 #endif /* HAVE_CONFIG_H */
52 
56 # if defined(_Windows) || defined(__WINDOWS__) || \
57  defined(__WIN32__) || defined(WIN32) || \
58  defined(__WINNT__) || defined(__NT__)
59 # ifndef WINDOWS
60 # define WINDOWS
61 # endif
62 # endif
63 
67 #if !defined(WINDOWS) && !defined(GAMEBOY) && !defined(NDS)
68 # define UNIX
69 
70 # ifndef HAVE_DIRENT_H
71 # define HAVE_DIRENT_H
72 # endif
73 #endif
74 
79 /* #define SETGID */
80 
81 
93 #undef PATH_SEP
94 #define PATH_SEP "/"
95 #define PATH_SEPC '/'
96 
97 #ifdef WINDOWS
98 # undef PATH_SEP
99 # undef PATH_SEPC
100 # define PATH_SEP "\\"
101 # define PATH_SEPC '\\'
102 #endif
103 
104 
111 /* Use various POSIX functions if available */
112 #undef _GNU_SOURCE
113 #define _GNU_SOURCE
114 
116 #include <ctype.h>
117 #include <stdbool.h>
118 #include <stdint.h>
119 #include <errno.h>
120 #include <limits.h>
121 #include <assert.h>
122 
123 #include <stdarg.h>
124 #include <stdio.h>
125 #include <stdlib.h>
126 #include <stddef.h>
127 #include <string.h>
128 #include <time.h>
129 
130 #include <wchar.h>
131 #include <wctype.h>
132 
134 #ifdef UNIX
135 # include <pwd.h>
136 # include <sys/stat.h>
137 # include <unistd.h>
138 #endif
139 
140 
141 
156 typedef int errr;
157 
158 /* Use guaranteed-size types */
159 typedef uint8_t byte;
160 
161 typedef uint16_t u16b;
162 typedef int16_t s16b;
163 
164 typedef uint32_t u32b;
165 typedef int32_t s32b;
166 
167 typedef uint64_t u64b;
168 typedef int64_t s64b;
169 
170 
173 #define DSTRINGIFY(x) #x
174 #define DSTRING(x) DSTRINGIFY(x)
175 #define DHERE __FILE__ ":" DSTRING(__LINE__) ": "
176 
177 
184 #undef MIN
185 #undef MAX
186 #undef ABS
187 #undef SGN
188 #undef CMP
189 
190 #define MIN(a,b) (((a) > (b)) ? (b) : (a))
191 #define MAX(a,b) (((a) < (b)) ? (b) : (a))
192 #define ABS(a) (((a) < 0) ? (-(a)) : (a))
193 #define SGN(a) (((a) < 0) ? (-1) : ((a) != 0))
194 #define CMP(a,b) ((a) < (b) ? -1 : ((b) < (a) ? 1 : 0))
195 
196 
206 #define N_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))
207 
218 #define A2I(X) ((X) - 'a')
219 #define I2A(X) ((X) + 'a')
220 #define D2I(X) ((X) - '0')
221 #define I2D(X) ((X) + '0')
222 
223 #endif /* INCLUDED_H_BASIC_H */
uint16_t u16b
Definition: h-basic.h:161
uint32_t u32b
Definition: h-basic.h:164
int errr
ANSI C headers.
Definition: h-basic.h:156
uint8_t byte
Definition: h-basic.h:159
int16_t s16b
Definition: h-basic.h:162
int64_t s64b
Definition: h-basic.h:168
int32_t s32b
Definition: h-basic.h:165
uint64_t u64b
Definition: h-basic.h:167