| 1 | /* |
| 2 | * Copyright 2007, 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 | */ |
| 10 | |
| 11 | #ifndef _TYPEDEFS_H_ |
| 12 | #define _TYPEDEFS_H_ |
| 13 | |
| 14 | |
| 15 | /* Define 'SITE_TYPEDEFS' in the compile to include a site specific |
| 16 | * typedef file "site_typedefs.h". |
| 17 | * |
| 18 | * If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs" |
| 19 | * section of this file makes inferences about the compile environment |
| 20 | * based on defined symbols and possibly compiler pragmas. |
| 21 | * |
| 22 | * Following these two sections is the "Default Typedefs" |
| 23 | * section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is |
| 24 | * defined. This section has a default set of typedefs and a few |
| 25 | * proprocessor symbols (TRUE, FALSE, NULL, ...). |
| 26 | */ |
| 27 | |
| 28 | #ifdef SITE_TYPEDEFS |
| 29 | |
| 30 | /* |
| 31 | * Site Specific Typedefs |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | #include "site_typedefs.h" |
| 36 | |
| 37 | #else |
| 38 | |
| 39 | /* |
| 40 | * Inferred Typedefs |
| 41 | * |
| 42 | */ |
| 43 | |
| 44 | /* Infer the compile environment based on preprocessor symbols and pramas. |
| 45 | * Override type definitions as needed, and include configuration dependent |
| 46 | * header files to define types. |
| 47 | */ |
| 48 | |
| 49 | #ifdef __cplusplus |
| 50 | |
| 51 | #define TYPEDEF_BOOL |
| 52 | #ifndef FALSE |
| 53 | #define FALSE false |
| 54 | #endif |
| 55 | #ifndef TRUE |
| 56 | #define TRUE true |
| 57 | #endif |
| 58 | |
| 59 | #else /* ! __cplusplus */ |
| 60 | |
| 61 | #if defined(_WIN32) |
| 62 | |
| 63 | #define TYPEDEF_BOOL |
| 64 | typedef unsigned char bool; /* consistent w/BOOL */ |
| 65 | |
| 66 | #endif /* _WIN32 */ |
| 67 | |
| 68 | #endif /* ! __cplusplus */ |
| 69 | |
| 70 | /* use the Windows ULONG_PTR type when compiling for 64 bit */ |
| 71 | #if defined(_WIN64) && !defined(EFI) |
| 72 | #include <basetsd.h> |
| 73 | #define TYPEDEF_UINTPTR |
| 74 | typedef ULONG_PTR uintptr; |
| 75 | #elif defined(__x86_64__) |
| 76 | #define TYPEDEF_UINTPTR |
| 77 | typedef unsigned long long int uintptr; |
| 78 | #endif |
| 79 | |
| 80 | |
| 81 | #if defined(_MINOSL_) |
| 82 | #define _NEED_SIZE_T_ |
| 83 | #endif |
| 84 | |
| 85 | #if defined(EFI) && !defined(_WIN64) |
| 86 | #define _NEED_SIZE_T_ |
| 87 | #endif |
| 88 | |
| 89 | #if defined(_NEED_SIZE_T_) |
| 90 | typedef long unsigned int size_t; |
| 91 | #endif |
| 92 | |
| 93 | #ifdef __DJGPP__ |
| 94 | typedef long unsigned int size_t; |
| 95 | #endif /* __DJGPP__ */ |
| 96 | |
| 97 | #ifdef _MSC_VER /* Microsoft C */ |
| 98 | #define TYPEDEF_INT64 |
| 99 | #define TYPEDEF_UINT64 |
| 100 | typedef signed __int64 int64; |
| 101 | typedef unsigned __int64 uint64; |
| 102 | #endif |
| 103 | |
| 104 | #if defined(MACOSX) |
| 105 | #define TYPEDEF_BOOL |
| 106 | #endif |
| 107 | |
| 108 | #if defined(__NetBSD__) |
| 109 | #define TYPEDEF_ULONG |
| 110 | #endif |
| 111 | |
| 112 | |
| 113 | #ifdef linux |
| 114 | #define TYPEDEF_UINT |
| 115 | #define TYPEDEF_USHORT |
| 116 | #define TYPEDEF_ULONG |
| 117 | #ifdef __KERNEL__ |
| 118 | #include <linux/version.h> |
| 119 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)) |
| 120 | #define TYPEDEF_BOOL |
| 121 | #endif /* >= 2.6.19 */ |
| 122 | #endif /* __KERNEL__ */ |
| 123 | #endif /* linux */ |
| 124 | |
| 125 | #if !defined(linux) && !defined(_WIN32) && !defined(_CFE_) && \ |
| 126 | !defined(_HNDRTE_) && !defined(_MINOSL_) && !defined(__DJGPP__) && !defined(__IOPOS__) |
| 127 | #define TYPEDEF_UINT |
| 128 | #define TYPEDEF_USHORT |
| 129 | #endif |
| 130 | |
| 131 | |
| 132 | /* Do not support the (u)int64 types with strict ansi for GNU C */ |
| 133 | #if defined(__GNUC__) && defined(__STRICT_ANSI__) |
| 134 | #define TYPEDEF_INT64 |
| 135 | #define TYPEDEF_UINT64 |
| 136 | #endif |
| 137 | |
| 138 | /* ICL accepts unsigned 64 bit type only, and complains in ANSI mode |
| 139 | * for singned or unsigned |
| 140 | */ |
| 141 | #if defined(__ICL) |
| 142 | |
| 143 | #define TYPEDEF_INT64 |
| 144 | |
| 145 | #if defined(__STDC__) |
| 146 | #define TYPEDEF_UINT64 |
| 147 | #endif |
| 148 | |
| 149 | #endif /* __ICL */ |
| 150 | |
| 151 | #if !defined(_WIN32) && !defined(_CFE_) && !defined(_MINOSL_) && \ |
| 152 | !defined(__DJGPP__) && !defined(__IOPOS__) |
| 153 | |
| 154 | /* pick up ushort & uint from standard types.h */ |
| 155 | #if defined(linux) && defined(__KERNEL__) |
| 156 | |
| 157 | #include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */ |
| 158 | |
| 159 | #else |
| 160 | |
| 161 | #include <sys/types.h> |
| 162 | |
| 163 | #endif |
| 164 | |
| 165 | #endif |
| 166 | |
| 167 | #if defined(MACOSX) |
| 168 | |
| 169 | #ifdef __BIG_ENDIAN__ |
| 170 | #define IL_BIGENDIAN |
| 171 | #else |
| 172 | #ifdef IL_BIGENDIAN |
| 173 | #error "IL_BIGENDIAN was defined for a little-endian compile" |
| 174 | #endif |
| 175 | #endif /* __BIG_ENDIAN__ */ |
| 176 | |
| 177 | #if !defined(__cplusplus) |
| 178 | |
| 179 | #if defined(__i386__) |
| 180 | typedef unsigned char bool; |
| 181 | #else |
| 182 | typedef unsigned int bool; |
| 183 | #endif |
| 184 | #define TYPE_BOOL 1 |
| 185 | enum { |
| 186 | false = 0, |
| 187 | true = 1 |
| 188 | }; |
| 189 | |
| 190 | #if defined(KERNEL) |
| 191 | #include <IOKit/IOTypes.h> |
| 192 | #endif /* KERNEL */ |
| 193 | |
| 194 | #endif /* __cplusplus */ |
| 195 | |
| 196 | #endif /* MACOSX */ |
| 197 | |
| 198 | |
| 199 | /* use the default typedefs in the next section of this file */ |
| 200 | #define USE_TYPEDEF_DEFAULTS |
| 201 | |
| 202 | #endif /* SITE_TYPEDEFS */ |
| 203 | |
| 204 | |
| 205 | /* |
| 206 | * Default Typedefs |
| 207 | * |
| 208 | */ |
| 209 | |
| 210 | #ifdef USE_TYPEDEF_DEFAULTS |
| 211 | #undef USE_TYPEDEF_DEFAULTS |
| 212 | |
| 213 | #ifndef TYPEDEF_BOOL |
| 214 | typedef /* @abstract@ */ unsigned char bool; |
| 215 | #endif |
| 216 | |
| 217 | /* define uchar, ushort, uint, ulong */ |
| 218 | |
| 219 | #ifndef TYPEDEF_UCHAR |
| 220 | typedef unsigned char uchar; |
| 221 | #endif |
| 222 | |
| 223 | #ifndef TYPEDEF_USHORT |
| 224 | typedef unsigned short ushort; |
| 225 | #endif |
| 226 | |
| 227 | #ifndef TYPEDEF_UINT |
| 228 | typedef unsigned int uint; |
| 229 | #endif |
| 230 | |
| 231 | #ifndef TYPEDEF_ULONG |
| 232 | typedef unsigned long ulong; |
| 233 | #endif |
| 234 | |
| 235 | /* define [u]int8/16/32/64, uintptr */ |
| 236 | |
| 237 | #ifndef TYPEDEF_UINT8 |
| 238 | typedef unsigned char uint8; |
| 239 | #endif |
| 240 | |
| 241 | #ifndef TYPEDEF_UINT16 |
| 242 | typedef unsigned short uint16; |
| 243 | #endif |
| 244 | |
| 245 | #ifndef TYPEDEF_UINT32 |
| 246 | typedef unsigned int uint32; |
| 247 | #endif |
| 248 | |
| 249 | #ifndef TYPEDEF_UINT64 |
| 250 | typedef unsigned long long uint64; |
| 251 | #endif |
| 252 | |
| 253 | #ifndef TYPEDEF_UINTPTR |
| 254 | typedef unsigned int uintptr; |
| 255 | #endif |
| 256 | |
| 257 | #ifndef TYPEDEF_INT8 |
| 258 | typedef signed char int8; |
| 259 | #endif |
| 260 | |
| 261 | #ifndef TYPEDEF_INT16 |
| 262 | typedef signed short int16; |
| 263 | #endif |
| 264 | |
| 265 | #ifndef TYPEDEF_INT32 |
| 266 | typedef signed int int32; |
| 267 | #endif |
| 268 | |
| 269 | #ifndef TYPEDEF_INT64 |
| 270 | typedef signed long long int64; |
| 271 | #endif |
| 272 | |
| 273 | /* define float32/64, float_t */ |
| 274 | |
| 275 | #ifndef TYPEDEF_FLOAT32 |
| 276 | typedef float float32; |
| 277 | #endif |
| 278 | |
| 279 | #ifndef TYPEDEF_FLOAT64 |
| 280 | typedef double float64; |
| 281 | #endif |
| 282 | |
| 283 | /* |
| 284 | * abstracted floating point type allows for compile time selection of |
| 285 | * single or double precision arithmetic. Compiling with -DFLOAT32 |
| 286 | * selects single precision; the default is double precision. |
| 287 | */ |
| 288 | |
| 289 | #ifndef TYPEDEF_FLOAT_T |
| 290 | |
| 291 | #if defined(FLOAT32) |
| 292 | typedef float32 float_t; |
| 293 | #else /* default to double precision floating point */ |
| 294 | typedef float64 float_t; |
| 295 | #endif |
| 296 | |
| 297 | #endif /* TYPEDEF_FLOAT_T */ |
| 298 | |
| 299 | /* define macro values */ |
| 300 | |
| 301 | #ifndef FALSE |
| 302 | #define FALSE 0 |
| 303 | #endif |
| 304 | |
| 305 | #ifndef TRUE |
| 306 | #define TRUE 1 /* TRUE */ |
| 307 | #endif |
| 308 | |
| 309 | #ifndef NULL |
| 310 | #define NULL 0 |
| 311 | #endif |
| 312 | |
| 313 | #ifndef OFF |
| 314 | #define OFF 0 |
| 315 | #endif |
| 316 | |
| 317 | #ifndef ON |
| 318 | #define ON 1 /* ON = 1 */ |
| 319 | #endif |
| 320 | |
| 321 | #define AUTO (-1) /* Auto = -1 */ |
| 322 | |
| 323 | /* define PTRSZ, INLINE */ |
| 324 | |
| 325 | #ifndef PTRSZ |
| 326 | #define PTRSZ sizeof(char*) |
| 327 | #endif |
| 328 | |
| 329 | #ifndef INLINE |
| 330 | |
| 331 | #ifdef _MSC_VER |
| 332 | |
| 333 | #define INLINE __inline |
| 334 | |
| 335 | #elif defined(__GNUC__) |
| 336 | |
| 337 | #define INLINE __inline__ |
| 338 | |
| 339 | #else |
| 340 | |
| 341 | #define INLINE |
| 342 | |
| 343 | #endif /* _MSC_VER */ |
| 344 | |
| 345 | #endif /* INLINE */ |
| 346 | |
| 347 | #undef TYPEDEF_BOOL |
| 348 | #undef TYPEDEF_UCHAR |
| 349 | #undef TYPEDEF_USHORT |
| 350 | #undef TYPEDEF_UINT |
| 351 | #undef TYPEDEF_ULONG |
| 352 | #undef TYPEDEF_UINT8 |
| 353 | #undef TYPEDEF_UINT16 |
| 354 | #undef TYPEDEF_UINT32 |
| 355 | #undef TYPEDEF_UINT64 |
| 356 | #undef TYPEDEF_UINTPTR |
| 357 | #undef TYPEDEF_INT8 |
| 358 | #undef TYPEDEF_INT16 |
| 359 | #undef TYPEDEF_INT32 |
| 360 | #undef TYPEDEF_INT64 |
| 361 | #undef TYPEDEF_FLOAT32 |
| 362 | #undef TYPEDEF_FLOAT64 |
| 363 | #undef TYPEDEF_FLOAT_T |
| 364 | |
| 365 | #endif /* USE_TYPEDEF_DEFAULTS */ |
| 366 | |
| 367 | /* |
| 368 | * Including the bcmdefs.h here, to make sure everyone including typedefs.h |
| 369 | * gets this automatically |
| 370 | */ |
| 371 | #include "bcmdefs.h" |
| 372 | |
| 373 | #endif /* _TYPEDEFS_H_ */ |
| 374 | |