Bug 673382: Update NSPR to NSPR_4_8_9_BETA4, which includes the fixes for
authorWan-Teh Chang <wtc@google.com>
Thu, 28 Jul 2011 07:17:57 -0700
changeset 73818 ec7ad3a1de609ecb1f252660ecf3c5790e9bdb79
parent 73817 425d3bbf99e6e31d19bb852207d02cc79c779dc2
child 73819 7bc488fc53a3c20fdee16a0903ceec6da19f0685
push id313
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 19:58:41 +0000
treeherdermozilla-aurora@ef9d1c90dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs673382, 665978, 655058, 645459, 661596, 673223, 673224, 654436, 663970
milestone8.0a1
Bug 673382: Update NSPR to NSPR_4_8_9_BETA4, which includes the fixes for Bug 665978, Bug 655058, Bug 645459, Bug 661596, Bug 673223, Bug 673224, Bug 654436, Bug 663970.
nsprpub/TAG-INFO
nsprpub/config/prdepend.h
nsprpub/config/rules.mk
nsprpub/configure
nsprpub/configure.in
nsprpub/pr/include/pratom.h
nsprpub/pr/include/prinit.h
nsprpub/pr/include/prtime.h
nsprpub/pr/include/prtypes.h
nsprpub/pr/src/misc/prinit.c
nsprpub/pr/src/misc/prsystem.c
nsprpub/pr/src/nspr.def
nsprpub/pr/tests/sprintf.c
--- a/nsprpub/TAG-INFO
+++ b/nsprpub/TAG-INFO
@@ -1,1 +1,1 @@
-NSPR_4_8_9_BETA3
+NSPR_4_8_9_BETA4
--- a/nsprpub/config/prdepend.h
+++ b/nsprpub/config/prdepend.h
@@ -37,9 +37,8 @@
 
 /*
  * 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/config/rules.mk
+++ b/nsprpub/config/rules.mk
@@ -373,16 +373,24 @@ ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
 
 $(PROGRAM): pgo.relink
 
 endif	# WINNT && !GCC
 endif	# MOZ_PROFILE_USE
 
 ################################################################################
 
+ifdef MOZ_PROFILE_GENERATE
+# Clean up profiling data during PROFILE_GENERATE phase
+export::
+	-$(RM) *.pgd *.gcda
+endif
+
+################################################################################
+
 ifeq ($(OS_ARCH),WINNT)
 $(RES): $(RESNAME)
 	@$(MAKE_OBJDIR)
 # The resource compiler does not understand the -U option.
 ifdef NS_USE_GCC
 	$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) -o $@ $<
 else
 	$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$@ $<
--- a/nsprpub/configure
+++ b/nsprpub/configure
@@ -2817,17 +2817,17 @@ else
   rm -rf conftest*
   result="no"
 fi
 rm -f conftest*
 echo "$ac_t""$result" 1>&6
 
 if test $result = "yes"; then
    PROFILE_GEN_LDFLAGS="-fprofile-generate"
-   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch -freorder-blocks-and-partition"
+   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
    PROFILE_USE_LDFLAGS="-fprofile-use"
 fi
 
 CFLAGS="$_SAVE_CFLAGS"
 
 if test "$GNU_CC"; then
     echo $ac_n "checking for visibility(hidden) attribute""... $ac_c" 1>&6
 echo "configure:2834: checking for visibility(hidden) attribute" >&5
@@ -3773,25 +3773,27 @@ EOF
 EOF
 
     AS='$(CC) -x assembler-with-cpp'
     CFLAGS="$CFLAGS -Wall -fno-common"
     case "${target_cpu}" in
         i*86*)
             if test -n "$USE_64"; then
                 CPU_ARCH=x86_64
-                CC="$CC -arch x86_64"
             else        
                 CPU_ARCH=i386
             fi
             ;;
         *)
             CPU_ARCH=ppc
             ;;
     esac
+    if test "`echo $CC | grep -c '\-arch '`" = "0"; then
+        CC="$CC -arch $CPU_ARCH"
+    fi
     DSO_CFLAGS=-fPIC
     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
     _OPTIMIZE_FLAGS=-O2
     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     STRIP="$STRIP -x -S"
     DLL_SUFFIX=dylib
     USE_PTHREADS=1
     MDCPUCFG_H=_darwin.cfg
@@ -4935,27 +4937,27 @@ EOF
     if test -z "$GNU_CC"; then
         CC="$CC -std1 -ieee_with_inexact"
         if test "$OS_RELEASE" != "V2.0"; then
             CC="$CC -readonly_strings"
         fi
         _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
         ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6
-echo "configure:4944: checking for machine/builtins.h" >&5
+echo "configure:4946: checking for machine/builtins.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4949 "configure"
+#line 4951 "configure"
 #include "confdefs.h"
 #include <machine/builtins.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4954: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4956: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
@@ -5594,63 +5596,63 @@ if test -z "$SKIP_LIBRARY_CHECKS"; then
 
 
 
 case $target in
 *-darwin*|*-beos*|*-os2*)
     ;;
 *)
     echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:5603: checking for dlopen in -ldl" >&5
+echo "configure:5605: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5611 "configure"
+#line 5613 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
 char dlopen();
 
 int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:5622: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5624: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:5639: checking for dlfcn.h" >&5
+echo "configure:5641: checking for dlfcn.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5644 "configure"
+#line 5646 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5649: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5651: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
@@ -5673,23 +5675,23 @@ fi
     ;;
 esac
 
 
 
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:5682: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:5684: checking whether ${CC-cc} needs -traditional" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
     ac_pattern="Autoconf.*'x'"
   cat > conftest.$ac_ext <<EOF
-#line 5688 "configure"
+#line 5690 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 Autoconf TIOCGETP
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "$ac_pattern" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=yes
@@ -5697,17 +5699,17 @@ else
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=no
 fi
 rm -f conftest*
 
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat > conftest.$ac_ext <<EOF
-#line 5706 "configure"
+#line 5708 "configure"
 #include "confdefs.h"
 #include <termio.h>
 Autoconf TCGETA
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "$ac_pattern" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=yes
@@ -5721,22 +5723,22 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
 fi
 
 for ac_func in lchown strerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5730: checking for $ac_func" >&5
+echo "configure:5732: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5735 "configure"
+#line 5737 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
 #include <assert.h>
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
 char $ac_func();
@@ -5749,17 +5751,17 @@ int main() {
 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
 $ac_func();
 #endif
 
 ; return 0; }
 EOF
-if { (eval echo configure:5758: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5760: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=no"
 fi
@@ -5800,17 +5802,17 @@ if test "$CCACHE" != "no"; then
             fi
         fi
     fi
     for ac_prog in $CCACHE ccache
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5809: checking for $ac_word" >&5
+echo "configure:5811: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_CCACHE'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$CCACHE" in
   /*)
   ac_cv_path_CCACHE="$CCACHE" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -5859,17 +5861,17 @@ if test "${enable_strip+set}" = set; the
 fi
 
 
 case "${target_os}" in
 hpux*)
 if test -z "$GNU_CC"; then
 
     echo $ac_n "checking for +Olit support""... $ac_c" 1>&6
-echo "configure:5868: checking for +Olit support" >&5
+echo "configure:5870: checking for +Olit support" >&5
 if eval "test \"`echo '$''{'ac_cv_hpux_usable_olit_option'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
                   ac_cv_hpux_usable_olit_option=no
         rm -f conftest*
         echo 'int main() { return 0; }' | cat > conftest.c
         ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
         if test $? -eq 0; then
@@ -5901,17 +5903,17 @@ darwin*)
     _HAVE_PTHREADS=1
     ;;
 wince*)
     _HAVE_PTHREADS=
     ;;
 *)
     
 echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:5910: checking for pthread_create in -lpthreads" >&5
+echo "configure:5912: checking for pthread_create in -lpthreads" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5923,17 +5925,17 @@ echo "
     rm -f dummy.c dummy${ac_exeext} ;
     if test "$_res" = "0"; then
         echo "$ac_t""yes" 1>&6
         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads"
     else
         echo "$ac_t""no" 1>&6
         
 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:5932: checking for pthread_create in -lpthread" >&5
+echo "configure:5934: checking for pthread_create in -lpthread" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5945,17 +5947,17 @@ echo "
     rm -f dummy.c dummy${ac_exeext} ;
     if test "$_res" = "0"; then
         echo "$ac_t""yes" 1>&6
         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread"
     else
         echo "$ac_t""no" 1>&6
         
 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
-echo "configure:5954: checking for pthread_create in -lc_r" >&5
+echo "configure:5956: checking for pthread_create in -lc_r" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5967,17 +5969,17 @@ echo "
     rm -f dummy.c dummy${ac_exeext} ;
     if test "$_res" = "0"; then
         echo "$ac_t""yes" 1>&6
         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r"
     else
         echo "$ac_t""no" 1>&6
         
 echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
-echo "configure:5976: checking for pthread_create in -lc" >&5
+echo "configure:5978: checking for pthread_create in -lc" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -6085,17 +6087,17 @@ if test "${enable_ipv6+set}" = set; then
       fi
 fi
 
 
 if test -n "$USE_PTHREADS"; then
       rm -f conftest*
    ac_cv_have_dash_pthread=no
    echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6
-echo "configure:6094: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:6096: checking whether ${CC-cc} accepts -pthread" >&5
    echo 'int main() { return 0; }' | cat > conftest.c
    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
    if test $? -eq 0; then
 	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
 	    ac_cv_have_dash_pthread=yes
 		case "$target_os" in
 	    freebsd*)
 # Freebsd doesn't use -pthread for compiles, it uses them for linking
@@ -6108,17 +6110,17 @@ echo "configure:6094: checking whether $
 	fi
     fi
     rm -f conftest*
     echo "$ac_t""$ac_cv_have_dash_pthread" 1>&6
 
 			    ac_cv_have_dash_pthreads=no
     if test "$ac_cv_have_dash_pthread" = "no"; then
 	    echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6
-echo "configure:6117: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:6119: checking whether ${CC-cc} accepts -pthreads" >&5
     	echo 'int main() { return 0; }' | cat > conftest.c
 	    ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
     	if test $? -eq 0; then
 	    	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
 			    ac_cv_have_dash_pthreads=yes
 			    CFLAGS="$CFLAGS -pthreads"
 			    CXXFLAGS="$CXXFLAGS -pthreads"
 		    fi
--- a/nsprpub/configure.in
+++ b/nsprpub/configure.in
@@ -671,17 +671,17 @@ CFLAGS="$CFLAGS -fprofile-generate -fpro
 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
 AC_TRY_COMPILE([], [return 0;],
                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
                  result="yes" ], result="no")
 AC_MSG_RESULT([$result])
 
 if test $result = "yes"; then
    PROFILE_GEN_LDFLAGS="-fprofile-generate"
-   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch -freorder-blocks-and-partition"
+   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
    PROFILE_USE_LDFLAGS="-fprofile-use"
 fi
 
 CFLAGS="$_SAVE_CFLAGS"
 
 dnl ===============================================================
 dnl Check for .hidden assembler directive and visibility attribute.
 dnl Borrowed from glibc configure.in
@@ -1304,25 +1304,27 @@ case "$target" in
     AC_DEFINE(HAVE_BSD_FLOCK)
     AC_DEFINE(HAVE_SOCKLEN_T)
     AS='$(CC) -x assembler-with-cpp'
     CFLAGS="$CFLAGS -Wall -fno-common"
     case "${target_cpu}" in
         i*86*)
             if test -n "$USE_64"; then
                 CPU_ARCH=x86_64
-                CC="$CC -arch x86_64"
             else        
                 CPU_ARCH=i386
             fi
             ;;
         *)
             CPU_ARCH=ppc
             ;;
     esac
+    if test "`echo $CC | grep -c '\-arch '`" = "0"; then
+        CC="$CC -arch $CPU_ARCH"
+    fi
     DSO_CFLAGS=-fPIC
     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
     _OPTIMIZE_FLAGS=-O2
     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     STRIP="$STRIP -x -S"
     DLL_SUFFIX=dylib
     USE_PTHREADS=1
     MDCPUCFG_H=_darwin.cfg
--- a/nsprpub/pr/include/pratom.h
+++ b/nsprpub/pr/include/pratom.h
@@ -128,19 +128,19 @@ long __cdecl _InterlockedExchangeAdd(lon
 #define PR_ATOMIC_INCREMENT(val) _InterlockedIncrement((long volatile *)(val))
 #define PR_ATOMIC_DECREMENT(val) _InterlockedDecrement((long volatile *)(val))
 #define PR_ATOMIC_SET(val, newval) \
         _InterlockedExchange((long volatile *)(val), (long)(newval))
 #define PR_ATOMIC_ADD(ptr, val) \
         (_InterlockedExchangeAdd((long volatile *)(ptr), (long)(val)) + (val))
 
 #elif ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && \
-      ((defined(DARWIN) && \
+      ((defined(__APPLE__) && \
            (defined(__ppc__) || defined(__i386__) || defined(__x86_64__))) || \
-       (defined(LINUX) && \
+       (defined(__linux__) && \
            ((defined(__i386__) && \
            defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \
            defined(__ia64__) || defined(__x86_64__) || \
            (defined(__powerpc__) && !defined(__powerpc64__)) || \
            (defined(__arm__) && \
            defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \
            defined(__alpha))))
 
--- a/nsprpub/pr/include/prinit.h
+++ b/nsprpub/pr/include/prinit.h
@@ -92,16 +92,21 @@ typedef PRBool (*PRVersionCheck)(const c
 **
 ** NSPR's existance proof of the version check function.
 **
 ** Note that NSPR has no cooperating dependencies.
 */
 
 NSPR_API(PRBool) PR_VersionCheck(const char *importedVersion);
 
