Bug 634793: update NSPR to NSPR_4_9_5_BETA1 and add the TestPRIntN.cpp
authorWan-Teh Chang <wtc@google.com>
Fri, 14 Dec 2012 09:01:25 -0800
changeset 116075 3173175efff1a391e065f81ed4de36f896bca592
parent 116074 15e83fa7017265eadfce80b140385436df5f11e8
child 116076 1c74122a6fcfeb556a1cebe979b74b9f85dddef6
push id24043
push userryanvm@gmail.com
push dateSat, 15 Dec 2012 21:18:16 +0000
treeherdermozilla-central@c8a1314aa449 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs634793
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 634793: update NSPR to NSPR_4_9_5_BETA1 and add the TestPRIntN.cpp test to verify PRInt{N} matches int{N}_t. r=ehsan,jlebar.
nsprpub/TAG-INFO
nsprpub/admin/repackage.sh
nsprpub/config/prdepend.h
nsprpub/configure
nsprpub/configure.in
nsprpub/pr/include/prinit.h
nsprpub/pr/include/prlong.h
nsprpub/pr/include/prtypes.h
nsprpub/pr/tests/vercheck.c
xpcom/tests/Makefile.in
xpcom/tests/TestPRIntN.cpp
--- a/nsprpub/TAG-INFO
+++ b/nsprpub/TAG-INFO
@@ -1,1 +1,1 @@
-NSPR_4_9_4_RTM
+NSPR_4_9_5_BETA1
deleted file mode 100755
--- a/nsprpub/admin/repackage.sh
+++ /dev/null
@@ -1,179 +0,0 @@
-#! /bin/sh
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# ------------------------------------------------------------------
-# repackage.sh -- Repackage NSPR from /s/b/c to mozilla.org format
-#
-# syntax: repackage.sh
-#
-# Description:
-# repackage.sh creates NSPR binary distributions for mozilla.org from
-# the internal binary distributions in /share/builds/components/nspr20.
-# There are reasons why we can't just push the internal binary distributions
-# to mozilla.org. External developers prefer to use the common archive 
-# file format for their platforms, rather than the jar files we use internally.
-#
-# On Unix, we create a tar.gz file.  On Windows, we create a zip file.
-# For example: NSPR 4.1.1, these would be nspr-4.1.1.tar.gz and nspr-4.1.1.zip.
-#
-# When unpacked, nspr-4.1.1.tar.gz or nspr-4.1.1.zip should expand to a
-# nspr-4.1.1 directory that contains three subdirectories: include, lib,
-# and bin.  The header files, with the correct line endings for the
-# platform, are in nspr-4.1.1/include.  The libraries are in nspr-4.1.1/lib.
-# The executable programs are in nspr-4.1.1/bin.
-# 
-# Note! Files written with Gnu tar are not readable by some non-Gnu
-# versions. Sun, in particular.
-# 
-# 
-# 
-# 
-# ------------------------------------------------------------------
-
-FROMTOP=/share/builds/components/nspr20/v4.9.4
-TOTOP=./v4.9.4
-NSPRDIR=nspr-4.9.4
-SOURCETAG=NSPR_4_9_4_RTM
-
-#
-# enumerate Unix object directories on /s/b/c
-UNIX_OBJDIRS="
-HP-UXB.11.11_64_DBG.OBJ
-HP-UXB.11.11_64_OPT.OBJ
-HP-UXB.11.11_DBG.OBJ
-HP-UXB.11.11_OPT.OBJ
-HP-UXB.11.23_ia64_32_DBG.OBJ
-HP-UXB.11.23_ia64_32_OPT.OBJ
-HP-UXB.11.23_ia64_64_DBG.OBJ
-HP-UXB.11.23_ia64_64_OPT.OBJ
-Linux2.4_x86_glibc_PTH_DBG.OBJ
-Linux2.4_x86_glibc_PTH_OPT.OBJ
-Linux2.6_x86_64_glibc_PTH_DBG.OBJ
-Linux2.6_x86_64_glibc_PTH_OPT.OBJ
-Linux2.6_x86_glibc_PTH_DBG.OBJ
-Linux2.6_x86_glibc_PTH_OPT.OBJ
-SunOS5.9_64_DBG.OBJ
-SunOS5.9_64_OPT.OBJ
-SunOS5.9_DBG.OBJ
-SunOS5.9_OPT.OBJ
-"
-#
-# enumerate Windows object directories on /s/b/c
-WIN_OBJDIRS="
-WIN954.0_DBG.OBJ
-WIN954.0_DBG.OBJD
-WIN954.0_OPT.OBJ
-WINNT5.0_DBG.OBJ
-WINNT5.0_DBG.OBJD
-WINNT5.0_OPT.OBJ
-"
-
-#
-# Create the destination directory.
-#
-echo "removing directory $TOTOP"
-rm -rf $TOTOP
-echo "creating directory $TOTOP"
-mkdir -p $TOTOP
-
-#
-# Generate the tar.gz files for Unix platforms.
-#
-for OBJDIR in $UNIX_OBJDIRS; do
-    echo "removing directory $NSPRDIR"
-    rm -rf $NSPRDIR
-    echo "creating directory $NSPRDIR"
-    mkdir $NSPRDIR
-
-    echo "creating directory $NSPRDIR/include"
-    mkdir $NSPRDIR/include
-    echo "copying $FROMTOP/$OBJDIR/include"
-    cp -r $FROMTOP/$OBJDIR/include $NSPRDIR
-
-    echo "copying $FROMTOP/$OBJDIR/lib"
-    cp -r $FROMTOP/$OBJDIR/lib $NSPRDIR
-
-    echo "copying $FROMTOP/$OBJDIR/bin"
-    cp -r $FROMTOP/$OBJDIR/bin $NSPRDIR
-
-    echo "creating directory $TOTOP/$OBJDIR"
-    mkdir $TOTOP/$OBJDIR
-    echo "creating $TOTOP/$OBJDIR/$NSPRDIR.tar"
-    tar cvf $TOTOP/$OBJDIR/$NSPRDIR.tar $NSPRDIR
-    echo "gzipping $TOTOP/$OBJDIR/$NSPRDIR.tar"
-    gzip $TOTOP/$OBJDIR/$NSPRDIR.tar
-done
-
-#
-# Generate the zip files for Windows platforms.
-#
-for OBJDIR in $WIN_OBJDIRS; do
-    echo "removing directory $NSPRDIR"
-    rm -rf $NSPRDIR
-    echo "creating directory $NSPRDIR"
-    mkdir $NSPRDIR
-
-    echo "creating directory $NSPRDIR/include"
-    mkdir $NSPRDIR/include
-    echo "creating directory $NSPRDIR/include/private"
-    mkdir $NSPRDIR/include/private
-    echo "creating directory $NSPRDIR/include/obsolete"
-    mkdir $NSPRDIR/include/obsolete
-
-    # copy headers and adjust unix line-end to Windows line-end
-    # Note: Watch out for the "sed" command line.
-    # when editing the command, take care to preserve the "^M" as the literal
-    # cntl-M character! in vi, use "cntl-v cntl-m" to enter it!
-    #
-    headers=`ls $FROMTOP/$OBJDIR/include/*.h`
-    for header in $headers; do
-        sed -e 's/$/
/g' $header > $NSPRDIR/include/`basename $header`
-    done
-    headers=`ls $FROMTOP/$OBJDIR/include/obsolete/*.h`
-    for header in $headers; do
-        sed -e 's/$/
/g' $header > $NSPRDIR/include/obsolete/`basename $header`
-    done
-    headers=`ls $FROMTOP/$OBJDIR/include/private/*.h`
-    for header in $headers; do
-        sed -e 's/$/
/g' $header > $NSPRDIR/include/private/`basename $header`
-    done
-
-    echo "copying $FROMTOP/$OBJDIR/lib"
-    cp -r $FROMTOP/$OBJDIR/lib $NSPRDIR
-
-    echo "copying $FROMTOP/$OBJDIR/bin"
-    cp -r $FROMTOP/$OBJDIR/bin $NSPRDIR
-
-    echo "creating directory $TOTOP/$OBJDIR"
-    mkdir -p $TOTOP/$OBJDIR
-    echo "creating $TOTOP/$OBJDIR/$NSPRDIR.zip"
-    zip -r $TOTOP/$OBJDIR/$NSPRDIR.zip $NSPRDIR
-done
-
-#
-# package the source from CVS
-#
-echo "Packaging source"
-echo "removing directory $NSPRDIR"
-rm -rf $NSPRDIR
-echo "creating directory $NSPRDIR"
-mkdir $NSPRDIR
-myWD=`pwd`
-cd $NSPRDIR
-echo "Pulling source from CVS with tag $SOURCETAG"
-cvs co -r $SOURCETAG mozilla/nsprpub
-cd $myWD
-mkdir $TOTOP/src
-echo "Creating source tar file: $TOTOP/src/$NSPRDIR.tar"
-tar cvf $TOTOP/src/$NSPRDIR.tar $NSPRDIR
-echo "gzip $TOTOP/src/$NSPRDIR.tar"
-gzip $TOTOP/src/$NSPRDIR.tar
-
-#
-# Remove the working directory.
-#
-echo "removing directory $NSPRDIR"
-rm -rf $NSPRDIR
-# --- end repackage.sh ---------------------------------------------
--- a/nsprpub/config/prdepend.h
+++ b/nsprpub/config/prdepend.h
@@ -5,8 +5,9 @@
 
 /*
  * A dummy header file that is a dependency for all the object files.
  * Used to force a full recompilation of NSPR in Mozilla's Tinderbox
  * depend builds.  See comments in rules.mk.
  */
 
 #error "Do not include this header file."
