1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) 1999-2019, Broadcom. 4 * 5 * Unless you and Broadcom execute a separate written software license 6 * agreement governing use of this software, this software is licensed to you 7 * under the terms of the GNU General Public License version 2 (the "GPL"), 8 * available at http://www.broadcom.com/licenses/GPLv2.php, with the 9 * following added to such license: 10 * 11 * As a special exception, the copyright holders of this software give you 12 * permission to link this software with independent modules, and to copy and 13 * distribute the resulting executable under terms of your choice, provided that 14 * you also meet, for each linked independent module, the terms and conditions of 15 * the license of that module. An independent module is a module which is not 16 * derived from this software. The special exception does not apply to any 17 * modifications of the software. 18 * 19 * Notwithstanding the above, under no circumstances may you combine this 20 * software in any way with any other Broadcom software provided under a license 21 * other than the GPL, without Broadcom's express prior written consent. 22 * 23 * 24 * <<Broadcom-WL-IPTag/Open:>> 25 * 26 * $Id: typedefs.h 742663 2018-01-23 06:57:52Z $ 27 */ 28 29 #ifndef _TYPEDEFS_H_ 30 #define _TYPEDEFS_H_ 31 32 #if (!defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)) || \ 33 !defined(BWL_NO_INTERNAL_STDLIB_SUPPORT) 34 35 #ifdef SITE_TYPEDEFS 36 37 /* 38 * Define SITE_TYPEDEFS in the compile to include a site-specific 39 * typedef file "site_typedefs.h". 40 * 41 * If SITE_TYPEDEFS is not defined, then the code section below makes 42 * inferences about the compile environment based on defined symbols and 43 * possibly compiler pragmas. 44 * 45 * Following these two sections is the Default Typedefs section. 46 * This section is only processed if USE_TYPEDEF_DEFAULTS is 47 * defined. This section has a default set of typedefs and a few 48 * preprocessor symbols (TRUE, FALSE, NULL, ...). 49 */ 50 51 #include "site_typedefs.h" 52 53 #else 54 55 /* 56 * Infer the compile environment based on preprocessor symbols and pragmas. 57 * Override type definitions as needed, and include configuration-dependent 58 * header files to define types. 59 */ 60 61 #ifdef __cplusplus 62 63 #define TYPEDEF_BOOL 64 #ifndef FALSE 65 #define FALSE false 66 #endif // endif 67 #ifndef TRUE 68 #define TRUE true 69 #endif // endif 70 71 #else /* ! __cplusplus */ 72 73 #endif /* ! __cplusplus */ 74 75 #if !defined(TYPEDEF_UINTPTR) 76 #if defined(__LP64__) 77 #define TYPEDEF_UINTPTR 78 typedef unsigned long long int uintptr; 79 #endif // endif 80 #endif /* TYPEDEF_UINTPTR */ 81 82 /* float_t types conflict with the same typedefs from the standard ANSI-C 83 ** math.h header file. Don't re-typedef them here. 84 */ 85 86 #if defined(_NEED_SIZE_T_) 87 typedef long unsigned int size_t; 88 #endif // endif 89 90 #if defined(__sparc__) 91 #define TYPEDEF_ULONG 92 #endif // endif 93 94 /* 95 * If this is either a Linux hybrid build or the per-port code of a hybrid build 96 * then use the Linux header files to get some of the typedefs. Otherwise, define 97 * them entirely in this file. We can't always define the types because we get 98 * a duplicate typedef error; there is no way to "undefine" a typedef. 99 * We know when it's per-port code because each file defines LINUX_PORT at the top. 100 */ 101 #define TYPEDEF_UINT 102 #ifndef TARGETENV_android 103 #define TYPEDEF_USHORT 104 #define TYPEDEF_ULONG 105 #endif /* TARGETENV_android */ 106 #ifdef __KERNEL__ 107 #include <linux/version.h> 108 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)) 109 #define TYPEDEF_BOOL 110 #endif /* >= 2.6.19 */ 111 /* special detection for 2.6.18-128.7.1.0.1.el5 */ 112 #if (LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 18)) 113 #include <linux/compiler.h> 114 #ifdef noinline_for_stack 115 #define TYPEDEF_BOOL 116 #endif // endif 117 #endif /* == 2.6.18 */ 118 #endif /* __KERNEL__ */ 119 120 /* Do not support the (u)int64 types with strict ansi for GNU C */ 121 #if defined(__GNUC__) && defined(__STRICT_ANSI__) 122 #define TYPEDEF_INT64 123 #define TYPEDEF_UINT64 124 #endif /* defined(__GNUC__) && defined(__STRICT_ANSI__) */ 125 126 /* ICL accepts unsigned 64 bit type only, and complains in ANSI mode 127 * for signed or unsigned 128 */ 129 #if defined(__ICL) 130 131 #define TYPEDEF_INT64 132 133 #if defined(__STDC__) 134 #define TYPEDEF_UINT64 135 #endif // endif 136 137 #endif /* __ICL */ 138 139 #if !defined(__DJGPP__) 140 141 /* pick up ushort & uint from standard types.h */ 142 #if defined(__KERNEL__) 143 144 /* See note above */ 145 #include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */ 146 147 #else 148 149 #include <sys/types.h> 150 151 #endif /* linux && __KERNEL__ */ 152 153 #endif // endif 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 * Default Typedefs 162 */ 163 164 #ifdef USE_TYPEDEF_DEFAULTS 165 #undef USE_TYPEDEF_DEFAULTS 166 167 #ifndef TYPEDEF_BOOL 168 typedef /* @abstract@ */ unsigned char bool; 169 #endif /* endif TYPEDEF_BOOL */ 170 171 /* define uchar, ushort, uint, ulong */ 172 173 #ifndef TYPEDEF_UCHAR 174 typedef unsigned char uchar; 175 #endif // endif 176 177 #ifndef TYPEDEF_USHORT 178 typedef unsigned short ushort; 179 #endif // endif 180 181 #ifndef TYPEDEF_UINT 182 typedef unsigned int uint; 183 #endif // endif 184 185 #ifndef TYPEDEF_ULONG 186 typedef unsigned long ulong; 187 #endif // endif 188 189 /* define [u]int8/16/32/64, uintptr */ 190 191 #ifndef TYPEDEF_UINT8 192 typedef unsigned char uint8; 193 #endif // endif 194 195 #ifndef TYPEDEF_UINT16 196 typedef unsigned short uint16; 197 #endif // endif 198 199 #ifndef TYPEDEF_UINT32 200 typedef unsigned int uint32; 201 #endif // endif 202 203 #ifndef TYPEDEF_UINT64 204 typedef unsigned long long uint64; 205 #endif // endif 206 207 #ifndef TYPEDEF_UINTPTR 208 typedef unsigned int uintptr; 209 #endif // endif 210 211 #ifndef TYPEDEF_INT8 212 typedef signed char int8; 213 #endif // endif 214 215 #ifndef TYPEDEF_INT16 216 typedef signed short int16; 217 #endif // endif 218 219 #ifndef TYPEDEF_INT32 220 typedef signed int int32; 221 #endif // endif 222 223 #ifndef TYPEDEF_INT64 224 typedef signed long long int64; 225 #endif // endif 226 227 /* define float32/64, float_t */ 228 229 #ifndef TYPEDEF_FLOAT32 230 typedef float float32; 231 #endif // endif 232 233 #ifndef TYPEDEF_FLOAT64 234 typedef double float64; 235 #endif // endif 236 237 /* 238 * abstracted floating point type allows for compile time selection of 239 * single or double precision arithmetic. Compiling with -DFLOAT32 240 * selects single precision; the default is double precision. 241 */ 242 243 #ifndef TYPEDEF_FLOAT_T 244 245 #if defined(FLOAT32) 246 typedef float32 float_t; 247 #else /* default to double precision floating point */ 248 typedef float64 float_t; 249 #endif // endif 250 251 #endif /* TYPEDEF_FLOAT_T */ 252 253 /* define macro values */ 254 255 #ifndef FALSE 256 #define FALSE 0 257 #endif // endif 258 259 #ifndef TRUE 260 #define TRUE 1 /* TRUE */ 261 #endif // endif 262 263 #ifndef NULL 264 #define NULL 0 265 #endif // endif 266 267 #ifndef OFF 268 #define OFF 0 269 #endif // endif 270 271 #ifndef ON 272 #define ON 1 /* ON = 1 */ 273 #endif // endif 274 275 #define AUTO (-1) /* Auto = -1 */ 276 277 /* define PTRSZ, INLINE */ 278 279 #ifndef PTRSZ 280 #define PTRSZ sizeof(char*) 281 #endif // endif 282 283 /* Detect compiler type. */ 284 #if defined(__GNUC__) || defined(__lint) 285 #define BWL_COMPILER_GNU 286 #elif defined(__CC_ARM) && __CC_ARM 287 #define BWL_COMPILER_ARMCC 288 #else 289 #error "Unknown compiler!" 290 #endif // endif 291 292 #ifndef INLINE 293 #if defined(BWL_COMPILER_MICROSOFT) 294 #define INLINE __inline 295 #elif defined(BWL_COMPILER_GNU) 296 #define INLINE __inline__ 297 #elif defined(BWL_COMPILER_ARMCC) 298 #define INLINE __inline 299 #else 300 #define INLINE 301 #endif 302 #endif /* INLINE */ 303 304 #undef TYPEDEF_BOOL 305 #undef TYPEDEF_UCHAR 306 #undef TYPEDEF_USHORT 307 #undef TYPEDEF_UINT 308 #undef TYPEDEF_ULONG 309 #undef TYPEDEF_UINT8 310 #undef TYPEDEF_UINT16 311 #undef TYPEDEF_UINT32 312 #undef TYPEDEF_UINT64 313 #undef TYPEDEF_UINTPTR 314 #undef TYPEDEF_INT8 315 #undef TYPEDEF_INT16 316 #undef TYPEDEF_INT32 317 #undef TYPEDEF_INT64 318 #undef TYPEDEF_FLOAT32 319 #undef TYPEDEF_FLOAT64 320 #undef TYPEDEF_FLOAT_T 321 322 #endif /* USE_TYPEDEF_DEFAULTS */ 323 324 /* Suppress unused parameter warning */ 325 #define UNUSED_PARAMETER(x) (void)(x) 326 327 /* Avoid warning for discarded const or volatile qualifier in special cases (-Wcast-qual) */ 328 #define DISCARD_QUAL(ptr, type) ((type *)(uintptr)(ptr)) 329 330 #else /* !EDK_RELEASE_VERSION || (EDK_RELEASE_VERSION < 0x00020000) */ 331 332 #include <sys/types.h> 333 #include <strings.h> 334 #include <stdlib.h> 335 336 #ifdef stderr 337 #undef stderr 338 #define stderr stdout 339 #endif // endif 340 341 typedef UINT8 uint8; 342 typedef UINT16 uint16; 343 typedef UINT32 uint32; 344 typedef UINT64 uint64; 345 typedef INT8 int8; 346 typedef INT16 int16; 347 typedef INT32 int32; 348 typedef INT64 int64; 349 350 typedef BOOLEAN bool; 351 typedef unsigned char uchar; 352 typedef UINTN uintptr; 353 354 #define UNUSED_PARAMETER(x) (void)(x) 355 #define DISCARD_QUAL(ptr, type) ((type *)(uintptr)(ptr)) 356 #define INLINE 357 #define AUTO (-1) /* Auto = -1 */ 358 #define ON 1 /* ON = 1 */ 359 #define OFF 0 360 361 #endif /* !EDK_RELEASE_VERSION || (EDK_RELEASE_VERSION < 0x00020000) */ 362 363 /* 364 * Including the bcmdefs.h here, to make sure everyone including typedefs.h 365 * gets this automatically 366 */ 367 #include <bcmdefs.h> 368 #endif /* _TYPEDEFS_H_ */ 369