adb6b1589d20b604a31dd8817a706510e60be0a8
[openwrt/openwrt.git] / target / linux / brcm-2.4 / files / arch / mips / bcm947xx / include / typedefs.h
1 /*
2 * Copyright 2007, Broadcom Corporation
3 * All Rights Reserved.
4 *
5 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
6 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
7 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
9 * $Id$
10 */
11
12 #ifndef _TYPEDEFS_H_
13 #define _TYPEDEFS_H_
14
15
16 /* Define 'SITE_TYPEDEFS' in the compile to include a site specific
17 * typedef file "site_typedefs.h".
18 *
19 * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs"
20 * section of this file makes inferences about the compile environment
21 * based on defined symbols and possibly compiler pragmas.
22 *
23 * Following these two sections is the "Default Typedefs"
24 * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is
25 * defined. This section has a default set of typedefs and a few
26 * proprocessor symbols (TRUE, FALSE, NULL, ...).
27 */
28
29 #ifdef SITE_TYPEDEFS
30
31 /*
32 * Site Specific Typedefs
33 *
34 */
35
36 #include "site_typedefs.h"
37
38 #else
39
40 /*
41 * Inferred Typedefs
42 *
43 */
44
45 /* Infer the compile environment based on preprocessor symbols and pramas.
46 * Override type definitions as needed, and include configuration dependent
47 * header files to define types.
48 */
49
50 #ifdef __cplusplus
51
52 #define TYPEDEF_BOOL
53 #ifndef FALSE
54 #define FALSE false
55 #endif
56 #ifndef TRUE
57 #define TRUE true
58 #endif
59
60 #else /* ! __cplusplus */
61
62 #if defined(_WIN32)
63
64 #define TYPEDEF_BOOL
65 typedef unsigned char bool; /* consistent w/BOOL */
66
67 #endif /* _WIN32 */
68
69 #endif /* ! __cplusplus */
70
71 /* use the Windows ULONG_PTR type when compiling for 64 bit */
72 #if defined(_WIN64) && !defined(EFI)
73 #include <basetsd.h>
74 #define TYPEDEF_UINTPTR
75 typedef ULONG_PTR uintptr;
76 #elif defined(__x86_64__)
77 #define TYPEDEF_UINTPTR
78 typedef unsigned long long int uintptr;
79 #endif
80
81
82 #if defined(_MINOSL_)
83 #define _NEED_SIZE_T_
84 #endif
85
86 #if defined(EFI) && !defined(_WIN64)
87 #define _NEED_SIZE_T_
88 #endif
89
90 #if defined(_NEED_SIZE_T_)
91 typedef long unsigned int size_t;
92 #endif
93
94 #ifdef __DJGPP__
95 typedef long unsigned int size_t;
96 #endif /* __DJGPP__ */
97
98 #ifdef _MSC_VER /* Microsoft C */
99 #define TYPEDEF_INT64
100 #define TYPEDEF_UINT64
101 typedef signed __int64 int64;
102 typedef unsigned __int64 uint64;
103 #endif
104
105 #if defined(MACOSX)
106 #define TYPEDEF_BOOL
107 #endif
108
109 #if defined(__NetBSD__)
110 #define TYPEDEF_ULONG
111 #endif
112
113
114 #ifdef linux
115 #define TYPEDEF_UINT
116 #define TYPEDEF_USHORT
117 #define TYPEDEF_ULONG
118 #ifdef __KERNEL__
119 #include <linux/version.h>
120 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19))
121 #define TYPEDEF_BOOL
122 #endif /* >= 2.6.19 */
123 #endif /* __KERNEL__ */
124 #endif /* linux */
125
126 #if !defined(linux) && !defined(_WIN32) && !defined(_CFE_) && \
127 !defined(_HNDRTE_) && !defined(_MINOSL_) && !defined(__DJGPP__) && !defined(__IOPOS__)
128 #define TYPEDEF_UINT
129 #define TYPEDEF_USHORT
130 #endif
131
132
133 /* Do not support the (u)int64 types with strict ansi for GNU C */
134 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
135 #define TYPEDEF_INT64
136 #define TYPEDEF_UINT64
137 #endif
138
139 /* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
140 * for singned or unsigned
141 */
142 #if defined(__ICL)
143
144 #define TYPEDEF_INT64
145
146 #if defined(__STDC__)
147 #define TYPEDEF_UINT64
148 #endif
149
150 #endif /* __ICL */
151
152 #if !defined(_WIN32) && !defined(_CFE_) && !defined(_MINOSL_) && \
153 !defined(__DJGPP__) && !defined(__IOPOS__)
154
155 /* pick up ushort & uint from standard types.h */
156 #if defined(linux) && defined(__KERNEL__)
157
158 #include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
159
160 #else
161
162 #include <sys/types.h>
163
164 #endif
165
166 #endif
167
168 #if defined(MACOSX)
169
170 #ifdef __BIG_ENDIAN__
171 #define IL_BIGENDIAN
172 #else
173 #ifdef IL_BIGENDIAN
174 #error "IL_BIGENDIAN was defined for a little-endian compile"
175 #endif
176 #endif /* __BIG_ENDIAN__ */
177
178 #if !defined(__cplusplus)
179
180 #if defined(__i386__)
181 typedef unsigned char bool;
182 #else
183 typedef unsigned int bool;
184 #endif
185 #define TYPE_BOOL 1
186 enum {
187 false = 0,
188 true = 1
189 };
190
191 #if defined(KERNEL)
192 #include <IOKit/IOTypes.h>
193 #endif /* KERNEL */
194
195 #endif /* __cplusplus */
196
197 #endif /* MACOSX */
198
199
200 /* use the default typedefs in the next section of this file */
201 #define USE_TYPEDEF_DEFAULTS
202
203 #endif /* SITE_TYPEDEFS */
204
205
206 /*
207 * Default Typedefs
208 *
209 */
210
211 #ifdef USE_TYPEDEF_DEFAULTS
212 #undef USE_TYPEDEF_DEFAULTS
213
214 #ifndef TYPEDEF_BOOL
215 typedef /* @abstract@ */ unsigned char bool;
216 #endif
217
218 /* define uchar, ushort, uint, ulong */
219
220 #ifndef TYPEDEF_UCHAR
221 typedef unsigned char uchar;
222 #endif
223
224 #ifndef TYPEDEF_USHORT
225 typedef unsigned short ushort;
226 #endif
227
228 #ifndef TYPEDEF_UINT
229 typedef unsigned int uint;
230 #endif
231
232 #ifndef TYPEDEF_ULONG
233 typedef unsigned long ulong;
234 #endif
235
236 /* define [u]int8/16/32/64, uintptr */
237
238 #ifndef TYPEDEF_UINT8
239 typedef unsigned char uint8;
240 #endif
241
242 #ifndef TYPEDEF_UINT16
243 typedef unsigned short uint16;
244 #endif
245
246 #ifndef TYPEDEF_UINT32
247 typedef unsigned int uint32;
248 #endif
249
250 #ifndef TYPEDEF_UINT64
251 typedef unsigned long long uint64;
252 #endif
253
254 #ifndef TYPEDEF_UINTPTR
255 typedef unsigned int uintptr;
256 #endif
257
258 #ifndef TYPEDEF_INT8
259 typedef signed char int8;
260 #endif
261
262 #ifndef TYPEDEF_INT16
263 typedef signed short int16;
264 #endif
265
266 #ifndef TYPEDEF_INT32
267 typedef signed int int32;
268 #endif
269
270 #ifndef TYPEDEF_INT64
271 typedef signed long long int64;
272 #endif
273
274 /* define float32/64, float_t */
275
276 #ifndef TYPEDEF_FLOAT32
277 typedef float float32;
278 #endif
279
280 #ifndef TYPEDEF_FLOAT64
281 typedef double float64;
282 #endif
283
284 /*
285 * abstracted floating point type allows for compile time selection of
286 * single or double precision arithmetic. Compiling with -DFLOAT32
287 * selects single precision; the default is double precision.
288 */
289
290 #ifndef TYPEDEF_FLOAT_T
291
292 #if defined(FLOAT32)
293 typedef float32 float_t;
294 #else /* default to double precision floating point */
295 typedef float64 float_t;
296 #endif
297
298 #endif /* TYPEDEF_FLOAT_T */
299
300 /* define macro values */
301
302 #ifndef FALSE
303 #define FALSE 0
304 #endif
305
306 #ifndef TRUE
307 #define TRUE 1 /* TRUE */
308 #endif
309
310 #ifndef NULL
311 #define NULL 0
312 #endif
313
314 #ifndef OFF
315 #define OFF 0
316 #endif
317
318 #ifndef ON
319 #define ON 1 /* ON = 1 */
320 #endif
321
322 #define AUTO (-1) /* Auto = -1 */
323
324 /* define PTRSZ, INLINE */
325
326 #ifndef PTRSZ
327 #define PTRSZ sizeof(char*)
328 #endif
329
330 #ifndef INLINE
331
332 #ifdef _MSC_VER
333
334 #define INLINE __inline
335
336 #elif defined(__GNUC__)
337
338 #define INLINE __inline__
339
340 #else
341
342 #define INLINE
343
344 #endif /* _MSC_VER */
345
346 #endif /* INLINE */
347
348 #undef TYPEDEF_BOOL
349 #undef TYPEDEF_UCHAR
350 #undef TYPEDEF_USHORT
351 #undef TYPEDEF_UINT
352 #undef TYPEDEF_ULONG
353 #undef TYPEDEF_UINT8
354 #undef TYPEDEF_UINT16
355 #undef TYPEDEF_UINT32
356 #undef TYPEDEF_UINT64
357 #undef TYPEDEF_UINTPTR
358 #undef TYPEDEF_INT8
359 #undef TYPEDEF_INT16
360 #undef TYPEDEF_INT32
361 #undef TYPEDEF_INT64
362 #undef TYPEDEF_FLOAT32
363 #undef TYPEDEF_FLOAT64
364 #undef TYPEDEF_FLOAT_T
365
366 #endif /* USE_TYPEDEF_DEFAULTS */
367
368 /*
369 * Including the bcmdefs.h here, to make sure everyone including typedefs.h
370 * gets this automatically
371 */
372 #include "bcmdefs.h"
373
374 #endif /* _TYPEDEFS_H_ */