6b0c25e042487f5373b2b285cab556c8a807ce1f
[openwrt.git] / openwrt / package / openwrt / include / typedefs.h
1 /*
2 * Copyright 2004, 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$
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 #include "site_typedefs.h"
36
37 #else
38
39 /*******************************************************************************
40 * Inferred Typedefs
41 *******************************************************************************/
42
43 /* Infer the compile environment based on preprocessor symbols and pramas.
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 /* for Windows build, define bool as a uchar instead of the default int */
61 #if defined(_WIN32)
62
63 #define TYPEDEF_BOOL
64 typedef unsigned char bool;
65
66 #endif /* _WIN32 */
67
68 #endif /* ! __cplusplus */
69
70 #ifdef _MSC_VER /* Microsoft C */
71 #define TYPEDEF_INT64
72 #define TYPEDEF_UINT64
73 typedef signed __int64 int64;
74 typedef unsigned __int64 uint64;
75 #endif
76
77 #if defined(MACOSX) && defined(KERNEL)
78 #define TYPEDEF_BOOL
79 #endif
80
81
82 #if defined(linux)
83 #define TYPEDEF_UINT
84 #define TYPEDEF_USHORT
85 #define TYPEDEF_ULONG
86 #endif
87
88 #if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_)
89 #define TYPEDEF_UINT
90 #define TYPEDEF_USHORT
91 #endif
92
93
94 /* Do not support the (u)int64 types with strict ansi for GNU C */
95 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
96 #define TYPEDEF_INT64
97 #define TYPEDEF_UINT64
98 #endif
99
100 /* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
101 * for singned or unsigned */
102 #if defined(__ICL)
103
104 #define TYPEDEF_INT64
105
106 #if defined(__STDC__)
107 #define TYPEDEF_UINT64
108 #endif
109
110 #endif /* __ICL */
111
112
113 #if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_)
114
115 /* pick up ushort & uint from standard types.h */
116 #if defined(linux) && defined(__KERNEL__)
117
118 #include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
119
120 #else
121
122 #include <sys/types.h>
123
124 #endif
125
126 #endif /* !_WIN32 && !PMON && !_CFE_ */
127
128 #if defined(MACOSX) && defined(KERNEL)
129 #include <IOKit/IOTypes.h>
130 #endif
131
132
133 /* use the default typedefs in the next section of this file */
134 #define USE_TYPEDEF_DEFAULTS
135
136 #endif /* SITE_TYPEDEFS */
137
138
139 /*******************************************************************************
140 * Default Typedefs
141 *******************************************************************************/
142
143 #ifdef USE_TYPEDEF_DEFAULTS
144 #undef USE_TYPEDEF_DEFAULTS
145
146 #ifndef TYPEDEF_BOOL
147 typedef int bool;
148 #endif
149
150 /*----------------------- define uchar, ushort, uint, ulong ----------------*/
151
152 #ifndef TYPEDEF_UCHAR
153 typedef unsigned char uchar;
154 #endif
155
156 #ifndef TYPEDEF_USHORT
157 typedef unsigned short ushort;
158 #endif
159
160 #ifndef TYPEDEF_UINT
161 typedef unsigned int uint;
162 #endif
163
164 #ifndef TYPEDEF_ULONG
165 typedef unsigned long ulong;
166 #endif
167
168 /*----------------------- define [u]int8/16/32/64 --------------------------*/
169
170 #ifndef TYPEDEF_UINT8
171 typedef unsigned char uint8;
172 #endif
173
174 #ifndef TYPEDEF_UINT16
175 typedef unsigned short uint16;
176 #endif
177
178 #ifndef TYPEDEF_UINT32
179 typedef unsigned int uint32;
180 #endif
181
182 #ifndef TYPEDEF_UINT64
183 typedef unsigned long long uint64;
184 #endif
185
186 #ifndef TYPEDEF_INT8
187 typedef signed char int8;
188 #endif
189
190 #ifndef TYPEDEF_INT16
191 typedef signed short int16;
192 #endif
193
194 #ifndef TYPEDEF_INT32
195 typedef signed int int32;
196 #endif
197
198 #ifndef TYPEDEF_INT64
199 typedef signed long long int64;
200 #endif
201
202 /*----------------------- define float32/64, float_t -----------------------*/
203
204 #ifndef TYPEDEF_FLOAT32
205 typedef float float32;
206 #endif
207
208 #ifndef TYPEDEF_FLOAT64
209 typedef double float64;
210 #endif
211
212 /*
213 * abstracted floating point type allows for compile time selection of
214 * single or double precision arithmetic. Compiling with -DFLOAT32
215 * selects single precision; the default is double precision.
216 */
217
218 #ifndef TYPEDEF_FLOAT_T
219
220 #if defined(FLOAT32)
221 typedef float32 float_t;
222 #else /* default to double precision floating point */
223 typedef float64 float_t;
224 #endif
225
226 #endif /* TYPEDEF_FLOAT_T */
227
228 /*----------------------- define macro values -----------------------------*/
229
230 #ifndef FALSE
231 #define FALSE 0
232 #endif
233
234 #ifndef TRUE
235 #define TRUE 1
236 #endif
237
238 #ifndef NULL
239 #define NULL 0
240 #endif
241
242 #ifndef OFF
243 #define OFF 0
244 #endif
245
246 #ifndef ON
247 #define ON 1
248 #endif
249
250 /*----------------------- define PTRSZ, INLINE ----------------------------*/
251
252 #ifndef PTRSZ
253 #define PTRSZ sizeof (char*)
254 #endif
255
256 #ifndef INLINE
257
258 #ifdef _MSC_VER
259
260 #define INLINE __inline
261
262 #elif __GNUC__
263
264 #define INLINE __inline__
265
266 #else
267
268 #define INLINE
269
270 #endif /* _MSC_VER */
271
272 #endif /* INLINE */
273
274 #undef TYPEDEF_BOOL
275 #undef TYPEDEF_UCHAR
276 #undef TYPEDEF_USHORT
277 #undef TYPEDEF_UINT
278 #undef TYPEDEF_ULONG
279 #undef TYPEDEF_UINT8
280 #undef TYPEDEF_UINT16
281 #undef TYPEDEF_UINT32
282 #undef TYPEDEF_UINT64
283 #undef TYPEDEF_INT8
284 #undef TYPEDEF_INT16
285 #undef TYPEDEF_INT32
286 #undef TYPEDEF_INT64
287 #undef TYPEDEF_FLOAT32
288 #undef TYPEDEF_FLOAT64
289 #undef TYPEDEF_FLOAT_T
290
291 #endif /* USE_TYPEDEF_DEFAULTS */
292
293 #endif /* _TYPEDEFS_H_ */
This page took 0.059439 seconds and 3 git commands to generate.