| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2005, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bstd_defs.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/8 $ |
|---|
| 12 | * $brcm_Date: 1/18/06 12:05p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/basemodules/std/types/generic/bstd_defs.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/8 1/18/06 12:05p rjlewis |
|---|
| 21 | * PR19044: new compiler in vxworks 6 defines bool to be uchar. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/7 9/18/03 10:43a jasonh |
|---|
| 24 | * Fixed check to work with non-win32 systems. |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/6 9/17/03 1:42p frusso |
|---|
| 27 | * Added check for MS C version >=13 when defining intptr_t. This |
|---|
| 28 | * applies to Visual Studio 2003 builds |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/5 9/5/03 11:09a jasonh |
|---|
| 31 | * Added BSTD_UNUSED. |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/4 7/28/03 11:54a vsilyaev |
|---|
| 34 | * for MSC_VER>13 (Visual Studio 2003), bool should be defined as char. |
|---|
| 35 | * That's needed to make it compatible with MS VC++ bool. |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/3 4/17/03 1:37p dlwin |
|---|
| 38 | * Use VxWorks' int64_t and uint64_t for VxWorks builds. |
|---|
| 39 | * |
|---|
| 40 | * Hydra_Software_Devel/2 4/8/03 6:02p vsilyaev |
|---|
| 41 | * Added 64-bit integers. |
|---|
| 42 | * |
|---|
| 43 | ***************************************************************************/ |
|---|
| 44 | #ifndef BSTD_DEFS_H__ |
|---|
| 45 | #define BSTD_DEFS_H__ |
|---|
| 46 | #include "bstd.h" |
|---|
| 47 | #if 0 |
|---|
| 48 | /****************************************************************************** |
|---|
| 49 | |
|---|
| 50 | This header file implements the environment described below, with the |
|---|
| 51 | exception of <float.h>, for the following compilation environments: |
|---|
| 52 | |
|---|
| 53 | - C90 (as defined by ISO/IEC 9899:1990(E)) |
|---|
| 54 | - C95 (as defined by ISO/IEC 9899:1995(E) Amendment 1 to C90) |
|---|
| 55 | - C99 (as defined by ISO/IEC 9899:1999(E)) |
|---|
| 56 | - C++ (as defined by ISO/IEC 14882:1998(E)) |
|---|
| 57 | |
|---|
| 58 | As stated in ISO/IEC 9899:1999(E) clause 4 paragraph 6: |
|---|
| 59 | |
|---|
| 60 | "A conforming freestanding implementation shall accept any strictly |
|---|
| 61 | conforming program that does not use complex types and in which the |
|---|
| 62 | use of the features specified in the library clause (clause 7) is |
|---|
| 63 | confined to the contents of the standard headers <float.h>, |
|---|
| 64 | <iso646.h>, <limits.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, and |
|---|
| 65 | <stdint.h>." |
|---|
| 66 | |
|---|
| 67 | Our intention is to standardize on a set of types that is based on C99. |
|---|
| 68 | |
|---|
| 69 | ******************************************************************************/ |
|---|
| 70 | |
|---|
| 71 | #define BSTD_UNUSED(x) { volatile void *bstd_unused; bstd_unused = (void *)&(x); } |
|---|
| 72 | |
|---|
| 73 | #define STDC_1995 199409L |
|---|
| 74 | #define STDC_1999 199901L |
|---|
| 75 | |
|---|
| 76 | #if defined __STDC_VERSION__ && __STDC_VERSION__ != STDC_1995 && __STDC_VERSION__ != STDC_1999 |
|---|
| 77 | #pragma message( "Unanticipated value: predefined macro __STDC_VERSION__" ) |
|---|
| 78 | #endif |
|---|
| 79 | |
|---|
| 80 | /*****************************************************************************/ |
|---|
| 81 | |
|---|
| 82 | #define STDCPP_1998 199711L |
|---|
| 83 | |
|---|
| 84 | #if defined __cplusplus && __cplusplus && __cplusplus != 1 && __cplusplus != STDCPP_1998 |
|---|
| 85 | #pragma message( "Unanticipated value: predefined macro __cplusplus" ) |
|---|
| 86 | #endif |
|---|
| 87 | |
|---|
| 88 | /*****************************************************************************/ |
|---|
| 89 | |
|---|
| 90 | #if __STDC_VERSION__ < STDC_1999 |
|---|
| 91 | #define restrict |
|---|
| 92 | #endif |
|---|
| 93 | |
|---|
| 94 | /*****************************************************************************/ |
|---|
| 95 | /* */ |
|---|
| 96 | /* 17.9 Alternative spellings */ |
|---|
| 97 | /* */ |
|---|
| 98 | /*****************************************************************************/ |
|---|
| 99 | |
|---|
| 100 | #if (defined __cplusplus || defined __STDC_VERSION__) && !defined UNDER_CE |
|---|
| 101 | #include <iso646.h> |
|---|
| 102 | #else |
|---|
| 103 | #define and && |
|---|
| 104 | #define and_eq &= |
|---|
| 105 | #define bitand & |
|---|
| 106 | #define bitor | |
|---|
| 107 | #define compl ~ |
|---|
| 108 | #define not ! |
|---|
| 109 | #define not_eq != |
|---|
| 110 | #define or || |
|---|
| 111 | #define or_eq |= |
|---|
| 112 | #define xor ^ |
|---|
| 113 | #define xor_eq ^= |
|---|
| 114 | #endif |
|---|
| 115 | |
|---|
| 116 | /*****************************************************************************/ |
|---|
| 117 | /* */ |
|---|
| 118 | /* 17.10 Sizes of integer types <limits.h> */ |
|---|
| 119 | /* */ |
|---|
| 120 | /*****************************************************************************/ |
|---|
| 121 | |
|---|
| 122 | #include <limits.h> |
|---|
| 123 | |
|---|
| 124 | /*****************************************************************************/ |
|---|
| 125 | /* */ |
|---|
| 126 | /* 17.15 Variable arguments <stdarg.h> */ |
|---|
| 127 | /* */ |
|---|
| 128 | /*****************************************************************************/ |
|---|
| 129 | |
|---|
| 130 | #include <stdarg.h> |
|---|
| 131 | |
|---|
| 132 | /*****************************************************************************/ |
|---|
| 133 | /* */ |
|---|
| 134 | /* 17.16 Boolean type and values <stdbool.h> */ |
|---|
| 135 | /* */ |
|---|
| 136 | /*****************************************************************************/ |
|---|
| 137 | |
|---|
| 138 | #if __STDC_VERSION__ >= STDC_1999 |
|---|
| 139 | #include <stdbool.h> |
|---|
| 140 | #else |
|---|
| 141 | #if !defined __cplusplus |
|---|
| 142 | #if defined BRCM_BOOL |
|---|
| 143 | #define bool BRCM_BOOL |
|---|
| 144 | #else |
|---|
| 145 | #if defined(_MSC_VER) |
|---|
| 146 | #if _MSC_VER > 1300 |
|---|
| 147 | #define bool unsigned char |
|---|
| 148 | #else /* MSC_VER > 1300 */ |
|---|
| 149 | #define bool unsigned int |
|---|
| 150 | #endif /* _MSC_VER > 1300 */ |
|---|
| 151 | #else /* defined(_MSC_VER) */ |
|---|
| 152 | #if defined(__vxworks) && defined(__GNUC__) && (__GNUC__ >= 3) |
|---|
| 153 | #define bool unsigned char |
|---|
| 154 | #else |
|---|
| 155 | #define bool unsigned int |
|---|
| 156 | #endif |
|---|
| 157 | #endif |
|---|
| 158 | #endif |
|---|
| 159 | #define true 1 |
|---|
| 160 | #define false 0 |
|---|
| 161 | #else /* C above, C++ below */ |
|---|
| 162 | #endif |
|---|
| 163 | #define __bool_true_false_are_defined 1 |
|---|
| 164 | #endif |
|---|
| 165 | |
|---|
| 166 | /*****************************************************************************/ |
|---|
| 167 | /* */ |
|---|
| 168 | /* 17.17 Common definitions <stddef.h> */ |
|---|
| 169 | /* */ |
|---|
| 170 | /*****************************************************************************/ |
|---|
| 171 | |
|---|
| 172 | #include <stddef.h> |
|---|
| 173 | |
|---|
| 174 | /*****************************************************************************/ |
|---|
| 175 | /* */ |
|---|
| 176 | /* 17.18 Integer types <stdint.h> */ |
|---|
| 177 | /* */ |
|---|
| 178 | /*****************************************************************************/ |
|---|
| 179 | |
|---|
| 180 | #if __STDC_VERSION__ >= STDC_1999 |
|---|
| 181 | #include <stdint.h> |
|---|
| 182 | #else |
|---|
| 183 | |
|---|
| 184 | /*************************/ |
|---|
| 185 | /* 17.18.1 Integer types */ |
|---|
| 186 | /*************************/ |
|---|
| 187 | |
|---|
| 188 | #if defined __sun__ |
|---|
| 189 | #include <sys/int_types.h> |
|---|
| 190 | #else |
|---|
| 191 | |
|---|
| 192 | /* 17.18.1.1 Exact-width integer types */ |
|---|
| 193 | |
|---|
| 194 | #if defined LINUX |
|---|
| 195 | #if defined __KERNEL__ |
|---|
| 196 | #include <linux/types.h> |
|---|
| 197 | #else |
|---|
| 198 | #include <sys/types.h> |
|---|
| 199 | typedef u_int8_t uint8_t; |
|---|
| 200 | typedef u_int16_t uint16_t; |
|---|
| 201 | typedef u_int32_t uint32_t; |
|---|
| 202 | #endif |
|---|
| 203 | #elif defined VXWORKS |
|---|
| 204 | #include <types/vxTypes.h> |
|---|
| 205 | #else |
|---|
| 206 | typedef signed char int8_t; |
|---|
| 207 | typedef unsigned char uint8_t; |
|---|
| 208 | |
|---|
| 209 | typedef signed short int16_t; |
|---|
| 210 | typedef unsigned short uint16_t; |
|---|
| 211 | |
|---|
| 212 | typedef signed long int32_t; |
|---|
| 213 | typedef unsigned long uint32_t; |
|---|
| 214 | #endif |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | /* 64 bit integer types */ |
|---|
| 218 | #if defined(INT64_MAX) |
|---|
| 219 | /* 64 bit integers shall be already defined there */ |
|---|
| 220 | # elif defined(VXWORKS) |
|---|
| 221 | /* Use VxWorks version of int64_t and uint64_t */ |
|---|
| 222 | # elif defined(_MSC_VER) |
|---|
| 223 | typedef __int64 int64_t; |
|---|
| 224 | typedef unsigned __int64 uint64_t; |
|---|
| 225 | # elif defined(__GNUC__) |
|---|
| 226 | typedef long long int64_t; |
|---|
| 227 | typedef unsigned long long uint64_t; |
|---|
| 228 | # else |
|---|
| 229 | # define BSTD_INT64_NOT_DEFINED |
|---|
| 230 | #endif |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | /* 17.18.1.2 Minimun-width integer types */ |
|---|
| 234 | |
|---|
| 235 | typedef int8_t int_least8_t; |
|---|
| 236 | typedef uint8_t uint_least8_t; |
|---|
| 237 | |
|---|
| 238 | typedef int16_t int_least16_t; |
|---|
| 239 | typedef uint16_t uint_least16_t; |
|---|
| 240 | |
|---|
| 241 | typedef int32_t int_least32_t; |
|---|
| 242 | typedef uint32_t uint_least32_t; |
|---|
| 243 | |
|---|
| 244 | /* 17.18.1.3 Fastest minimum-width integer types */ |
|---|
| 245 | |
|---|
| 246 | typedef int8_t int_fast8_t; |
|---|
| 247 | typedef uint8_t uint_fast8_t; |
|---|
| 248 | |
|---|
| 249 | typedef int16_t int_fast16_t; |
|---|
| 250 | typedef uint16_t uint_fast16_t; |
|---|
| 251 | |
|---|
| 252 | typedef int32_t int_fast32_t; |
|---|
| 253 | typedef uint32_t uint_fast32_t; |
|---|
| 254 | |
|---|
| 255 | /* 7.18.1.4 Integer types capable of holding object pointers */ |
|---|
| 256 | |
|---|
| 257 | #if defined LINUX && !defined __KERNEL__ |
|---|
| 258 | #include <unistd.h> |
|---|
| 259 | #elif !defined WIN32 || _MSC_VER < 1300 |
|---|
| 260 | typedef int32_t intptr_t; |
|---|
| 261 | #endif |
|---|
| 262 | #if !defined WIN32 || _MSC_VER < 1300 |
|---|
| 263 | typedef uint32_t uintptr_t; |
|---|
| 264 | #endif |
|---|
| 265 | |
|---|
| 266 | /* 7.18.1.5 Greatest-width integer types */ |
|---|
| 267 | |
|---|
| 268 | typedef int32_t intmax_t; |
|---|
| 269 | typedef uint32_t uintmax_t; |
|---|
| 270 | |
|---|
| 271 | #endif /* __sun__ */ |
|---|
| 272 | |
|---|
| 273 | /***************************************************/ |
|---|
| 274 | /* 7.18.2 Limits of specified-width integer types */ |
|---|
| 275 | /***************************************************/ |
|---|
| 276 | |
|---|
| 277 | #if defined __sun__ |
|---|
| 278 | #include <sys/int_limits.h> |
|---|
| 279 | #else |
|---|
| 280 | |
|---|
| 281 | #if !defined __cplusplus || defined __STDC_LIMIT_MACROS /* 217 */ |
|---|
| 282 | |
|---|
| 283 | /* 7.18.2.1 Limits of exact-width integer types */ |
|---|
| 284 | |
|---|
| 285 | #define INT8_MIN (-128) |
|---|
| 286 | #define INT8_MAX ( 127) |
|---|
| 287 | #define UINT8_MAX ( 255) |
|---|
| 288 | |
|---|
| 289 | #define INT16_MIN (-32768) |
|---|
| 290 | #define INT16_MAX ( 32767) |
|---|
| 291 | #define UINT16_MAX ( 65535) |
|---|
| 292 | |
|---|
| 293 | #define INT32_MIN (-2147483648L) |
|---|
| 294 | #define INT32_MAX ( 2147483647L) |
|---|
| 295 | #define UINT32_MAX ( 4294967295UL) |
|---|
| 296 | |
|---|
| 297 | /* 7.18.2.2 Limits of minimum-width integer types */ |
|---|
| 298 | |
|---|
| 299 | #define INT_LEAST8_MIN INT8_MIN |
|---|
| 300 | #define INT_LEAST8_MAX INT8_MAX |
|---|
| 301 | #define UINT_LEAST8_MAX UINT8_MAX |
|---|
| 302 | |
|---|
| 303 | #define INT_LEAST16_MIN INT16_MIN |
|---|
| 304 | #define INT_LEAST16_MAX INT16_MAX |
|---|
| 305 | #define UINT_LEAST16_MAX UINT16_MAX |
|---|
| 306 | |
|---|
| 307 | #define INT_LEAST32_MIN INT32_MIN |
|---|
| 308 | #define INT_LEAST32_MAX INT32_MAX |
|---|
| 309 | #define UINT_LEAST32_MAX UINT32_MAX |
|---|
| 310 | |
|---|
| 311 | /* 7.18.2.3 Limits of fastest minimum-width integer types */ |
|---|
| 312 | |
|---|
| 313 | #define INT_FAST8_MIN INT8_MIN |
|---|
| 314 | #define INT_FAST8_MAX INT8_MAX |
|---|
| 315 | #define UINT_FAST8_MAX UINT8_MAX |
|---|
| 316 | |
|---|
| 317 | #define INT_FAST16_MIN INT16_MIN |
|---|
| 318 | #define INT_FAST16_MAX INT16_MAX |
|---|
| 319 | #define UINT_FAST16_MAX UINT16_MAX |
|---|
| 320 | |
|---|
| 321 | #define INT_FAST32_MIN INT32_MIN |
|---|
| 322 | #define INT_FAST32_MAX INT32_MAX |
|---|
| 323 | #define UINT_FAST32_MAX UINT32_MAX |
|---|
| 324 | |
|---|
| 325 | /* 7.18.2.4 Limits of integer types capable of holding object pointers */ |
|---|
| 326 | |
|---|
| 327 | #define INT_PTR_MIN INT32_MIN |
|---|
| 328 | #define INT_PTR_MAX INT32_MAX |
|---|
| 329 | #define UINT_PTR_MAX UINT32_MAX |
|---|
| 330 | |
|---|
| 331 | /* 7.18.2.5 Limits of greatest-width integer types */ |
|---|
| 332 | |
|---|
| 333 | #define INTMAX_MIN INT32_MIN |
|---|
| 334 | #define INTMAX_MAX INT32_MAX |
|---|
| 335 | #define UINTMAX_MAX UINT32_MAX |
|---|
| 336 | |
|---|
| 337 | #endif /* 217 */ |
|---|
| 338 | |
|---|
| 339 | #endif /* __sun__ */ |
|---|
| 340 | |
|---|
| 341 | /****************************************/ |
|---|
| 342 | /* 7.18.3 Limits of other integer types */ |
|---|
| 343 | /****************************************/ |
|---|
| 344 | |
|---|
| 345 | #if !defined __cplusplus || defined __STDC_LIMIT_MACROS /* 218 */ |
|---|
| 346 | |
|---|
| 347 | /* min signed ptrdiff_t range: -65535 .. 65535 */ |
|---|
| 348 | #define PTRDIFF_MIN INT32_MIN |
|---|
| 349 | #define PTRDIFF_MAX INT32_MAX |
|---|
| 350 | |
|---|
| 351 | /* min signed sig_atomic_t range: -127 .. 127 */ |
|---|
| 352 | /* min unsigned sig_atomic_t range: 0 .. 255 */ |
|---|
| 353 | #define SIG_ATOMIC_MIN INT32_MIN |
|---|
| 354 | #define SIG_ATOMIC_MAX INT32_MAX |
|---|
| 355 | |
|---|
| 356 | /* min unsigned size_t range: 0 .. 65535 */ |
|---|
| 357 | #if !defined __sun__ |
|---|
| 358 | #define SIZE_MAX UINT32_MIN |
|---|
| 359 | #endif /* __sun__ */ |
|---|
| 360 | |
|---|
| 361 | /* min signed wchar_t range: -127 .. 127 */ |
|---|
| 362 | /* min unsigned wchar_t range: 0 .. 255 */ |
|---|
| 363 | #define WCHAR_MIN UINT16_MIN |
|---|
| 364 | #define WCHAR_MAX UINT16_MAX |
|---|
| 365 | |
|---|
| 366 | /* min signed wint_t range: -32767 .. 32767 */ |
|---|
| 367 | /* min unsigned wint_t range: 0 .. 65535 */ |
|---|
| 368 | #define WINT_MIN UINT16_MIN |
|---|
| 369 | #define WINT_MAX UINT16_MAX |
|---|
| 370 | |
|---|
| 371 | #endif /* 218 */ |
|---|
| 372 | |
|---|
| 373 | /***************************************/ |
|---|
| 374 | /* 7.18.4 Macros for integer constants */ |
|---|
| 375 | /***************************************/ |
|---|
| 376 | |
|---|
| 377 | #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS /* 220 */ |
|---|
| 378 | |
|---|
| 379 | /* 7.18.4.1 Macros for minimum-width integer constants */ |
|---|
| 380 | |
|---|
| 381 | #define INT8_C(value) ((int_least8_t)(value)) |
|---|
| 382 | #define UINT8_C(value) ((uint_least8_t)(value)) |
|---|
| 383 | |
|---|
| 384 | #define INT16_C(value) ((int_least16_t)(value)) |
|---|
| 385 | #define UINT16_C(value) ((uint_least16_t)(value)) |
|---|
| 386 | |
|---|
| 387 | #define INT32_C(value) ((int_least32_t)(value ## L)) |
|---|
| 388 | #define UINT32_C(value) ((uint_least32_t)(value ## UL)) |
|---|
| 389 | |
|---|
| 390 | /* 7.18.4.2 Macros for greatest-width integer constants */ |
|---|
| 391 | |
|---|
| 392 | #define INTMAX_C(value) ((intmax_t)(value ## L)) |
|---|
| 393 | #define UINTMAX_C(value) ((uintmax_t)(value ## UL)) |
|---|
| 394 | |
|---|
| 395 | #endif /* 220 */ |
|---|
| 396 | |
|---|
| 397 | #endif /* !C99 */ |
|---|
| 398 | |
|---|
| 399 | /*****************************************************************************/ |
|---|
| 400 | #endif |
|---|
| 401 | #endif /* BRCM_T_H__ */ |
|---|
| 402 | |
|---|
| 403 | /* end of file */ |
|---|