+/*
+ * Returns a const string of the NSPR library version.
+ */
+NSPR_API(const char*) PR_GetVersion(void);
+
 
 /************************************************************************/
 /*******************************INITIALIZATION***************************/
 /************************************************************************/
 
 /*
 ** Initialize the runtime. Attach a thread object to the currently
 ** executing native thread of type "type".
--- a/nsprpub/pr/include/prtime.h
+++ b/nsprpub/pr/include/prtime.h
@@ -51,21 +51,21 @@
 #include "prlong.h"
 
 PR_BEGIN_EXTERN_C
 
 /**********************************************************************/
 /************************* TYPES AND CONSTANTS ************************/
 /**********************************************************************/
 
-#define PR_MSEC_PER_SEC		1000UL
-#define PR_USEC_PER_SEC		1000000UL
-#define PR_NSEC_PER_SEC		1000000000UL
-#define PR_USEC_PER_MSEC	1000UL
-#define PR_NSEC_PER_MSEC	1000000UL
+#define PR_MSEC_PER_SEC		1000L
+#define PR_USEC_PER_SEC		1000000L
+#define PR_NSEC_PER_SEC		1000000000L
+#define PR_USEC_PER_MSEC	1000L
+#define PR_NSEC_PER_MSEC	1000000L
 
 /*
  * PRTime --
  *
  *     NSPR represents basic time as 64-bit signed integers relative
  *     to midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).
  *     (GMT is also known as Coordinated Universal Time, UTC.)
  *     The units of time are in microseconds. Negative times are allowed
--- a/nsprpub/pr/include/prtypes.h
+++ b/nsprpub/pr/include/prtypes.h
@@ -223,16 +223,23 @@
 ** DESCRIPTION:
 **      Commonly used macros for operations on compatible types.
 ***********************************************************************/
 #define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))
 #define PR_MIN(x,y)     ((x)<(y)?(x):(y))
 #define PR_MAX(x,y)     ((x)>(y)?(x):(y))
 #define PR_ABS(x)       ((x)<0?-(x):(x))
 
