Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 1999-2013, Broadcom Corporation
      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  *
     16  * $Id: typedefs.h 286783 2011-09-29 06:18:57Z $
     17  */
     18 
     19 #ifndef _TYPEDEFS_H_
     20 #define _TYPEDEFS_H_
     21 
     22 #ifdef SITE_TYPEDEFS
     23 
     24 /*
     25  * Define SITE_TYPEDEFS in the compile to include a site-specific
     26  * typedef file "site_typedefs.h".
     27  *
     28  * If SITE_TYPEDEFS is not defined, then the code section below makes
     29  * inferences about the compile environment based on defined symbols and
     30  * possibly compiler pragmas.
     31  *
     32  * Following these two sections is the Default Typedefs section.
     33  * This section is only processed if USE_TYPEDEF_DEFAULTS is
     34  * defined. This section has a default set of typedefs and a few
     35  * preprocessor symbols (TRUE, FALSE, NULL, ...).
     36  */
     37 
     38 #include "site_typedefs.h"
     39 
     40 #else
     41 
     42 /*
     43  * Infer the compile environment based on preprocessor symbols and pragmas.
     44  * Override type definitions as needed, and include configuration-dependent
     45  * header files to define types.
     46  */
     47 
     48 #ifdef __cplusplus
     49 
     50 #define TYPEDEF_BOOL
     51 #ifndef FALSE
     52 #define FALSE	false
     53 #endif
     54 #ifndef TRUE
     55 #define TRUE	true
     56 #endif
     57 
     58 #else	/* ! __cplusplus */
     59 
     60 
     61 #endif	/* ! __cplusplus */
     62 
     63 #if defined(__x86_64__)
     64 #define TYPEDEF_UINTPTR
     65 typedef unsigned long long int uintptr;
     66 #endif
     67 
     68 
     69 
     70 
     71 
     72 #if defined(_NEED_SIZE_T_)
     73 typedef long unsigned int size_t;
     74 #endif
     75 
     76 
     77 
     78 
     79 #if defined(__sparc__)
     80 #define TYPEDEF_ULONG
     81 #endif
     82 
     83 
     84 /*
     85  * If this is either a Linux hybrid build or the per-port code of a hybrid build
     86  * then use the Linux header files to get some of the typedefs.  Otherwise, define
     87  * them entirely in this file.  We can't always define the types because we get
     88  * a duplicate typedef error; there is no way to "undefine" a typedef.
     89  * We know when it's per-port code because each file defines LINUX_PORT at the top.
     90  */
     91 #if !defined(LINUX_HYBRID) || defined(LINUX_PORT)
     92 #define TYPEDEF_UINT
     93 #ifndef TARGETENV_android
     94 #define TYPEDEF_USHORT
     95 #define TYPEDEF_ULONG
     96 #endif /* TARGETENV_android */
     97 #ifdef __KERNEL__
     98 #include <linux/version.h>
     99 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19))
    100 #define TYPEDEF_BOOL
    101 #endif	/* >= 2.6.19 */
    102 /* special detection for 2.6.18-128.7.1.0.1.el5 */
    103 #if (LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 18))
    104 #include <linux/compiler.h>
    105 #ifdef noinline_for_stack
    106 #define TYPEDEF_BOOL
    107 #endif
    108 #endif	/* == 2.6.18 */
    109 #endif	/* __KERNEL__ */
    110 #endif  /* !defined(LINUX_HYBRID) || defined(LINUX_PORT) */
    111 
    112 
    113 
    114 
    115 /* Do not support the (u)int64 types with strict ansi for GNU C */
    116 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
    117 #define TYPEDEF_INT64
    118 #define TYPEDEF_UINT64
    119 #endif
    120 
    121 /* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
    122  * for signed or unsigned
    123  */
    124 #if defined(__ICL)
    125 
    126 #define TYPEDEF_INT64
    127 
    128 #if defined(__STDC__)
    129 #define TYPEDEF_UINT64
    130 #endif
    131 
    132 #endif /* __ICL */
    133 
    134 #if !defined(__DJGPP__)
    135 
    136 /* pick up ushort & uint from standard types.h */
    137 #if defined(__KERNEL__)
    138 
    139 /* See note above */
    140 #if !defined(LINUX_HYBRID) || defined(LINUX_PORT)
    141 #include <linux/types.h>	/* sys/types.h and linux/types.h are oil and water */
    142 #endif /* !defined(LINUX_HYBRID) || defined(LINUX_PORT) */
    143 
    144 #else
    145 
    146 
    147 #include <sys/types.h>
    148 
    149 #endif /* linux && __KERNEL__ */
    150 
    151 #endif
    152 
    153 
    154 
    155 /* use the default typedefs in the next section of this file */
    156 #define USE_TYPEDEF_DEFAULTS
    157 
    158 #endif /* SITE_TYPEDEFS */
    159 
    160 
    161 /*
    162  * Default Typedefs
    163  */
    164 
    165 #ifdef USE_TYPEDEF_DEFAULTS
    166 #undef USE_TYPEDEF_DEFAULTS
    167 
    168 #ifndef TYPEDEF_BOOL
    169 typedef	/* @abstract@ */ unsigned char	bool;
    170 #endif
    171 
    172 /* define uchar, ushort, uint, ulong */
    173 
    174 #ifndef TYPEDEF_UCHAR
    175 typedef unsigned char	uchar;
    176 #endif
    177 
    178 #ifndef TYPEDEF_USHORT
    179 typedef unsigned short	ushort;
    180 #endif
    181 
    182 #ifndef TYPEDEF_UINT
    183 typedef unsigned int	uint;
    184 #endif
    185 
    186 #ifndef TYPEDEF_ULONG
    187 typedef unsigned long	ulong;
    188 #endif
    189 
    190 /* define [u]int8/16/32/64, uintptr */
    191 
    192 #ifndef TYPEDEF_UINT8
    193 typedef unsigned char	uint8;
    194 #endif
    195 
    196 #ifndef TYPEDEF_UINT16
    197 typedef unsigned short	uint16;
    198 #endif
    199 
    200 #ifndef TYPEDEF_UINT32
    201 typedef unsigned int	uint32;
    202 #endif
    203 
    204 #ifndef TYPEDEF_UINT64
    205 typedef unsigned long long uint64;
    206 #endif
    207 
    208 #ifndef TYPEDEF_UINTPTR
    209 typedef unsigned int	uintptr;
    210 #endif
    211 
    212 #ifndef TYPEDEF_INT8
    213 typedef signed char	int8;
    214 #endif
    215 
    216 #ifndef TYPEDEF_INT16
    217 typedef signed short	int16;
    218 #endif
    219 
    220 #ifndef TYPEDEF_INT32
    221 typedef signed int	int32;
    222 #endif
    223 
    224 #ifndef TYPEDEF_INT64
    225 typedef signed long long int64;
    226 #endif
    227 
    228 /* define float32/64, float_t */
    229 
    230 #ifndef TYPEDEF_FLOAT32
    231 typedef float		float32;
    232 #endif
    233 
    234 #ifndef TYPEDEF_FLOAT64
    235 typedef double		float64;
    236 #endif
    237 
    238 /*
    239  * abstracted floating point type allows for compile time selection of
    240  * single or double precision arithmetic.  Compiling with -DFLOAT32
    241  * selects single precision; the default is double precision.
    242  */
    243 
    244 #ifndef TYPEDEF_FLOAT_T
    245 
    246 #if defined(FLOAT32)
    247 typedef float32 float_t;
    248 #else /* default to double precision floating point */
    249 typedef float64 float_t;
    250 #endif
    251 
    252 #endif /* TYPEDEF_FLOAT_T */
    253 
    254 /* define macro values */
    255 
    256 #ifndef FALSE
    257 #define FALSE	0
    258 #endif
    259 
    260 #ifndef TRUE
    261 #define TRUE	1  /* TRUE */
    262 #endif
    263 
    264 #ifndef NULL
    265 #define	NULL	0
    266 #endif
    267 
    268 #ifndef OFF
    269 #define	OFF	0
    270 #endif
    271 
    272 #ifndef ON
    273 #define	ON	1  /* ON = 1 */
    274 #endif
    275 
    276 #define	AUTO	(-1) /* Auto = -1 */
    277 
    278 /* define PTRSZ, INLINE */
    279 
    280 #ifndef PTRSZ
    281 #define	PTRSZ	sizeof(char*)
    282 #endif
    283 
    284 
    285 /* Detect compiler type. */
    286 #if defined(__GNUC__) || defined(__lint)
    287 	#define BWL_COMPILER_GNU
    288 #elif defined(__CC_ARM) && __CC_ARM
    289 	#define BWL_COMPILER_ARMCC
    290 #else
    291 	#error "Unknown compiler!"
    292 #endif
    293 
    294 
    295 #ifndef INLINE
    296 	#if defined(BWL_COMPILER_MICROSOFT)
    297 		#define INLINE __inline
    298 	#elif defined(BWL_COMPILER_GNU)
    299 		#define INLINE __inline__
    300 	#elif defined(BWL_COMPILER_ARMCC)
    301 		#define INLINE	__inline
    302 	#else
    303 		#define INLINE
    304 	#endif
    305 #endif /* INLINE */
    306 
    307 #undef TYPEDEF_BOOL
    308 #undef TYPEDEF_UCHAR
    309 #undef TYPEDEF_USHORT
    310 #undef TYPEDEF_UINT
    311 #undef TYPEDEF_ULONG
    312 #undef TYPEDEF_UINT8
    313 #undef TYPEDEF_UINT16
    314 #undef TYPEDEF_UINT32
    315 #undef TYPEDEF_UINT64
    316 #undef TYPEDEF_UINTPTR
    317 #undef TYPEDEF_INT8
    318 #undef TYPEDEF_INT16
    319 #undef TYPEDEF_INT32
    320 #undef TYPEDEF_INT64
    321 #undef TYPEDEF_FLOAT32
    322 #undef TYPEDEF_FLOAT64
    323 #undef TYPEDEF_FLOAT_T
    324 
    325 #endif /* USE_TYPEDEF_DEFAULTS */
    326 
    327 /* Suppress unused parameter warning */
    328 #define UNUSED_PARAMETER(x) (void)(x)
    329 
    330 /* Avoid warning for discarded const or volatile qualifier in special cases (-Wcast-qual) */
    331 #define DISCARD_QUAL(ptr, type) ((type *)(uintptr)(ptr))
    332 
    333 /*
    334  * Including the bcmdefs.h here, to make sure everyone including typedefs.h
    335  * gets this automatically
    336 */
    337 #include <bcmdefs.h>
    338 #endif /* _TYPEDEFS_H_ */
    339