GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / include / typedefs.h
blob12fbdd4eb603f8b92cc11bec773748e52469f58b
1 /*
2 * Copyright (C) 2012, 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 355800 2012-09-09 01:32:41Z $
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 #define TYPEDEF_BOOL
110 #endif
112 #if defined(__NetBSD__)
113 #ifndef _KERNEL
114 #include <stdbool.h>
115 #endif
116 #define TYPEDEF_BOOL
117 #define TYPEDEF_UINT
118 #define TYPEDEF_USHORT
119 #define TYPEDEF_ULONG
120 #endif /* NetBSD */
122 #if defined(__sparc__)
123 #define TYPEDEF_ULONG
124 #endif
127 #ifdef linux
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)
136 #define TYPEDEF_UINT
137 #ifndef TARGETENV_android
138 #define TYPEDEF_USHORT
139 #define TYPEDEF_ULONG
140 #endif /* TARGETENV_android */
141 #ifdef __KERNEL__
142 #include <linux/version.h>
143 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19))
144 #define TYPEDEF_BOOL
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
150 #define TYPEDEF_BOOL
151 #endif
152 #endif /* == 2.6.18 */
153 #endif /* __KERNEL__ */
154 #endif /* !defined(LINUX_HYBRID) || defined(LINUX_PORT) */
155 #endif /* linux */
157 #if defined(__ECOS)
158 #define TYPEDEF_UCHAR
159 #define TYPEDEF_UINT
160 #define TYPEDEF_USHORT
161 #define TYPEDEF_ULONG
162 #define TYPEDEF_BOOL
163 #endif
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__)
168 #define TYPEDEF_UINT
169 #define TYPEDEF_USHORT
170 #endif
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
177 #endif
179 /* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
180 * for signed or unsigned
182 #if defined(__ICL)
184 #define TYPEDEF_INT64
186 #if defined(__STDC__)
187 #define TYPEDEF_UINT64
188 #endif
190 #endif /* __ICL */
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__)
198 /* See note above */
199 #if !defined(LINUX_HYBRID) || defined(LINUX_PORT)
200 #ifdef USER_MODE
201 #include <sys/types.h>
202 #else
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) */
207 #else
209 #if defined(__ECOS)
210 #include <pkgconf/infra.h>
211 #include <cyg/infra/cyg_type.h>
212 #include <stdarg.h>
213 #endif
215 #include <sys/types.h>
217 #endif /* linux && __KERNEL__ */
219 #endif
221 #if defined(MACOSX)
223 #ifdef __BIG_ENDIAN__
224 #define IL_BIGENDIAN
225 #else
226 #ifdef IL_BIGENDIAN
227 #error "IL_BIGENDIAN was defined for a little-endian compile"
228 #endif
229 #endif /* __BIG_ENDIAN__ */
231 #if !defined(__cplusplus)
233 #if defined(__i386__)
234 typedef unsigned char bool;
235 #else
236 typedef unsigned int bool;
237 #endif
238 #define TYPE_BOOL 1
239 enum {
240 false = 0,
241 true = 1
244 #if defined(KERNEL)
245 #include <IOKit/IOTypes.h>
246 #endif /* KERNEL */
248 #endif /* __cplusplus */
250 #endif /* MACOSX */
253 /* use the default typedefs in the next section of this file */
254 #define USE_TYPEDEF_DEFAULTS
256 #endif /* SITE_TYPEDEFS */
260 * Default Typedefs
263 #ifdef USE_TYPEDEF_DEFAULTS
264 #undef USE_TYPEDEF_DEFAULTS
266 #ifndef TYPEDEF_BOOL
267 typedef /* @abstract@ */ unsigned char bool;
268 #endif
270 /* define uchar, ushort, uint, ulong */
272 #ifndef TYPEDEF_UCHAR
273 typedef unsigned char uchar;
274 #endif
276 #ifndef TYPEDEF_USHORT
277 typedef unsigned short ushort;
278 #endif
280 #ifndef TYPEDEF_UINT
281 typedef unsigned int uint;
282 #endif
284 #ifndef TYPEDEF_ULONG
285 typedef unsigned long ulong;
286 #endif
288 /* define [u]int8/16/32/64, uintptr */
290 #ifndef TYPEDEF_UINT8
291 typedef unsigned char uint8;
292 #endif
294 #ifndef TYPEDEF_UINT16
295 typedef unsigned short uint16;
296 #endif
298 #ifndef TYPEDEF_UINT32
299 typedef unsigned int uint32;
300 #endif
302 #ifndef TYPEDEF_UINT64
303 typedef unsigned long long uint64;
304 #endif
306 #ifndef TYPEDEF_UINTPTR
307 typedef unsigned int uintptr;
308 #endif
310 #ifndef TYPEDEF_INT8
311 typedef signed char int8;
312 #endif
314 #ifndef TYPEDEF_INT16
315 typedef signed short int16;
316 #endif
318 #ifndef TYPEDEF_INT32
319 typedef signed int int32;
320 #endif
322 #ifndef TYPEDEF_INT64
323 typedef signed long long int64;
324 #endif
326 /* define float32/64, float_t */
328 #ifndef TYPEDEF_FLOAT32
329 typedef float float32;
330 #endif
332 #ifndef TYPEDEF_FLOAT64
333 typedef double float64;
334 #endif
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
344 #if defined(FLOAT32)
345 typedef float32 float_t;
346 #else /* default to double precision floating point */
347 typedef float64 float_t;
348 #endif
350 #endif /* TYPEDEF_FLOAT_T */
352 /* define macro values */
354 #ifndef FALSE
355 #define FALSE 0
356 #endif
358 #ifndef TRUE
359 #define TRUE 1 /* TRUE */
360 #endif
362 #ifndef NULL
363 #define NULL 0
364 #endif
366 #ifndef OFF
367 #define OFF 0
368 #endif
370 #ifndef ON
371 #define ON 1 /* ON = 1 */
372 #endif
374 #define AUTO (-1) /* Auto = -1 */
376 /* define PTRSZ, INLINE */
378 #ifndef PTRSZ
379 #define PTRSZ sizeof(char*)
380 #endif
383 /* Detect compiler type. */
384 #ifdef _MSC_VER
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
390 #else
391 #error "Unknown compiler!"
392 #endif /* _MSC_VER */
395 #ifndef INLINE
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
402 #else
403 #define INLINE
404 #endif /* _MSC_VER */
405 #endif /* INLINE */
407 #undef TYPEDEF_BOOL
408 #undef TYPEDEF_UCHAR
409 #undef TYPEDEF_USHORT
410 #undef TYPEDEF_UINT
411 #undef TYPEDEF_ULONG
412 #undef TYPEDEF_UINT8
413 #undef TYPEDEF_UINT16
414 #undef TYPEDEF_UINT32
415 #undef TYPEDEF_UINT64
416 #undef TYPEDEF_UINTPTR
417 #undef TYPEDEF_INT8
418 #undef TYPEDEF_INT16
419 #undef TYPEDEF_INT32
420 #undef TYPEDEF_INT64
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
437 #include <bcmdefs.h>
438 #endif /* _TYPEDEFS_H_ */