summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%google.com <devnull@localhost>2012-12-07 21:13:41 +0000
committerwtc%google.com <devnull@localhost>2012-12-07 21:13:41 +0000
commit1435cde9ca7ec9fabc001671ee0abb512ffa1e5d (patch)
treea33f91dc6ed50872367999b57f37122a2d3a7de0
parent5208113a435393acacafc2314a908bf8c782207c (diff)
downloadnspr-hg-1435cde9ca7ec9fabc001671ee0abb512ffa1e5d.tar.gz
Bug 634793: Add OpenBSD and Android to the list of exceptions to how NSPRNSPR_4_9_5_BETA1
normally defines PRInt64 and PRUint64. From now on, NSPR's exact-width integer types will match the exact-width integer types defined in <stdint.h>. r=ehsan. Modified Files: prdepend.h prlong.h prtypes.h
-rw-r--r--config/prdepend.h1
-rw-r--r--pr/include/prlong.h2
-rw-r--r--pr/include/prtypes.h37
3 files changed, 33 insertions, 7 deletions
diff --git a/config/prdepend.h b/config/prdepend.h
index e49e9267..6c66b37c 100644
--- a/config/prdepend.h
+++ b/config/prdepend.h
@@ -10,3 +10,4 @@
*/
#error "Do not include this header file."
+
diff --git a/pr/include/prlong.h b/pr/include/prlong.h
index 23bd3a9a..df1f30b0 100644
--- a/pr/include/prlong.h
+++ b/pr/include/prlong.h
@@ -35,7 +35,7 @@ NSPR_API(PRUint64) LL_MaxUint(void);
#if defined(HAVE_LONG_LONG)
/* Keep this in sync with prtypes.h. */
-#if PR_BYTES_PER_LONG == 8 && !defined(__APPLE__)
+#if PR_BYTES_PER_LONG == 8 && !defined(PR_ALTERNATE_INT64_TYPEDEF)
#define LL_MAXINT 9223372036854775807L
#define LL_MININT (-LL_MAXINT - 1L)
#define LL_ZERO 0L
diff --git a/pr/include/prtypes.h b/pr/include/prtypes.h
index 56fa039c..a5069bb7 100644
--- a/pr/include/prtypes.h
+++ b/pr/include/prtypes.h
@@ -205,6 +205,36 @@
PR_BEGIN_EXTERN_C
+/*
+** Starting in NSPR 4.9.5, NSPR's exact-width integer types should match
+** the exact-width integer types defined in <stdint.h>. This allows sloppy
+** code to use PRInt{N} and int{N}_t interchangeably.
+**
+** The 8-bit and 16-bit integer types can only be defined using char and
+** short. All platforms define the 32-bit integer types using int. So only
+** the 64-bit integer types could be defined differently.
+**
+** NSPR's original strategy was to use the "shortest" 64-bit integer type:
+** if long is 64-bit, then prefer it over long long. This strategy is also
+** used by Linux/glibc, FreeBSD, and NetBSD.
+**
+** Other platforms use a different strategy: simply define the 64-bit
+** integer types using long long. We define the PR_ALTERNATE_INT64_TYPEDEF
+** macro on these platforms. Note that PR_ALTERNATE_INT64_TYPEDEF is for
+** internal use by NSPR headers only. Do not define or test this macro in
+** your code.
+**
+** NOTE: NSPR can't use <stdint.h> because C99 requires C++ code to define
+** __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS to make all the macros
+** defined in <stdint.h> available. This strange requirement is gone in
+** C11. When most platforms ignore this C99 requirement, NSPR will be able
+** to use <stdint.h>. A patch to do that is in NSPR bug 634793.
+*/
+
+#if defined(__APPLE__) || defined(__ANDROID__) || defined(__OpenBSD__)
+#define PR_ALTERNATE_INT64_TYPEDEF
+#endif
+
/************************************************************************
** TYPES: PRUint8
** PRInt8
@@ -331,12 +361,7 @@ typedef long PRInt32;
************************************************************************/
#ifdef HAVE_LONG_LONG
/* Keep this in sync with prlong.h. */
-/*
- * On 64-bit Mac OS X, uint64 needs to be defined as unsigned long long to
- * match uint64_t, otherwise our uint64 typedef conflicts with the uint64
- * typedef in cssmconfig.h, which CoreServices.h includes indirectly.
- */
-#if PR_BYTES_PER_LONG == 8 && !defined(__APPLE__)
+#if PR_BYTES_PER_LONG == 8 && !defined(PR_ALTERNATE_INT64_TYPEDEF)
typedef long PRInt64;
typedef unsigned long PRUint64;
#define PR_INT64(x) x ## L