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