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