• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef __LP64__
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 #include <stdbool.h>
169 
170 /* define uchar, ushort, uint, ulong */
171 
172 #ifndef TYPEDEF_UCHAR
173 typedef unsigned char	uchar;
174 #endif
175 
176 #ifndef TYPEDEF_USHORT
177 typedef unsigned short	ushort;
178 #endif
179 
180 #ifndef TYPEDEF_UINT
181 typedef unsigned int	uint;
182 #endif
183 
184 #ifndef TYPEDEF_ULONG
185 typedef unsigned long	ulong;
186 #endif
187 
188 /* define [u]int8/16/32/64, uintptr */
189 
190 #ifndef TYPEDEF_UINT8
191 typedef unsigned char	uint8;
192 #endif
193 
194 #ifndef TYPEDEF_UINT16
195 typedef unsigned short	uint16;
196 #endif
197 
198 #ifndef TYPEDEF_UINT32
199 typedef unsigned int	uint32;
200 #endif
201 
202 #ifndef TYPEDEF_UINT64
203 typedef unsigned long long uint64;
204 #endif
205 
206 #ifndef TYPEDEF_UINTPTR
207 typedef unsigned int	uintptr;
208 #endif
209 
210 #ifndef TYPEDEF_INT8
211 typedef signed char	int8;
212 #endif
213 
214 #ifndef TYPEDEF_INT16
215 typedef signed short	int16;
216 #endif
217 
218 #ifndef TYPEDEF_INT32
219 typedef signed int	int32;
220 #endif
221 
222 #ifndef TYPEDEF_INT64
223 typedef signed long long int64;
224 #endif
225 
226 /* define float32/64, float_t */
227 
228 #ifndef TYPEDEF_FLOAT32
229 typedef float		float32;
230 #endif
231 
232 #ifndef TYPEDEF_FLOAT64
233 typedef double		float64;
234 #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
249 
250 #endif /* TYPEDEF_FLOAT_T */
251 
252 /* define macro values */
253 
254 #ifndef FALSE
255 #define FALSE	0
256 #endif
257 
258 #ifndef TRUE
259 #define TRUE	1  /* TRUE */
260 #endif
261 
262 #ifndef NULL
263 #define	NULL	0
264 #endif
265 
266 #ifndef OFF
267 #define	OFF	0
268 #endif
269 
270 #ifndef ON
271 #define	ON	1  /* ON = 1 */
272 #endif
273 
274 #define	AUTO	(-1) /* Auto = -1 */
275 
276 /* define PTRSZ, INLINE */
277 
278 #ifndef PTRSZ
279 #define	PTRSZ	sizeof(char*)
280 #endif
281 
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
291 
292 
293 #ifndef INLINE
294 	#if defined(BWL_COMPILER_MICROSOFT)
295 		#define INLINE __inline
296 	#elif defined(BWL_COMPILER_GNU)
297 		#define INLINE __inline__
298 	#elif defined(BWL_COMPILER_ARMCC)
299 		#define INLINE	__inline
300 	#else
301 		#define INLINE
302 	#endif
303 #endif /* INLINE */
304 
305 #undef TYPEDEF_BOOL
306 #undef TYPEDEF_UCHAR
307 #undef TYPEDEF_USHORT
308 #undef TYPEDEF_UINT
309 #undef TYPEDEF_ULONG
310 #undef TYPEDEF_UINT8
311 #undef TYPEDEF_UINT16
312 #undef TYPEDEF_UINT32
313 #undef TYPEDEF_UINT64
314 #undef TYPEDEF_UINTPTR
315 #undef TYPEDEF_INT8
316 #undef TYPEDEF_INT16
317 #undef TYPEDEF_INT32
318 #undef TYPEDEF_INT64
319 #undef TYPEDEF_FLOAT32
320 #undef TYPEDEF_FLOAT64
321 #undef TYPEDEF_FLOAT_T
322 
323 #endif /* USE_TYPEDEF_DEFAULTS */
324 
325 /* Suppress unused parameter warning */
326 #define UNUSED_PARAMETER(x) (void)(x)
327 
328 /* Avoid warning for discarded const or volatile qualifier in special cases (-Wcast-qual) */
329 #define DISCARD_QUAL(ptr, type) ((type *)(uintptr)(ptr))
330 
331 /*
332  * Including the bcmdefs.h here, to make sure everyone including typedefs.h
333  * gets this automatically
334 */
335 #include <bcmdefs.h>
336 #endif /* _TYPEDEFS_H_ */
337