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