+/***********************************************************************
+** 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
 
 /************************************************************************
 ** 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".
--- a/nsprpub/pr/src/misc/prinit.c
+++ b/nsprpub/pr/src/misc/prinit.c
@@ -132,16 +132,20 @@ PR_IMPLEMENT(PRBool) PR_VersionCheck(con
         return PR_FALSE;
     }
     if (vmajor == PR_VMAJOR && vminor == PR_VMINOR && vpatch > PR_VPATCH) {
         return PR_FALSE;
     }
     return PR_TRUE;
 }  /* PR_VersionCheck */
 
+PR_IMPLEMENT(const char*) PR_GetVersion(void)
+{
+    return PR_VERSION;
+}
 
 PR_IMPLEMENT(PRBool) PR_Initialized(void)
 {
     return _pr_initialized;
 }
 
 PRInt32 _native_threads_only = 0;
 
--- a/nsprpub/pr/src/misc/prsystem.c
+++ b/nsprpub/pr/src/misc/prsystem.c
@@ -72,16 +72,22 @@
 #include <sys/pstat.h>
 #endif
 
 #if defined(XP_UNIX)
 #include <unistd.h>
 #include <sys/utsname.h>
 #endif
 
+#if defined(LINUX)
+#include <string.h>
+#include <ctype.h>
+#define MAX_LINE 512
+#endif
+
 #if defined(AIX)
 #include <cf.h>
 #include <sys/cfgodm.h>
 #endif
 
 #if defined(WIN32)
 /* This struct is not present in VC6 headers, so declare it here */
 typedef struct {
@@ -250,18 +256,51 @@ PR_IMPLEMENT(PRInt32) PR_GetNumberOfProc
     if ( numCpus < 1 )  {
         numCpus = -1; /* set to -1 for return value on error */
         _PR_MD_MAP_DEFAULT_ERROR( _MD_ERRNO() );
     }
 #elif defined(IRIX)
     numCpus = sysconf( _SC_NPROC_ONLN );
 #elif defined(RISCOS) || defined(SYMBIAN)
     numCpus = 1;
+#elif defined(LINUX)
+    /* for the benefit of devices with advanced power-saving, that
+       actually hotplug their cpus in heavy load, try to figure out
+       the real number of CPUs */
+    char buf[MAX_LINE];
+    FILE *fin;
+    const char *cpu_present = "/sys/devices/system/cpu/present";
+    size_t strsize;
+    numCpus = 0;
+    fin = fopen(cpu_present, "r");
+    if (fin != NULL) {
+        if (fgets(buf, MAX_LINE, fin) != NULL) {
+            /* check that the format is what we expect */
+            if (buf[0] == '0') {
+                strsize = strlen(buf);
+                if (strsize == 1) {
+                    /* single core */
+                    numCpus = 1;
+                } else if (strsize >= 3 && strsize <= 5) {
+                    /* should be of the form 0-999 */
+                    /* parse the part after the 0-, note count is 0-based */
+                    if (buf[1] == '-' && isdigit(buf[2])) {
+                        numCpus = 1 + atoi(buf + 2);
+                    }
+                }
+            }
+        }
+        fclose(fin);
+    }
+    /* if that fails, fall back to more standard methods */
+    if (!numCpus) {
+        numCpus = sysconf( _SC_NPROCESSORS_CONF );
+    }
 #elif defined(XP_UNIX)
-    numCpus = sysconf( _SC_NPROCESSORS_ONLN );
+    numCpus = sysconf( _SC_NPROCESSORS_CONF );
 #else
 #error "An implementation is required"
 #endif
     return(numCpus);
 } /* end PR_GetNumberOfProcessors() */
 
 /*
 ** PR_GetPhysicalMemorySize()
--- a/nsprpub/pr/src/nspr.def
+++ b/nsprpub/pr/src/nspr.def
@@ -469,8 +469,12 @@ EXPORTS ;-
 ;+	global:
 		PR_ParseTimeStringToExplodedTime;
 ;+} NSPR_4.6;
 ;+NSPR_4.8 {
 ;+	global:
 		PR_AssertCurrentThreadOwnsLock;
 		PR_AssertCurrentThreadInMonitor;
 ;+} NSPR_4.7;
+;+NSPR_4.8.9 {
+;+      global:
+                PR_GetVersion;
+;+} NSPR_4.8;
--- a/nsprpub/pr/tests/sprintf.c
+++ b/nsprpub/pr/tests/sprintf.c
@@ -51,18 +51,16 @@
 #include "prinit.h"
 #include "prprf.h"
 #include "prlog.h"
 #include "prlong.h"
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#define countof(a) (sizeof(a)/sizeof(a[0]))
-
 static char sbuf[20000];
 
 
 /*
 ** Perform a three way test against PR_smprintf, PR_snprintf, and sprintf.
 ** Make sure the results are identical
 */
 static void test_i(char *pattern, int i)
