| OLD | NEW |
| (Empty) |
| 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | |
| 2 /* This Source Code Form is subject to the terms of the Mozilla Public | |
| 3 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
| 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
| 5 | |
| 6 /* | |
| 7 ** File: prtypes.h | |
| 8 ** Description: Definitions of NSPR's basic types | |
| 9 ** | |
| 10 ** Prototypes and macros used to make up for deficiencies that we have found | |
| 11 ** in ANSI environments. | |
| 12 ** | |
| 13 ** Since we do not wrap <stdlib.h> and all the other standard headers, authors | |
| 14 ** of portable code will not know in general that they need these definitions. | |
| 15 ** Instead of requiring these authors to find the dependent uses in their code | |
| 16 ** and take the following steps only in those C files, we take steps once here | |
| 17 ** for all C files. | |
| 18 **/ | |
| 19 | |
| 20 #ifndef prtypes_h___ | |
| 21 #define prtypes_h___ | |
| 22 | |
| 23 #ifdef MDCPUCFG | |
| 24 #include MDCPUCFG | |
| 25 #else | |
| 26 #include "prcpucfg.h" | |
| 27 #endif | |
| 28 | |
| 29 #include <stddef.h> | |
| 30 | |
| 31 /*********************************************************************** | |
| 32 ** MACROS: PR_EXTERN | |
| 33 ** PR_IMPLEMENT | |
| 34 ** DESCRIPTION: | |
| 35 ** These are only for externally visible routines and globals. For | |
| 36 ** internal routines, just use "extern" for type checking and that | |
| 37 ** will not export internal cross-file or forward-declared symbols. | |
| 38 ** Define a macro for declaring procedures return types. We use this to | |
| 39 ** deal with windoze specific type hackery for DLL definitions. Use | |
| 40 ** PR_EXTERN when the prototype for the method is declared. Use | |
| 41 ** PR_IMPLEMENT for the implementation of the method. | |
| 42 ** | |
| 43 ** Example: | |
| 44 ** in dowhim.h | |
| 45 ** PR_EXTERN( void ) DoWhatIMean( void ); | |
| 46 ** in dowhim.c | |
| 47 ** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; } | |
| 48 ** | |
| 49 ** | |
| 50 ***********************************************************************/ | |
| 51 #if defined(NSPR_STATIC) | |
| 52 | |
| 53 #define PR_EXPORT(__type) extern __type | |
| 54 #define PR_EXPORT_DATA(__type) extern __type | |
| 55 #define PR_IMPORT(__type) extern __type | |
| 56 #define PR_IMPORT_DATA(__type) extern __type | |
| 57 | |
| 58 #define PR_EXTERN(__type) extern __type | |
| 59 #define PR_IMPLEMENT(__type) __type | |
| 60 #define PR_EXTERN_DATA(__type) extern __type | |
| 61 #define PR_IMPLEMENT_DATA(__type) __type | |
| 62 | |
| 63 #define PR_CALLBACK | |
| 64 #define PR_CALLBACK_DECL | |
| 65 #define PR_STATIC_CALLBACK(__x) static __x | |
| 66 | |
| 67 #elif defined(WIN32) | |
| 68 | |
| 69 #define PR_EXPORT(__type) extern __declspec(dllexport) __type | |
| 70 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type | |
| 71 #define PR_IMPORT(__type) __declspec(dllimport) __type | |
| 72 #define PR_IMPORT_DATA(__type) __declspec(dllimport) __type | |
| 73 | |
| 74 #define PR_EXTERN(__type) extern __declspec(dllexport) __type | |
| 75 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type | |
| 76 #define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type | |
| 77 #define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type | |
| 78 | |
| 79 #define PR_CALLBACK | |
| 80 #define PR_CALLBACK_DECL | |
| 81 #define PR_STATIC_CALLBACK(__x) static __x | |
| 82 | |
| 83 #elif defined(XP_BEOS) | |
| 84 | |
| 85 #define PR_EXPORT(__type) extern __declspec(dllexport) __type | |
| 86 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type | |
| 87 #define PR_IMPORT(__type) extern __declspec(dllexport) __type | |
| 88 #define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type | |
| 89 | |
| 90 #define PR_EXTERN(__type) extern __declspec(dllexport) __type | |
| 91 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type | |
| 92 #define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type | |
| 93 #define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type | |
| 94 | |
| 95 #define PR_CALLBACK | |
| 96 #define PR_CALLBACK_DECL | |
| 97 #define PR_STATIC_CALLBACK(__x) static __x | |
| 98 | |
| 99 #elif defined(XP_OS2) && defined(__declspec) | |
| 100 | |
| 101 #define PR_EXPORT(__type) extern __declspec(dllexport) __type | |
| 102 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type | |
| 103 #define PR_IMPORT(__type) extern __declspec(dllimport) __type | |
| 104 #define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type | |
| 105 | |
| 106 #define PR_EXTERN(__type) extern __declspec(dllexport) __type | |
| 107 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type | |
| 108 #define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type | |
| 109 #define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type | |
| 110 | |
| 111 #define PR_CALLBACK | |
| 112 #define PR_CALLBACK_DECL | |
| 113 #define PR_STATIC_CALLBACK(__x) static __x | |
| 114 | |
| 115 #elif defined(SYMBIAN) | |
| 116 | |
| 117 #define PR_EXPORT(__type) extern __declspec(dllexport) __type | |
| 118 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type | |
| 119 #ifdef __WINS__ | |
| 120 #define PR_IMPORT(__type) extern __declspec(dllexport) __type | |
| 121 #define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type | |
| 122 #else | |
| 123 #define PR_IMPORT(__type) extern __declspec(dllimport) __type | |
| 124 #define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type | |
| 125 #endif | |
| 126 | |
| 127 #define PR_EXTERN(__type) extern __type | |
| 128 #define PR_IMPLEMENT(__type) __type | |
| 129 #define PR_EXTERN_DATA(__type) extern __type | |
| 130 #define PR_IMPLEMENT_DATA(__type) __type | |
| 131 | |
| 132 #define PR_CALLBACK | |
| 133 #define PR_CALLBACK_DECL | |
| 134 #define PR_STATIC_CALLBACK(__x) static __x | |
| 135 | |
| 136 #else /* Unix */ | |
| 137 | |
| 138 /* GCC 3.3 and later support the visibility attribute. */ | |
| 139 #if (__GNUC__ >= 4) || \ | |
| 140 (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) | |
| 141 #define PR_VISIBILITY_DEFAULT __attribute__((visibility("default"))) | |
| 142 #else | |
| 143 #define PR_VISIBILITY_DEFAULT | |
| 144 #endif | |
| 145 | |
| 146 #define PR_EXPORT(__type) extern PR_VISIBILITY_DEFAULT __type | |
| 147 #define PR_EXPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type | |
| 148 #define PR_IMPORT(__type) extern PR_VISIBILITY_DEFAULT __type | |
| 149 #define PR_IMPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type | |
| 150 | |
| 151 #define PR_EXTERN(__type) extern PR_VISIBILITY_DEFAULT __type | |
| 152 #define PR_IMPLEMENT(__type) PR_VISIBILITY_DEFAULT __type | |
| 153 #define PR_EXTERN_DATA(__type) extern PR_VISIBILITY_DEFAULT __type | |
| 154 #define PR_IMPLEMENT_DATA(__type) PR_VISIBILITY_DEFAULT __type | |
| 155 #define PR_CALLBACK | |
| 156 #define PR_CALLBACK_DECL | |
| 157 #define PR_STATIC_CALLBACK(__x) static __x | |
| 158 | |
| 159 #endif | |
| 160 | |
| 161 #if defined(_NSPR_BUILD_) | |
| 162 #define NSPR_API(__type) PR_EXPORT(__type) | |
| 163 #define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type) | |
| 164 #else | |
| 165 #define NSPR_API(__type) PR_IMPORT(__type) | |
| 166 #define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type) | |
| 167 #endif | |
| 168 | |
| 169 /*********************************************************************** | |
| 170 ** MACROS: PR_BEGIN_MACRO | |
| 171 ** PR_END_MACRO | |
| 172 ** DESCRIPTION: | |
| 173 ** Macro body brackets so that macros with compound statement definitions | |
| 174 ** behave syntactically more like functions when called. | |
| 175 ***********************************************************************/ | |
| 176 #define PR_BEGIN_MACRO do { | |
| 177 #define PR_END_MACRO } while (0) | |
| 178 | |
| 179 /*********************************************************************** | |
| 180 ** MACROS: PR_BEGIN_EXTERN_C | |
| 181 ** PR_END_EXTERN_C | |
| 182 ** DESCRIPTION: | |
| 183 ** Macro shorthands for conditional C++ extern block delimiters. | |
| 184 ***********************************************************************/ | |
| 185 #ifdef __cplusplus | |
| 186 #define PR_BEGIN_EXTERN_C extern "C" { | |
| 187 #define PR_END_EXTERN_C } | |
| 188 #else | |
| 189 #define PR_BEGIN_EXTERN_C | |
| 190 #define PR_END_EXTERN_C | |
| 191 #endif | |
| 192 | |
| 193 /*********************************************************************** | |
| 194 ** MACROS: PR_BIT | |
| 195 ** PR_BITMASK | |
| 196 ** DESCRIPTION: | |
| 197 ** Bit masking macros. XXX n must be <= 31 to be portable | |
| 198 ***********************************************************************/ | |
| 199 #define PR_BIT(n) ((PRUint32)1 << (n)) | |
| 200 #define PR_BITMASK(n) (PR_BIT(n) - 1) | |
| 201 | |
| 202 /*********************************************************************** | |
| 203 ** MACROS: PR_ROUNDUP | |
| 204 ** PR_MIN | |
| 205 ** PR_MAX | |
| 206 ** PR_ABS | |
| 207 ** DESCRIPTION: | |
| 208 ** Commonly used macros for operations on compatible types. | |
| 209 ***********************************************************************/ | |
| 210 #define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y)) | |
| 211 #define PR_MIN(x,y) ((x)<(y)?(x):(y)) | |
| 212 #define PR_MAX(x,y) ((x)>(y)?(x):(y)) | |
| 213 #define PR_ABS(x) ((x)<0?-(x):(x)) | |
| 214 | |
| 215 /*********************************************************************** | |
| 216 ** MACROS: PR_ARRAY_SIZE | |
| 217 ** DESCRIPTION: | |
| 218 ** The number of elements in an array. | |
| 219 ***********************************************************************/ | |
| 220 #define PR_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) | |
| 221 | |
| 222 PR_BEGIN_EXTERN_C | |
| 223 | |
| 224 /* | |
| 225 ** Starting in NSPR 4.9.5, NSPR's exact-width integer types should match | |
| 226 ** the exact-width integer types defined in <stdint.h>. This allows sloppy | |
| 227 ** code to use PRInt{N} and int{N}_t interchangeably. | |
| 228 ** | |
| 229 ** The 8-bit and 16-bit integer types can only be defined using char and | |
| 230 ** short. All platforms define the 32-bit integer types using int. So only | |
| 231 ** the 64-bit integer types could be defined differently. | |
| 232 ** | |
| 233 ** NSPR's original strategy was to use the "shortest" 64-bit integer type: | |
| 234 ** if long is 64-bit, then prefer it over long long. This strategy is also | |
| 235 ** used by Linux/glibc, FreeBSD, and NetBSD. | |
| 236 ** | |
| 237 ** Other platforms use a different strategy: simply define the 64-bit | |
| 238 ** integer types using long long. We define the PR_ALTERNATE_INT64_TYPEDEF | |
| 239 ** macro on these platforms. Note that PR_ALTERNATE_INT64_TYPEDEF is for | |
| 240 ** internal use by NSPR headers only. Do not define or test this macro in | |
| 241 ** your code. | |
| 242 ** | |
| 243 ** NOTE: NSPR can't use <stdint.h> because C99 requires C++ code to define | |
| 244 ** __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS to make all the macros | |
| 245 ** defined in <stdint.h> available. This strange requirement is gone in | |
| 246 ** C11. When most platforms ignore this C99 requirement, NSPR will be able | |
| 247 ** to use <stdint.h>. A patch to do that is in NSPR bug 634793. | |
| 248 */ | |
| 249 | |
| 250 #if defined(__APPLE__) || defined(__ANDROID__) || defined(__OpenBSD__) | |
| 251 #define PR_ALTERNATE_INT64_TYPEDEF | |
| 252 #endif | |
| 253 | |
| 254 /************************************************************************ | |
| 255 ** TYPES: PRUint8 | |
| 256 ** PRInt8 | |
| 257 ** DESCRIPTION: | |
| 258 ** The int8 types are known to be 8 bits each. There is no type that | |
| 259 ** is equivalent to a plain "char". | |
| 260 ************************************************************************/ | |
| 261 #if PR_BYTES_PER_BYTE == 1 | |
| 262 typedef unsigned char PRUint8; | |
| 263 /* | |
| 264 ** Some cfront-based C++ compilers do not like 'signed char' and | |
| 265 ** issue the warning message: | |
| 266 ** warning: "signed" not implemented (ignored) | |
| 267 ** For these compilers, we have to define PRInt8 as plain 'char'. | |
| 268 ** Make sure that plain 'char' is indeed signed under these compilers. | |
| 269 */ | |
| 270 #if (defined(HPUX) && defined(__cplusplus) \ | |
| 271 && !defined(__GNUC__) && __cplusplus < 199707L) \ | |
| 272 || (defined(SCO) && defined(__cplusplus) \ | |
| 273 && !defined(__GNUC__) && __cplusplus == 1L) | |
| 274 typedef char PRInt8; | |
| 275 #else | |
| 276 typedef signed char PRInt8; | |
| 277 #endif | |
| 278 #else | |
| 279 #error No suitable type for PRInt8/PRUint8 | |
| 280 #endif | |
| 281 | |
| 282 /************************************************************************ | |
| 283 * MACROS: PR_INT8_MAX | |
| 284 * PR_INT8_MIN | |
| 285 * PR_UINT8_MAX | |
| 286 * DESCRIPTION: | |
| 287 * The maximum and minimum values of a PRInt8 or PRUint8. | |
| 288 ************************************************************************/ | |
| 289 | |
| 290 #define PR_INT8_MAX 127 | |
| 291 #define PR_INT8_MIN (-128) | |
| 292 #define PR_UINT8_MAX 255U | |
| 293 | |
| 294 /************************************************************************ | |
| 295 ** TYPES: PRUint16 | |
| 296 ** PRInt16 | |
| 297 ** DESCRIPTION: | |
| 298 ** The int16 types are known to be 16 bits each. | |
| 299 ************************************************************************/ | |
| 300 #if PR_BYTES_PER_SHORT == 2 | |
| 301 typedef unsigned short PRUint16; | |
| 302 typedef short PRInt16; | |
| 303 #else | |
| 304 #error No suitable type for PRInt16/PRUint16 | |
| 305 #endif | |
| 306 | |
| 307 /************************************************************************ | |
| 308 * MACROS: PR_INT16_MAX | |
| 309 * PR_INT16_MIN | |
| 310 * PR_UINT16_MAX | |
| 311 * DESCRIPTION: | |
| 312 * The maximum and minimum values of a PRInt16 or PRUint16. | |
| 313 ************************************************************************/ | |
| 314 | |
| 315 #define PR_INT16_MAX 32767 | |
| 316 #define PR_INT16_MIN (-32768) | |
| 317 #define PR_UINT16_MAX 65535U | |
| 318 | |
| 319 /************************************************************************ | |
| 320 ** TYPES: PRUint32 | |
| 321 ** PRInt32 | |
| 322 ** DESCRIPTION: | |
| 323 ** The int32 types are known to be 32 bits each. | |
| 324 ************************************************************************/ | |
| 325 #if PR_BYTES_PER_INT == 4 | |
| 326 typedef unsigned int PRUint32; | |
| 327 typedef int PRInt32; | |
| 328 #define PR_INT32(x) x | |
| 329 #define PR_UINT32(x) x ## U | |
| 330 #elif PR_BYTES_PER_LONG == 4 | |
| 331 typedef unsigned long PRUint32; | |
| 332 typedef long PRInt32; | |
| 333 #define PR_INT32(x) x ## L | |
| 334 #define PR_UINT32(x) x ## UL | |
| 335 #else | |
| 336 #error No suitable type for PRInt32/PRUint32 | |
| 337 #endif | |
| 338 | |
| 339 /************************************************************************ | |
| 340 * MACROS: PR_INT32_MAX | |
| 341 * PR_INT32_MIN | |
| 342 * PR_UINT32_MAX | |
| 343 * DESCRIPTION: | |
| 344 * The maximum and minimum values of a PRInt32 or PRUint32. | |
| 345 ************************************************************************/ | |
| 346 | |
| 347 #define PR_INT32_MAX PR_INT32(2147483647) | |
| 348 #define PR_INT32_MIN (-PR_INT32_MAX - 1) | |
| 349 #define PR_UINT32_MAX PR_UINT32(4294967295) | |
| 350 | |
| 351 /************************************************************************ | |
| 352 ** TYPES: PRUint64 | |
| 353 ** PRInt64 | |
| 354 ** DESCRIPTION: | |
| 355 ** The int64 types are known to be 64 bits each. Care must be used when | |
| 356 ** declaring variables of type PRUint64 or PRInt64. Different hardware | |
| 357 ** architectures and even different compilers have varying support for | |
| 358 ** 64 bit values. The only guaranteed portability requires the use of | |
| 359 ** the LL_ macros (see prlong.h). | |
| 360 ** | |
| 361 ** MACROS: PR_INT64 | |
| 362 ** PR_UINT64 | |
| 363 ** DESCRIPTION: | |
| 364 ** The PR_INT64 and PR_UINT64 macros provide a portable way for | |
| 365 ** specifying 64-bit integer constants. They can only be used if | |
| 366 ** PRInt64 and PRUint64 are defined as compiler-supported 64-bit | |
| 367 ** integer types (i.e., if HAVE_LONG_LONG is defined, which is true | |
| 368 ** for all the supported compilers topday). If PRInt64 and PRUint64 | |
| 369 ** are defined as structs, the LL_INIT macro defined in prlong.h has | |
| 370 ** to be used. | |
| 371 ** | |
| 372 ** MACROS: PR_INT64_MAX | |
| 373 ** PR_INT64_MIN | |
| 374 ** PR_UINT64_MAX | |
| 375 ** DESCRIPTION: | |
| 376 ** The maximum and minimum values of a PRInt64 or PRUint64. | |
| 377 ************************************************************************/ | |
| 378 #ifdef HAVE_LONG_LONG | |
| 379 /* Keep this in sync with prlong.h. */ | |
| 380 #if PR_BYTES_PER_LONG == 8 && !defined(PR_ALTERNATE_INT64_TYPEDEF) | |
| 381 typedef long PRInt64; | |
| 382 typedef unsigned long PRUint64; | |
| 383 #define PR_INT64(x) x ## L | |
| 384 #define PR_UINT64(x) x ## UL | |
| 385 #elif defined(WIN32) && !defined(__GNUC__) | |
| 386 typedef __int64 PRInt64; | |
| 387 typedef unsigned __int64 PRUint64; | |
| 388 #define PR_INT64(x) x ## i64 | |
| 389 #define PR_UINT64(x) x ## ui64 | |
| 390 #else | |
| 391 typedef long long PRInt64; | |
| 392 typedef unsigned long long PRUint64; | |
| 393 #define PR_INT64(x) x ## LL | |
| 394 #define PR_UINT64(x) x ## ULL | |
| 395 #endif /* PR_BYTES_PER_LONG == 8 */ | |
| 396 | |
| 397 #define PR_INT64_MAX PR_INT64(0x7fffffffffffffff) | |
| 398 #define PR_INT64_MIN (-PR_INT64_MAX - 1) | |
| 399 #define PR_UINT64_MAX PR_UINT64(-1) | |
| 400 #else /* !HAVE_LONG_LONG */ | |
| 401 typedef struct { | |
| 402 #ifdef IS_LITTLE_ENDIAN | |
| 403 PRUint32 lo, hi; | |
| 404 #else | |
| 405 PRUint32 hi, lo; | |
| 406 #endif | |
| 407 } PRInt64; | |
| 408 typedef PRInt64 PRUint64; | |
| 409 | |
| 410 #define PR_INT64_MAX (PRInt64){0x7fffffff, 0xffffffff} | |
| 411 #define PR_INT64_MIN (PRInt64){0xffffffff, 0xffffffff} | |
| 412 #define PR_UINT64_MAX (PRUint64){0xffffffff, 0xffffffff} | |
| 413 | |
| 414 #endif /* !HAVE_LONG_LONG */ | |
| 415 | |
| 416 /************************************************************************ | |
| 417 ** TYPES: PRUintn | |
| 418 ** PRIntn | |
| 419 ** DESCRIPTION: | |
| 420 ** The PRIntn types are most appropriate for automatic variables. They are | |
| 421 ** guaranteed to be at least 16 bits, though various architectures may | |
| 422 ** define them to be wider (e.g., 32 or even 64 bits). These types are | |
| 423 ** never valid for fields of a structure. | |
| 424 ************************************************************************/ | |
| 425 #if PR_BYTES_PER_INT >= 2 | |
| 426 typedef int PRIntn; | |
| 427 typedef unsigned int PRUintn; | |
| 428 #else | |
| 429 #error 'sizeof(int)' not sufficient for platform use | |
| 430 #endif | |
| 431 | |
| 432 /************************************************************************ | |
| 433 ** TYPES: PRFloat64 | |
| 434 ** DESCRIPTION: | |
| 435 ** NSPR's floating point type is always 64 bits. | |
| 436 ************************************************************************/ | |
| 437 typedef double PRFloat64; | |
| 438 | |
| 439 /************************************************************************ | |
| 440 ** TYPES: PRSize | |
| 441 ** DESCRIPTION: | |
| 442 ** A type for representing the size of objects. | |
| 443 ************************************************************************/ | |
| 444 typedef size_t PRSize; | |
| 445 | |
| 446 | |
| 447 /************************************************************************ | |
| 448 ** TYPES: PROffset32, PROffset64 | |
| 449 ** DESCRIPTION: | |
| 450 ** A type for representing byte offsets from some location. | |
| 451 ************************************************************************/ | |
| 452 typedef PRInt32 PROffset32; | |
| 453 typedef PRInt64 PROffset64; | |
| 454 | |
| 455 /************************************************************************ | |
| 456 ** TYPES: PRPtrDiff | |
| 457 ** DESCRIPTION: | |
| 458 ** A type for pointer difference. Variables of this type are suitable | |
| 459 ** for storing a pointer or pointer subtraction. | |
| 460 ************************************************************************/ | |
| 461 typedef ptrdiff_t PRPtrdiff; | |
| 462 | |
| 463 /************************************************************************ | |
| 464 ** TYPES: PRUptrdiff | |
| 465 ** DESCRIPTION: | |
| 466 ** A type for pointer difference. Variables of this type are suitable | |
| 467 ** for storing a pointer or pointer sutraction. | |
| 468 ************************************************************************/ | |
| 469 #ifdef _WIN64 | |
| 470 typedef PRUint64 PRUptrdiff; | |
| 471 #else | |
| 472 typedef unsigned long PRUptrdiff; | |
| 473 #endif | |
| 474 | |
| 475 /************************************************************************ | |
| 476 ** TYPES: PRBool | |
| 477 ** DESCRIPTION: | |
| 478 ** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE | |
| 479 ** for clarity of target type in assignments and actual arguments. Use | |
| 480 ** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans | |
| 481 ** just as you would C int-valued conditions. | |
| 482 ************************************************************************/ | |
| 483 typedef PRIntn PRBool; | |
| 484 #define PR_TRUE 1 | |
| 485 #define PR_FALSE 0 | |
| 486 | |
| 487 /************************************************************************ | |
| 488 ** TYPES: PRPackedBool | |
| 489 ** DESCRIPTION: | |
| 490 ** Use PRPackedBool within structs where bitfields are not desirable | |
| 491 ** but minimum and consistant overhead matters. | |
| 492 ************************************************************************/ | |
| 493 typedef PRUint8 PRPackedBool; | |
| 494 | |
| 495 /* | |
| 496 ** Status code used by some routines that have a single point of failure or | |
| 497 ** special status return. | |
| 498 */ | |
| 499 typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus; | |
| 500 | |
| 501 #ifndef __PRUNICHAR__ | |
| 502 #define __PRUNICHAR__ | |
| 503 #ifdef WIN32 | |
| 504 typedef wchar_t PRUnichar; | |
| 505 #else | |
| 506 typedef PRUint16 PRUnichar; | |
| 507 #endif | |
| 508 #endif | |
| 509 | |
| 510 /* | |
| 511 ** WARNING: The undocumented data types PRWord and PRUword are | |
| 512 ** only used in the garbage collection and arena code. Do not | |
| 513 ** use PRWord and PRUword in new code. | |
| 514 ** | |
| 515 ** A PRWord is an integer that is the same size as a void*. | |
| 516 ** It implements the notion of a "word" in the Java Virtual | |
| 517 ** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine | |
| 518 ** Specification, Addison-Wesley, September 1996. | |
| 519 ** http://java.sun.com/docs/books/vmspec/index.html.) | |
| 520 */ | |
| 521 #ifdef _WIN64 | |
| 522 typedef PRInt64 PRWord; | |
| 523 typedef PRUint64 PRUword; | |
| 524 #else | |
| 525 typedef long PRWord; | |
| 526 typedef unsigned long PRUword; | |
| 527 #endif | |
| 528 | |
| 529 /* | |
| 530 * PR_PRETEND_NORETURN, specified at the end of a function declaration, | |
| 531 * indicates that for the purposes of static analysis, this function does not | |
| 532 * return. (The function definition does not need to be annotated.) | |
| 533 * | |
| 534 * void PR_Assert(const char *s, const char *file, PRIntn ln) | |
| 535 * PR_PRETEND_NORETURN; | |
| 536 * | |
| 537 * Some static analyzers, like scan-build from clang, can use this information | |
| 538 * to eliminate false positives. From the upstream documentation of | |
| 539 * scan-build: | |
| 540 * This attribute is useful for annotating assertion handlers that actually | |
| 541 * can return, but for the purpose of using the analyzer we want to pretend | |
| 542 * that such functions do not return. | |
| 543 */ | |
| 544 #ifdef __clang_analyzer__ | |
| 545 #if __has_extension(attribute_analyzer_noreturn) | |
| 546 #define PR_PRETEND_NORETURN __attribute__((analyzer_noreturn)) | |
| 547 #endif | |
| 548 #endif | |
| 549 | |
| 550 #ifndef PR_PRETEND_NORETURN | |
| 551 #define PR_PRETEND_NORETURN /* no support */ | |
| 552 #endif | |
| 553 | |
| 554 #if defined(NO_NSPR_10_SUPPORT) | |
| 555 #else | |
| 556 /********* ???????????????? FIX ME ??????????????????????????? *****/ | |
| 557 /********************** Some old definitions until pr=>ds transition is done ***
/ | |
| 558 /********************** Also, we are still using NSPR 1.0. GC ******************
/ | |
| 559 /* | |
| 560 ** Fundamental NSPR macros, used nearly everywhere. | |
| 561 */ | |
| 562 | |
| 563 #define PR_PUBLIC_API PR_IMPLEMENT | |
| 564 | |
| 565 /* | |
| 566 ** Macro body brackets so that macros with compound statement definitions | |
| 567 ** behave syntactically more like functions when called. | |
| 568 */ | |
| 569 #define NSPR_BEGIN_MACRO do { | |
| 570 #define NSPR_END_MACRO } while (0) | |
| 571 | |
| 572 /* | |
| 573 ** Macro shorthands for conditional C++ extern block delimiters. | |
| 574 */ | |
| 575 #ifdef NSPR_BEGIN_EXTERN_C | |
| 576 #undef NSPR_BEGIN_EXTERN_C | |
| 577 #endif | |
| 578 #ifdef NSPR_END_EXTERN_C | |
| 579 #undef NSPR_END_EXTERN_C | |
| 580 #endif | |
| 581 | |
| 582 #ifdef __cplusplus | |
| 583 #define NSPR_BEGIN_EXTERN_C extern "C" { | |
| 584 #define NSPR_END_EXTERN_C } | |
| 585 #else | |
| 586 #define NSPR_BEGIN_EXTERN_C | |
| 587 #define NSPR_END_EXTERN_C | |
| 588 #endif | |
| 589 | |
| 590 #include "obsolete/protypes.h" | |
| 591 | |
| 592 /********* ????????????? End Fix me ?????????????????????????????? *****/ | |
| 593 #endif /* NO_NSPR_10_SUPPORT */ | |
| 594 | |
| 595 /* | |
| 596 ** Compile-time assert. "condition" must be a constant expression. | |
| 597 ** The macro can be used only in places where an "extern" declaration is | |
| 598 ** allowed. | |
| 599 */ | |
| 600 #define PR_STATIC_ASSERT(condition) \ | |
| 601 extern void pr_static_assert(int arg[(condition) ? 1 : -1]) | |
| 602 | |
| 603 PR_END_EXTERN_C | |
| 604 | |
| 605 #endif /* prtypes_h___ */ | |
| 606 | |
| OLD | NEW |