Resync with broadcom drivers 5.100.138.20 and utilities.
[tomato.git] / release / src-rt / include / typedefs.h
blobfb3152eab031ac2faaee6234f2f17727961e1910
1 /*
2 * Copyright (C) 2010, Broadcom Corporation. All Rights Reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 * $Id: typedefs.h,v 1.103.12.6 2010-12-21 02:38:54 Exp $
18 #ifndef _TYPEDEFS_H_
19 #define _TYPEDEFS_H_
21 #ifdef SITE_TYPEDEFS
24 * Define SITE_TYPEDEFS in the compile to include a site-specific
25 * typedef file "site_typedefs.h".
27 * If SITE_TYPEDEFS is not defined, then the code section below makes
28 * inferences about the compile environment based on defined symbols and
29 * possibly compiler pragmas.
31 * Following these two sections is the Default Typedefs section.
32 * This section is only processed if USE_TYPEDEF_DEFAULTS is
33 * defined. This section has a default set of typedefs and a few
34 * preprocessor symbols (TRUE, FALSE, NULL, ...).
37 #include "site_typedefs.h"
39 #else
42 * Infer the compile environment based on preprocessor symbols and pragmas.
43 * Override type definitions as needed, and include configuration-dependent
44 * header files to define types.
47 #ifdef __cplusplus
49 #define TYPEDEF_BOOL
50 #ifndef FALSE
51 #define FALSE false
52 #endif
53 #ifndef TRUE
54 #define TRUE true
55 #endif
57 #else /* ! __cplusplus */
59 #if defined(_WIN32)
61 #define TYPEDEF_BOOL
62 typedef unsigned char bool; /* consistent w/BOOL */
64 #endif /* _WIN32 */
66 #endif /* ! __cplusplus */
68 #if defined(_WIN64) && !defined(EFI)
69 /* use the Windows ULONG_PTR type when compiling for 64 bit */
70 #include <basetsd.h>
71 #define TYPEDEF_UINTPTR
72 typedef ULONG_PTR uintptr;
73 #elif defined(__x86_64__)
74 #define TYPEDEF_UINTPTR
75 typedef unsigned long long int uintptr;
76 #endif
79 #if defined(_MINOSL_)
80 #define _NEED_SIZE_T_
81 #endif
83 #if defined(EFI) && !defined(_WIN64)
84 #define _NEED_SIZE_T_
85 #endif
87 #if defined(TARGETOS_nucleus)
88 /* for 'size_t' type */
89 #include <stddef.h>
91 /* float_t types conflict with the same typedefs from the standard ANSI-C
92 ** math.h header file. Don't re-typedef them here.
94 #define TYPEDEF_FLOAT_T
95 #endif /* TARGETOS_nucleus */
97 #if defined(_NEED_SIZE_T_)
98 typedef long unsigned int size_t;
99 #endif
101 #ifdef _MSC_VER /* Microsoft C */
102 #define TYPEDEF_INT64
103 #define TYPEDEF_UINT64
104 typedef signed __int64 int64;
105 typedef unsigned __int64 uint64;
106 #endif
108 #if defined(MACOSX)
109 #ifdef KERNEL
110 #include <libkern/version.h>
111 #if VERSION_MAJOR > 10
112 #define WLP2P
113 #define IO80211P2P
114 #define APSTA
115 #define WLMCHAN
116 #define WL_MULTIQUEUE
117 #define WL_BSSCFG_TX_SUPR
118 #define WIFI_ACT_FRAME
119 #define FAST_ACTFRM_TX
120 #endif
121 #endif /* KERNEL */
122 #define TYPEDEF_BOOL
123 #endif /* MAXOSX */
125 #if defined(__NetBSD__)
126 #ifndef _KERNEL
127 #include <stdbool.h>
128 #endif
129 #define TYPEDEF_BOOL
130 #define TYPEDEF_UINT
131 #define TYPEDEF_USHORT
132 #define TYPEDEF_ULONG
133 #endif /* NetBSD */
135 #if defined(__sparc__)
136 #define TYPEDEF_ULONG
137 #endif
140 #ifdef linux
142 * If this is either a Linux hybrid build or the per-port code of a hybrid build
143 * then use the Linux header files to get some of the typedefs. Otherwise, define
144 * them entirely in this file. We can't always define the types because we get
145 * a duplicate typedef error; there is no way to "undefine" a typedef.
146 * We know when it's per-port code because each file defines LINUX_PORT at the top.
148 #if !defined(LINUX_HYBRID) || defined(LINUX_PORT)
149 #define TYPEDEF_UINT
150 #ifndef TARGETENV_android
151 #define TYPEDEF_USHORT
152 #define TYPEDEF_ULONG
153 #endif /* TARGETENV_android */
154 #ifdef __KERNEL__
155 #include <linux/version.h>
156 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19))
157 #define TYPEDEF_BOOL
158 #endif /* >= 2.6.19 */
159 #endif /* __KERNEL__ */
160 #endif /* !defined(LINUX_HYBRID) || defined(LINUX_PORT) */
161 #endif /* linux */
163 #if defined(__ECOS)
164 #define TYPEDEF_UCHAR
165 #define TYPEDEF_UINT
166 #define TYPEDEF_USHORT
167 #define TYPEDEF_ULONG
168 #define TYPEDEF_BOOL
169 #endif
171 #if !defined(linux) && !defined(_WIN32) && !defined(_CFE_) && !defined(_MINOSL_) && \
172 !defined(__DJGPP__) && !defined(__ECOS) && !defined(__BOB__) && \
173 !defined(TARGETOS_nucleus)
174 #define TYPEDEF_UINT
175 #define TYPEDEF_USHORT
176 #endif
179 /* Do not support the (u)int64 types with strict ansi for GNU C */
180 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
181 #define TYPEDEF_INT64
182 #define TYPEDEF_UINT64
183 #endif
185 /* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
186 * for signed or unsigned
188 #if defined(__ICL)
190 #define TYPEDEF_INT64
192 #if defined(__STDC__)
193 #define TYPEDEF_UINT64
194 #endif
196 #endif /* __ICL */
198 #if !defined(_WIN32) && !defined(_CFE_) && !defined(_MINOSL_) && !defined(__DJGPP__) && \
199 !defined(__BOB__) && !defined(TARGETOS_nucleus)
201 /* pick up ushort & uint from standard types.h */
202 #if defined(linux) && defined(__KERNEL__)
204 /* See note above */
205 #if !defined(LINUX_HYBRID) || defined(LINUX_PORT)
206 #ifdef USER_MODE
207 #include <sys/types.h>
208 #else
209 #include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
210 #endif /* USER_MODE */
211 #endif /* !defined(LINUX_HYBRID) || defined(LINUX_PORT) */
213 #else
215 #if defined(__ECOS)
216 #include <pkgconf/infra.h>
217 #include <cyg/infra/cyg_type.h>
218 #include <stdarg.h>
219 #endif
221 #include <sys/types.h>
223 #endif /* linux && __KERNEL__ */
225 #endif
227 #if defined(MACOSX)
229 #ifdef __BIG_ENDIAN__
230 #define IL_BIGENDIAN
231 #else
232 #ifdef IL_BIGENDIAN
233 #error "IL_BIGENDIAN was defined for a little-endian compile"
234 #endif
235 #endif /* __BIG_ENDIAN__ */
237 #if !defined(__cplusplus)
239 #if defined(__i386__)
240 typedef unsigned char bool;
241 #else
242 typedef unsigned int bool;
243 #endif
244 #define TYPE_BOOL 1
245 enum {
246 false = 0,
247 true = 1
250 #if defined(KERNEL)
251 #include <IOKit/IOTypes.h>
252 #endif /* KERNEL */
254 #endif /* __cplusplus */
256 #endif /* MACOSX */
259 /* use the default typedefs in the next section of this file */
260 #define USE_TYPEDEF_DEFAULTS
262 #endif /* SITE_TYPEDEFS */
266 * Default Typedefs
269 #ifdef USE_TYPEDEF_DEFAULTS
270 #undef USE_TYPEDEF_DEFAULTS
272 #ifndef TYPEDEF_BOOL
273 typedef /* @abstract@ */ unsigned char bool;
274 #endif
276 /* define uchar, ushort, uint, ulong */
278 #ifndef TYPEDEF_UCHAR
279 typedef unsigned char uchar;
280 #endif
282 #ifndef TYPEDEF_USHORT
283 typedef unsigned short ushort;
284 #endif
286 #ifndef TYPEDEF_UINT
287 typedef unsigned int uint;
288 #endif
290 #ifndef TYPEDEF_ULONG
291 typedef unsigned long ulong;
292 #endif
294 /* define [u]int8/16/32/64, uintptr */
296 #ifndef TYPEDEF_UINT8
297 typedef unsigned char uint8;
298 #endif
300 #ifndef TYPEDEF_UINT16
301 typedef unsigned short uint16;
302 #endif
304 #ifndef TYPEDEF_UINT32
305 typedef unsigned int uint32;
306 #endif
308 #ifndef TYPEDEF_UINT64
309 typedef unsigned long long uint64;
310 #endif
312 #ifndef TYPEDEF_UINTPTR
313 typedef unsigned int uintptr;
314 #endif
316 #ifndef TYPEDEF_INT8
317 typedef signed char int8;
318 #endif
320 #ifndef TYPEDEF_INT16
321 typedef signed short int16;
322 #endif
324 #ifndef TYPEDEF_INT32
325 typedef signed int int32;
326 #endif
328 #ifndef TYPEDEF_INT64
329 typedef signed long long int64;
330 #endif
332 /* define float32/64, float_t */
334 #ifndef TYPEDEF_FLOAT32
335 typedef float float32;
336 #endif
338 #ifndef TYPEDEF_FLOAT64
339 typedef double float64;
340 #endif
343 * abstracted floating point type allows for compile time selection of
344 * single or double precision arithmetic. Compiling with -DFLOAT32
345 * selects single precision; the default is double precision.
348 #ifndef TYPEDEF_FLOAT_T
350 #if defined(FLOAT32)
351 typedef float32 float_t;
352 #else /* default to double precision floating point */
353 typedef float64 float_t;
354 #endif
356 #endif /* TYPEDEF_FLOAT_T */
358 /* define macro values */
360 #ifndef FALSE
361 #define FALSE 0
362 #endif
364 #ifndef TRUE
365 #define TRUE 1 /* TRUE */
366 #endif
368 #ifndef NULL
369 #define NULL 0
370 #endif
372 #ifndef OFF
373 #define OFF 0
374 #endif
376 #ifndef ON
377 #define ON 1 /* ON = 1 */
378 #endif
380 #define AUTO (-1) /* Auto = -1 */
382 /* define PTRSZ, INLINE */
384 #ifndef PTRSZ
385 #define PTRSZ sizeof(char*)
386 #endif
389 /* Detect compiler type. */
390 #ifdef _MSC_VER
391 #define BWL_COMPILER_MICROSOFT
392 #elif defined(__GNUC__)
393 #define BWL_COMPILER_GNU
394 #elif defined(__CC_ARM) && __CC_ARM
395 #define BWL_COMPILER_ARMCC
396 #else
397 #error "Unknown compiler!"
398 #endif /* _MSC_VER */
401 #ifndef INLINE
402 #if defined(BWL_COMPILER_MICROSOFT)
403 #define INLINE __inline
404 #elif defined(BWL_COMPILER_GNU)
405 #define INLINE __inline__
406 #elif defined(BWL_COMPILER_ARMCC)
407 #define INLINE __inline
408 #else
409 #define INLINE
410 #endif /* _MSC_VER */
411 #endif /* INLINE */
413 #undef TYPEDEF_BOOL
414 #undef TYPEDEF_UCHAR
415 #undef TYPEDEF_USHORT
416 #undef TYPEDEF_UINT
417 #undef TYPEDEF_ULONG
418 #undef TYPEDEF_UINT8
419 #undef TYPEDEF_UINT16
420 #undef TYPEDEF_UINT32
421 #undef TYPEDEF_UINT64
422 #undef TYPEDEF_UINTPTR
423 #undef TYPEDEF_INT8
424 #undef TYPEDEF_INT16
425 #undef TYPEDEF_INT32
426 #undef TYPEDEF_INT64
427 #undef TYPEDEF_FLOAT32
428 #undef TYPEDEF_FLOAT64
429 #undef TYPEDEF_FLOAT_T
431 #endif /* USE_TYPEDEF_DEFAULTS */
433 /* Suppress unused parameter warning */
434 #define UNUSED_PARAMETER(x) (void)(x)
437 * Including the bcmdefs.h here, to make sure everyone including typedefs.h
438 * gets this automatically
440 #include <bcmdefs.h>
442 * If android target is building then include this file
444 #ifndef LINUX_HYBRID
445 #ifdef TARGETENV_android
446 #include <bcm_android_types.h>
447 #endif /* TARGETENV_android */
448 #endif /* LINUX_HYBRID */
450 #endif /* _TYPEDEFS_H_ */