+
--- a/nsprpub/configure
+++ b/nsprpub/configure
@@ -731,17 +731,17 @@ echo "$ac_t""$build" 1>&6
 test "$host_alias" != "$target_alias" &&
   test "$program_prefix$program_suffix$program_transform_name" = \
     NONENONEs,x,x, &&
   program_prefix=${target_alias}-
 
 
 MOD_MAJOR_VERSION=4
 MOD_MINOR_VERSION=9
-MOD_PATCH_VERSION=4
+MOD_PATCH_VERSION=5
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_64=
 USE_CPLUS=
@@ -6577,17 +6577,17 @@ trap 'rm -f $CONFIG_STATUS conftest*; ex
 # Protect against Makefile macro expansion.
 cat > conftest.defs <<\EOF
 s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
 s%[ 	`~#$^&*(){}\\|;'"<>?]%\\&%g
 s%\[%\\&%g
 s%\]%\\&%g
 s%\$%$$%g
 EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' ' | tr '\015' ' '` # Manually modified for MKS support.
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
 rm -f conftest.defs
 
 
 # Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
 
 echo creating $CONFIG_STATUS
 rm -f $CONFIG_STATUS
--- a/nsprpub/configure.in
+++ b/nsprpub/configure.in
@@ -10,17 +10,17 @@ AC_INIT(config/libc_r.h)
 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
 AC_CANONICAL_SYSTEM
 
 dnl ========================================================
 dnl = Defaults
 dnl ========================================================
 MOD_MAJOR_VERSION=4
 MOD_MINOR_VERSION=9
-MOD_PATCH_VERSION=4
+MOD_PATCH_VERSION=5
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_64=
 USE_CPLUS=
--- a/nsprpub/pr/include/prinit.h
+++ b/nsprpub/pr/include/prinit.h
@@ -26,21 +26,21 @@ PR_BEGIN_EXTERN_C
 /*
 ** NSPR's version is used to determine the likelihood that the version you
 ** used to build your component is anywhere close to being compatible with
 ** what is in the underlying library.
 **
 ** The format of the version string is
 **     "<major version>.<minor version>[.<patch level>] [<Beta>]"
 */
-#define PR_VERSION  "4.9.4"
+#define PR_VERSION  "4.9.5 Beta"
 #define PR_VMAJOR   4
 #define PR_VMINOR   9
-#define PR_VPATCH   4
-#define PR_BETA     PR_FALSE
+#define PR_VPATCH   5
+#define PR_BETA     PR_TRUE
 
 /*
 ** PRVersionCheck
 **
 ** The basic signature of the function that is called to provide version
 ** checking. The result will be a boolean that indicates the likelihood
 ** that the underling library will perform as the caller expects.
 **
--- a/nsprpub/pr/include/prlong.h
+++ b/nsprpub/pr/include/prlong.h
@@ -30,17 +30,17 @@ PR_BEGIN_EXTERN_C
 NSPR_API(PRInt64) LL_MaxInt(void);
 NSPR_API(PRInt64) LL_MinInt(void);
 NSPR_API(PRInt64) LL_Zero(void);
 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
 #define LL_MAXUINT  18446744073709551615UL
 #define LL_INIT(hi, lo)  ((hi ## L << 32) + lo ## L)
 #elif defined(WIN32) && !defined(__GNUC__)
 #define LL_MAXINT   9223372036854775807i64
 #define LL_MININT   (-LL_MAXINT - 1i64)
--- a/nsprpub/pr/include/prtypes.h
+++ b/nsprpub/pr/include/prtypes.h
@@ -200,16 +200,46 @@
 ** MACROS:      PR_ARRAY_SIZE
 ** DESCRIPTION:
 **  The number of elements in an array.
 ***********************************************************************/
 #define PR_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
 
 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
 ** DESCRIPTION:
 **  The int8 types are known to be 8 bits each. There is no type that
 **      is equivalent to a plain "char".
 ************************************************************************/
 #if PR_BYTES_PER_BYTE == 1
@@ -326,22 +356,17 @@ typedef long PRInt32;
 ** MACROS:      PR_INT64_MAX
 **              PR_INT64_MIN
 **              PR_UINT64_MAX
 ** DESCRIPTION:
 **  The maximum and minimum values of a PRInt64 or PRUint64.
 ************************************************************************/
 #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
 #define PR_UINT64(x) x ## UL
 #elif defined(WIN32) && !defined(__GNUC__)
 typedef __int64  PRInt64;
 typedef unsigned __int64 PRUint64;
 #define PR_INT64(x)  x ## i64
--- a/nsprpub/pr/tests/vercheck.c
+++ b/nsprpub/pr/tests/vercheck.c
@@ -15,47 +15,47 @@
  */
 
 #include "prinit.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 
 /*
- * This release (4.9.4) is backward compatible with the
+ * This release (4.9.5) is backward compatible with the
  * 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, 4.5.x, 4.6.x, 4.7.x,
- * 4.8.x, 4.9, 4.9.1, 4.9.2, and 4.9.3 releases.  It, of course,
- * is compatible with itself.
+ * 4.8.x, 4.9, 4.9.1, 4.9.2, 4.9.3, and 4.9.4 releases.
+ * It, of course, is compatible with itself.
  */
 static char *compatible_version[] = {
     "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3",
     "4.2", "4.2.1", "4.2.2", "4.3", "4.4", "4.4.1",
     "4.5", "4.5.1",
     "4.6", "4.6.1", "4.6.2", "4.6.3", "4.6.4", "4.6.5",
     "4.6.6", "4.6.7", "4.6.8",
     "4.7", "4.7.1", "4.7.2", "4.7.3", "4.7.4", "4.7.5",
     "4.7.6",
     "4.8", "4.8.1", "4.8.2", "4.8.3", "4.8.4", "4.8.5",
     "4.8.6", "4.8.7", "4.8.8", "4.8.9",
-    "4.9", "4.9.1", "4.9.2", "4.9.3", PR_VERSION
+    "4.9", "4.9.1", "4.9.2", "4.9.3", "4.9.4", PR_VERSION
 };
 
 /*
  * This release is not backward compatible with the old
  * NSPR 2.1 and 3.x releases.
  *
  * Any release is incompatible with future releases and
  * patches.
  */
 static char *incompatible_version[] = {
     "2.1 19980529",
     "3.0", "3.0.1",
     "3.1", "3.1.1", "3.1.2", "3.1.3",
     "3.5", "3.5.1",
-    "4.9.5",
+    "4.9.6",
     "4.10", "4.10.1",
     "10.0", "11.1", "12.14.20"
 };
 
 int main(int argc, char **argv)
 {
     int idx;
     int num_compatible = sizeof(compatible_version) / sizeof(char *);
--- a/xpcom/tests/Makefile.in
+++ b/xpcom/tests/Makefile.in
@@ -30,16 +30,17 @@ DIRS += static-checker
 endif
 
 VPATH += $(topsrcdir)/build
 
 CPPSRCS = \
   nsIFileEnumerator.cpp \
   TestCallTemplates.cpp \
   TestINIParser.cpp \
+  TestPRIntN.cpp \
   TestRacingServiceManager.cpp \
   TestRegistrationOrder.cpp \
   TestThreadPoolListener.cpp \
   TestTimers.cpp \
   TestBlockingProcess.cpp \
   TestQuickReturn.cpp \
   TestArguments.cpp \
   TestUnicodeArguments.cpp \
new file mode 100644
--- /dev/null
+++ b/xpcom/tests/TestPRIntN.cpp
@@ -0,0 +1,34 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/StandardInteger.h"
+ 
+#include "prtypes.h"
+
+// This test is NOT intended to be run.  It's a test to make sure
+// PRInt{N} matches int{N}_t. If they don't match, we should get a
+// compiler warning or error in main().
+
+static void
+ClearNSPRIntTypes(PRInt8 *a, PRInt16 *b, PRInt32 *c, PRInt64 *d)
+{
+  *a = 0; *b = 0; *c = 0; *d = 0;
+}
+
+static void
+ClearStdIntTypes(int8_t *w, int16_t *x, int32_t *y, int64_t *z)
+{
+  *w = 0; *x = 0; *y = 0; *z = 0;
+}
+
+int
+main()
+{
+  PRInt8 a; PRInt16 b; PRInt32 c; PRInt64 d;
+  int8_t w; int16_t x; int32_t y; int64_t z;
+
+  ClearNSPRIntTypes(&w, &x, &y, &z);
+  ClearStdIntTypes(&a, &b, &c, &d);
+  return 0;
+}