2 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
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.
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 355800 2012-09-09 01:32:41Z $
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"
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.
57 #else /* ! __cplusplus */
62 typedef unsigned char bool; /* consistent w/BOOL */
66 #endif /* ! __cplusplus */
68 #if defined(_WIN64) && !defined(EFI)
69 /* use the Windows ULONG_PTR type when compiling for 64 bit */
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
;
83 #if defined(EFI) && !defined(_WIN64)
87 #if defined(TARGETOS_nucleus)
88 /* for 'size_t' type */
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;
101 #ifdef _MSC_VER /* Microsoft C */
102 #define TYPEDEF_INT64
103 #define TYPEDEF_UINT64
104 typedef signed __int64 int64
;
105 typedef unsigned __int64 uint64
;
112 #if defined(__NetBSD__)
118 #define TYPEDEF_USHORT
119 #define TYPEDEF_ULONG
122 #if defined(__sparc__)
123 #define TYPEDEF_ULONG
129 * If this is either a Linux hybrid build or the per-port code of a hybrid build
130 * then use the Linux header files to get some of the typedefs. Otherwise, define
131 * them entirely in this file. We can't always define the types because we get
132 * a duplicate typedef error; there is no way to "undefine" a typedef.
133 * We know when it's per-port code because each file defines LINUX_PORT at the top.
135 #if !defined(LINUX_HYBRID) || defined(LINUX_PORT)
137 #ifndef TARGETENV_android
138 #define TYPEDEF_USHORT
139 #define TYPEDEF_ULONG
140 #endif /* TARGETENV_android */
142 #include <linux/version.h>
143 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19))
145 #endif /* >= 2.6.19 */
146 /* special detection for 2.6.18-128.7.1.0.1.el5 */
147 #if (LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 18))
148 #include <linux/compiler.h>
149 #ifdef noinline_for_stack
152 #endif /* == 2.6.18 */
153 #endif /* __KERNEL__ */
154 #endif /* !defined(LINUX_HYBRID) || defined(LINUX_PORT) */
158 #define TYPEDEF_UCHAR
160 #define TYPEDEF_USHORT
161 #define TYPEDEF_ULONG
165 #if !defined(linux) && !defined(_WIN32) && !defined(_CFE_) && !defined(_MINOSL_) && \
166 !defined(__DJGPP__) && !defined(__ECOS) && !defined(__BOB__) && \
167 !defined(TARGETOS_nucleus) && !defined(EFI) && !defined(__FreeBSD__)
169 #define TYPEDEF_USHORT
173 /* Do not support the (u)int64 types with strict ansi for GNU C */
174 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
175 #define TYPEDEF_INT64
176 #define TYPEDEF_UINT64
179 /* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
180 * for signed or unsigned
184 #define TYPEDEF_INT64
186 #if defined(__STDC__)
187 #define TYPEDEF_UINT64
192 #if !defined(_WIN32) && !defined(_CFE_) && !defined(_MINOSL_) && !defined(__DJGPP__) && \
193 !defined(__BOB__) && !defined(TARGETOS_nucleus) && !defined(EFI)
195 /* pick up ushort & uint from standard types.h */
196 #if defined(linux) && defined(__KERNEL__)
199 #if !defined(LINUX_HYBRID) || defined(LINUX_PORT)
201 #include <sys/types.h>
203 #include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
204 #endif /* USER_MODE */
205 #endif /* !defined(LINUX_HYBRID) || defined(LINUX_PORT) */
210 #include <pkgconf/infra.h>
211 #include <cyg/infra/cyg_type.h>
215 #include <sys/types.h>
217 #endif /* linux && __KERNEL__ */
223 #ifdef __BIG_ENDIAN__
227 #error "IL_BIGENDIAN was defined for a little-endian compile"
229 #endif /* __BIG_ENDIAN__ */
231 #if !defined(__cplusplus)
233 #if defined(__i386__)
234 typedef unsigned char bool;
236 typedef unsigned int bool;
245 #include <IOKit/IOTypes.h>
248 #endif /* __cplusplus */
253 /* use the default typedefs in the next section of this file */
254 #define USE_TYPEDEF_DEFAULTS
256 #endif /* SITE_TYPEDEFS */
263 #ifdef USE_TYPEDEF_DEFAULTS
264 #undef USE_TYPEDEF_DEFAULTS
267 typedef /* @abstract@ */ unsigned char bool;
270 /* define uchar, ushort, uint, ulong */
272 #ifndef TYPEDEF_UCHAR
273 typedef unsigned char uchar
;
276 #ifndef TYPEDEF_USHORT
277 typedef unsigned short ushort
;
281 typedef unsigned int uint
;
284 #ifndef TYPEDEF_ULONG
285 typedef unsigned long ulong
;
288 /* define [u]int8/16/32/64, uintptr */
290 #ifndef TYPEDEF_UINT8
291 typedef unsigned char uint8
;
294 #ifndef TYPEDEF_UINT16
295 typedef unsigned short uint16
;
298 #ifndef TYPEDEF_UINT32
299 typedef unsigned int uint32
;
302 #ifndef TYPEDEF_UINT64
303 typedef unsigned long long uint64
;
306 #ifndef TYPEDEF_UINTPTR
307 typedef unsigned int uintptr
;
311 typedef signed char int8
;
314 #ifndef TYPEDEF_INT16
315 typedef signed short int16
;
318 #ifndef TYPEDEF_INT32
319 typedef signed int int32
;
322 #ifndef TYPEDEF_INT64
323 typedef signed long long int64
;
326 /* define float32/64, float_t */
328 #ifndef TYPEDEF_FLOAT32
329 typedef float float32
;
332 #ifndef TYPEDEF_FLOAT64
333 typedef double float64
;
337 * abstracted floating point type allows for compile time selection of
338 * single or double precision arithmetic. Compiling with -DFLOAT32
339 * selects single precision; the default is double precision.
342 #ifndef TYPEDEF_FLOAT_T
345 typedef float32 float_t
;
346 #else /* default to double precision floating point */
347 typedef float64 float_t
;
350 #endif /* TYPEDEF_FLOAT_T */
352 /* define macro values */
359 #define TRUE 1 /* TRUE */
371 #define ON 1 /* ON = 1 */
374 #define AUTO (-1) /* Auto = -1 */
376 /* define PTRSZ, INLINE */
379 #define PTRSZ sizeof(char*)
383 /* Detect compiler type. */
385 #define BWL_COMPILER_MICROSOFT
386 #elif defined(__GNUC__) || defined(__lint)
387 #define BWL_COMPILER_GNU
388 #elif defined(__CC_ARM) && __CC_ARM
389 #define BWL_COMPILER_ARMCC
391 #error "Unknown compiler!"
392 #endif /* _MSC_VER */
396 #if defined(BWL_COMPILER_MICROSOFT)
397 #define INLINE __inline
398 #elif defined(BWL_COMPILER_GNU)
399 #define INLINE __inline__
400 #elif defined(BWL_COMPILER_ARMCC)
401 #define INLINE __inline
404 #endif /* _MSC_VER */
409 #undef TYPEDEF_USHORT
413 #undef TYPEDEF_UINT16
414 #undef TYPEDEF_UINT32
415 #undef TYPEDEF_UINT64
416 #undef TYPEDEF_UINTPTR
421 #undef TYPEDEF_FLOAT32
422 #undef TYPEDEF_FLOAT64
423 #undef TYPEDEF_FLOAT_T
425 #endif /* USE_TYPEDEF_DEFAULTS */
427 /* Suppress unused parameter warning */
428 #define UNUSED_PARAMETER(x) (void)(x)
430 /* Avoid warning for discarded const or volatile qualifier in special cases (-Wcast-qual) */
431 #define DISCARD_QUAL(ptr, type) ((type *)(uintptr)(ptr))
434 * Including the bcmdefs.h here, to make sure everyone including typedefs.h
435 * gets this automatically
438 #endif /* _TYPEDEFS_H_ */