Tomato-ND 1.21
[tomato.git] / release / src / include / typedefs.h
blob6e550bdc5f96c6b5e29116c2a2c6a0272a337253
1 /*
2 * Copyright 2006, 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$
12 #ifndef _TYPEDEFS_H_
13 #define _TYPEDEFS_H_
16 /* Define 'SITE_TYPEDEFS' in the compile to include a site specific
17 * typedef file "site_typedefs.h".
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.
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, ...).
29 #ifdef SITE_TYPEDEFS
32 * Site Specific Typedefs
36 #include "site_typedefs.h"
38 #else
41 * Inferred Typedefs
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.
50 #ifdef __cplusplus
52 #define TYPEDEF_BOOL
53 #ifndef FALSE
54 #define FALSE false
55 #endif
56 #ifndef TRUE
57 #define TRUE true
58 #endif
60 #else /* ! __cplusplus */
62 #if defined(_WIN32)
64 #define TYPEDEF_BOOL
65 typedef unsigned char bool; /* consistent w/BOOL */
67 #endif /* _WIN32 */
69 #endif /* ! __cplusplus */
71 /* use the Windows ULONG_PTR type when compiling for 64 bit */
72 #if defined(_WIN64)
73 #include <basetsd.h>
74 #define TYPEDEF_UINTPTR
75 typedef ULONG_PTR uintptr;
76 #endif
79 #if defined(_MINOSL_)
80 #define _NEED_SIZE_T_
81 #endif
83 #if defined(_NEED_SIZE_T_)
84 typedef long unsigned int size_t;
85 #endif
87 #ifdef __DJGPP__
88 typedef long unsigned int size_t;
89 #endif /* __DJGPP__ */
91 #ifdef _MSC_VER /* Microsoft C */
92 #define TYPEDEF_INT64
93 #define TYPEDEF_UINT64
94 typedef signed __int64 int64;
95 typedef unsigned __int64 uint64;
96 #endif
98 #if defined(MACOSX)
99 #define TYPEDEF_BOOL
100 #endif
102 #if defined(__NetBSD__)
103 #define TYPEDEF_ULONG
104 #endif
107 #if defined(linux)
108 #define TYPEDEF_UINT
109 #define TYPEDEF_USHORT
110 #define TYPEDEF_ULONG
111 #endif
113 #if !defined(linux) && !defined(_WIN32) && !defined(_CFE_) && \
114 !defined(_HNDRTE_) && !defined(_MINOSL_) && !defined(__DJGPP__)
115 #define TYPEDEF_UINT
116 #define TYPEDEF_USHORT
117 #endif
120 /* Do not support the (u)int64 types with strict ansi for GNU C */
121 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
122 #define TYPEDEF_INT64
123 #define TYPEDEF_UINT64
124 #endif
126 /* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
127 * for singned or unsigned
129 #if defined(__ICL)
131 #define TYPEDEF_INT64
133 #if defined(__STDC__)
134 #define TYPEDEF_UINT64
135 #endif
137 #endif /* __ICL */
139 #if !defined(_WIN32) && !defined(_CFE_) && !defined(_MINOSL_) && \
140 !defined(__DJGPP__)
142 /* pick up ushort & uint from standard types.h */
143 #if defined(linux) && defined(__KERNEL__)
145 #include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
147 #else
149 #include <sys/types.h>
151 #endif
153 #endif
155 #if defined(MACOSX)
157 #ifdef __BIG_ENDIAN__
158 #define IL_BIGENDIAN
159 #else
160 #ifdef IL_BIGENDIAN
161 #error "IL_BIGENDIAN was defined for a little-endian compile"
162 #endif
163 #endif /* __BIG_ENDIAN__ */
165 #if !defined(__cplusplus)
167 #if defined(__i386__)
168 typedef unsigned char bool;
169 #else
170 typedef unsigned int bool;
171 #endif
172 #define TYPE_BOOL 1
173 enum {
174 false = 0,
175 true = 1
178 #if defined(KERNEL)
179 #include <IOKit/IOTypes.h>
180 #endif /* KERNEL */
182 #endif /* __cplusplus */
184 #endif /* MACOSX */
187 /* use the default typedefs in the next section of this file */
188 #define USE_TYPEDEF_DEFAULTS
190 #endif /* SITE_TYPEDEFS */
194 * Default Typedefs
198 #ifdef USE_TYPEDEF_DEFAULTS
199 #undef USE_TYPEDEF_DEFAULTS
201 #ifndef TYPEDEF_BOOL
202 typedef /* @abstract@ */ unsigned char bool;
203 #endif
205 /* define uchar, ushort, uint, ulong */
207 #ifndef TYPEDEF_UCHAR
208 typedef unsigned char uchar;
209 #endif
211 #ifndef TYPEDEF_USHORT
212 typedef unsigned short ushort;
213 #endif
215 #ifndef TYPEDEF_UINT
216 typedef unsigned int uint;
217 #endif
219 #ifndef TYPEDEF_ULONG
220 typedef unsigned long ulong;
221 #endif
223 /* define [u]int8/16/32/64, uintptr */
225 #ifndef TYPEDEF_UINT8
226 typedef unsigned char uint8;
227 #endif
229 #ifndef TYPEDEF_UINT16
230 typedef unsigned short uint16;
231 #endif
233 #ifndef TYPEDEF_UINT32
234 typedef unsigned int uint32;
235 #endif
237 #ifndef TYPEDEF_UINT64
238 typedef unsigned long long uint64;
239 #endif
241 #ifndef TYPEDEF_UINTPTR
242 typedef unsigned int uintptr;
243 #endif
245 #ifndef TYPEDEF_INT8
246 typedef signed char int8;
247 #endif
249 #ifndef TYPEDEF_INT16
250 typedef signed short int16;
251 #endif
253 #ifndef TYPEDEF_INT32
254 typedef signed int int32;
255 #endif
257 #ifndef TYPEDEF_INT64
258 typedef signed long long int64;
259 #endif
261 /* define float32/64, float_t */
263 #ifndef TYPEDEF_FLOAT32
264 typedef float float32;
265 #endif
267 #ifndef TYPEDEF_FLOAT64
268 typedef double float64;
269 #endif
272 * abstracted floating point type allows for compile time selection of
273 * single or double precision arithmetic. Compiling with -DFLOAT32
274 * selects single precision; the default is double precision.
277 #ifndef TYPEDEF_FLOAT_T
279 #if defined(FLOAT32)
280 typedef float32 float_t;
281 #else /* default to double precision floating point */
282 typedef float64 float_t;
283 #endif
285 #endif /* TYPEDEF_FLOAT_T */
287 /* define macro values */
289 #ifndef FALSE
290 #define FALSE 0
291 #endif
293 #ifndef TRUE
294 #define TRUE 1 /* TRUE */
295 #endif
297 #ifndef NULL
298 #define NULL 0
299 #endif
301 #ifndef OFF
302 #define OFF 0
303 #endif
305 #ifndef ON
306 #define ON 1 /* ON = 1 */
307 #endif
309 #define AUTO (-1) /* Auto = -1 */
311 /* define PTRSZ, INLINE */
313 #ifndef PTRSZ
314 #define PTRSZ sizeof(char*)
315 #endif
317 #ifndef INLINE
319 #ifdef _MSC_VER
321 #define INLINE __inline
323 #elif defined(__GNUC__)
325 #define INLINE __inline__
327 #else
329 #define INLINE
331 #endif /* _MSC_VER */
333 #endif /* INLINE */
335 #undef TYPEDEF_BOOL
336 #undef TYPEDEF_UCHAR
337 #undef TYPEDEF_USHORT
338 #undef TYPEDEF_UINT
339 #undef TYPEDEF_ULONG
340 #undef TYPEDEF_UINT8
341 #undef TYPEDEF_UINT16
342 #undef TYPEDEF_UINT32
343 #undef TYPEDEF_UINT64
344 #undef TYPEDEF_UINTPTR
345 #undef TYPEDEF_INT8
346 #undef TYPEDEF_INT16
347 #undef TYPEDEF_INT32
348 #undef TYPEDEF_INT64
349 #undef TYPEDEF_FLOAT32
350 #undef TYPEDEF_FLOAT64
351 #undef TYPEDEF_FLOAT_T
353 #endif /* USE_TYPEDEF_DEFAULTS */
356 * Including the bcmdefs.h here, to make sure everyone including typedefs.h
357 * gets this automatically
359 #include <bcmdefs.h>
361 #endif /* _TYPEDEFS_H_ */