@@ -116,25 +114,25 @@ static void TestI(void)
     };
     static char *formats[] = {
 	"d", "o", "x", "u",
 	"hd", "ho", "hx", "hu"
     };
     int f, s, n, p;
     char fmt[20];
 
-    for (f = 0; f < countof(formats); f++) {
-	for (s = 0; s < countof(signs); s++) {
-	    for (p = 0; p < countof(precs); p++) {
+    for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {
+	for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {
+	    for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {
 		fmt[0] = '%';
 		fmt[1] = 0;
 		if (signs[s]) strcat(fmt, signs[s]);
 		if (precs[p]) strcat(fmt, precs[p]);
 		if (formats[f]) strcat(fmt, formats[f]);
-		for (n = 0; n < countof(nums); n++) {
+		for (n = 0; n < PR_ARRAY_SIZE(nums); n++) {
 		    test_i(fmt, nums[n]);
 		}
 	    }
 	}
     }
 }
 
 /************************************************************************/
@@ -208,27 +206,27 @@ static void TestL(void)
     static char *sformats[] = { "ld", "lo", "lx", "lu" };
 #else
 #error Neither int nor long is 4 bytes on this platform
 #endif
 
     int f, s, n, p;
     char fmt[40], sfmt[40];
 
-    for (f = 0; f < countof(formats); f++) {
-	for (s = 0; s < countof(signs); s++) {
-	    for (p = 0; p < countof(precs); p++) {
+    for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {
+	for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {
+	    for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {
 		fmt[0] = '%';
 		fmt[1] = 0;
 		if (signs[s]) strcat(fmt, signs[s]);
 		if (precs[p]) strcat(fmt, precs[p]);
 		strcpy(sfmt, fmt);
 		if (formats[f]) strcat(fmt, formats[f]);
 		if (sformats[f]) strcat(sfmt, sformats[f]);
-		for (n = 0; n < countof(nums); n++) {
+		for (n = 0; n < PR_ARRAY_SIZE(nums); n++) {
 		    test_l(fmt, sfmt, nums[n]);
 		}
 	    }
 	}
     }
 }
 
 /************************************************************************/
@@ -331,27 +329,27 @@ static void TestLL(void)
     static char *sformats[] = { "I64d", "I64o", "I64x", "I64u" };
 #else
     static char *sformats[] = { "lld", "llo", "llx", "llu" };
 #endif
 
     int f, s, n, p;
     char fmt[40], sfmt[40];
 
-    for (f = 0; f < countof(formats); f++) {
-	for (s = 0; s < countof(signs); s++) {
-	    for (p = 0; p < countof(precs); p++) {
+    for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {
+	for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {
+	    for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {
 		fmt[0] = '%';
 		fmt[1] = 0;
 		if (signs[s]) strcat(fmt, signs[s]);
 		if (precs[p]) strcat(fmt, precs[p]);
 		strcpy(sfmt, fmt);
 		if (formats[f]) strcat(fmt, formats[f]);
 		if (sformats[f]) strcat(sfmt, sformats[f]);
-		for (n = 0; n < countof(nums); n++) {
+		for (n = 0; n < PR_ARRAY_SIZE(nums); n++) {
 		    test_ll(fmt, sfmt, nums[n]);
 		}
 	    }
 	}
     }
 }
 
 /************************************************************************/
@@ -419,25 +417,25 @@ static void TestS(void)
 	"", "3", "5", "43",
 	".3", ".43",
 	"7.3", "7.5", "7.11", "7.43",
     };
     static char *formats[] = { "s" };
     int f, s, n, p;
     char fmt[40];
 
-    for (f = 0; f < countof(formats); f++) {
-	for (s = 0; s < countof(signs); s++) {
-	    for (p = 0; p < countof(precs); p++) {
+    for (f = 0; f < PR_ARRAY_SIZE(formats); f++) {
+	for (s = 0; s < PR_ARRAY_SIZE(signs); s++) {
+	    for (p = 0; p < PR_ARRAY_SIZE(precs); p++) {
 		fmt[0] = '%';
 		fmt[1] = 0;
 		if (signs[s]) strcat(fmt+strlen(fmt), signs[s]);
 		if (precs[p]) strcat(fmt+strlen(fmt), precs[p]);
 		if (formats[f]) strcat(fmt+strlen(fmt), formats[f]);
-		for (n = 0; n < countof(strs); n++) {
+		for (n = 0; n < PR_ARRAY_SIZE(strs); n++) {
 		    test_s(fmt, strs[n]);
 		}
 	    }
 	}
     }
 }
 
 /************************************************************************/