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