OLD | NEW |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 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 | 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 | 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/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | 5 |
6 /* | 6 /* |
7 ** File: prtypes.h | 7 ** File: prtypes.h |
8 ** Description: Definitions of NSPR's basic types | 8 ** Description: Definitions of NSPR's basic types |
9 ** | 9 ** |
10 ** Prototypes and macros used to make up for deficiencies that we have found | 10 ** Prototypes and macros used to make up for deficiencies that we have found |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 /*********************************************************************** | 215 /*********************************************************************** |
216 ** MACROS: PR_ARRAY_SIZE | 216 ** MACROS: PR_ARRAY_SIZE |
217 ** DESCRIPTION: | 217 ** DESCRIPTION: |
218 ** The number of elements in an array. | 218 ** The number of elements in an array. |
219 ***********************************************************************/ | 219 ***********************************************************************/ |
220 #define PR_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) | 220 #define PR_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) |
221 | 221 |
222 PR_BEGIN_EXTERN_C | 222 PR_BEGIN_EXTERN_C |
223 | 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 |
224 /************************************************************************ | 254 /************************************************************************ |
225 ** TYPES: PRUint8 | 255 ** TYPES: PRUint8 |
226 ** PRInt8 | 256 ** PRInt8 |
227 ** DESCRIPTION: | 257 ** DESCRIPTION: |
228 ** The int8 types are known to be 8 bits each. There is no type that | 258 ** The int8 types are known to be 8 bits each. There is no type that |
229 ** is equivalent to a plain "char". | 259 ** is equivalent to a plain "char". |
230 ************************************************************************/ | 260 ************************************************************************/ |
231 #if PR_BYTES_PER_BYTE == 1 | 261 #if PR_BYTES_PER_BYTE == 1 |
232 typedef unsigned char PRUint8; | 262 typedef unsigned char PRUint8; |
233 /* | 263 /* |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 ** to be used. | 370 ** to be used. |
341 ** | 371 ** |
342 ** MACROS: PR_INT64_MAX | 372 ** MACROS: PR_INT64_MAX |
343 ** PR_INT64_MIN | 373 ** PR_INT64_MIN |
344 ** PR_UINT64_MAX | 374 ** PR_UINT64_MAX |
345 ** DESCRIPTION: | 375 ** DESCRIPTION: |
346 ** The maximum and minimum values of a PRInt64 or PRUint64. | 376 ** The maximum and minimum values of a PRInt64 or PRUint64. |
347 ************************************************************************/ | 377 ************************************************************************/ |
348 #ifdef HAVE_LONG_LONG | 378 #ifdef HAVE_LONG_LONG |
349 /* Keep this in sync with prlong.h. */ | 379 /* Keep this in sync with prlong.h. */ |
350 /* | 380 #if PR_BYTES_PER_LONG == 8 && !defined(PR_ALTERNATE_INT64_TYPEDEF) |
351 * On 64-bit Mac OS X, uint64 needs to be defined as unsigned long long to | |
352 * match uint64_t, otherwise our uint64 typedef conflicts with the uint64 | |
353 * typedef in cssmconfig.h, which CoreServices.h includes indirectly. | |
354 */ | |
355 #if PR_BYTES_PER_LONG == 8 && !defined(__APPLE__) | |
356 typedef long PRInt64; | 381 typedef long PRInt64; |
357 typedef unsigned long PRUint64; | 382 typedef unsigned long PRUint64; |
358 #define PR_INT64(x) x ## L | 383 #define PR_INT64(x) x ## L |
359 #define PR_UINT64(x) x ## UL | 384 #define PR_UINT64(x) x ## UL |
360 #elif defined(WIN32) && !defined(__GNUC__) | 385 #elif defined(WIN32) && !defined(__GNUC__) |
361 typedef __int64 PRInt64; | 386 typedef __int64 PRInt64; |
362 typedef unsigned __int64 PRUint64; | 387 typedef unsigned __int64 PRUint64; |
363 #define PR_INT64(x) x ## i64 | 388 #define PR_INT64(x) x ## i64 |
364 #define PR_UINT64(x) x ## ui64 | 389 #define PR_UINT64(x) x ## ui64 |
365 #else | 390 #else |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 ** The macro can be used only in places where an "extern" declaration is | 572 ** The macro can be used only in places where an "extern" declaration is |
548 ** allowed. | 573 ** allowed. |
549 */ | 574 */ |
550 #define PR_STATIC_ASSERT(condition) \ | 575 #define PR_STATIC_ASSERT(condition) \ |
551 extern void pr_static_assert(int arg[(condition) ? 1 : -1]) | 576 extern void pr_static_assert(int arg[(condition) ? 1 : -1]) |
552 | 577 |
553 PR_END_EXTERN_C | 578 PR_END_EXTERN_C |
554 | 579 |
555 #endif /* prtypes_h___ */ | 580 #endif /* prtypes_h___ */ |
556 | 581 |
OLD | NEW |