Bug 844784: Update NSPR to NSPR_4_10_4_BETA4. Also includes the changes
authorWan-Teh Chang <wtc@google.com>
Sat, 01 Mar 2014 08:46:18 -0800
changeset 182391 65f75ee1c34f1864b734c679b2e0ab529475f44d
parent 182390 cef723d9aa314ffc52f27cd9d5595878cfe740d6
child 182392 fd2a7c560b0c81f2c22149c39c81aa415a613760
push id5439
push userffxbld
push dateMon, 17 Mar 2014 23:08:15 +0000
treeherdermozilla-aurora@c0befb3c8038 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs844784, 972125, 963033, 767759, 971152, 936320, 969061
milestone30.0a1
Bug 844784: Update NSPR to NSPR_4_10_4_BETA4. Also includes the changes for bug 972125, bug 963033, bug 767759, bug 971152, bug 936320, and bug 969061.
nsprpub/TAG-INFO
nsprpub/config/prdepend.h
nsprpub/configure
nsprpub/configure.in
nsprpub/pr/include/md/_darwin.cfg
nsprpub/pr/include/md/_darwin.h
nsprpub/pr/include/pratom.h
nsprpub/pr/include/private/primpl.h
nsprpub/pr/src/misc/prcountr.c
nsprpub/pr/src/misc/prnetdb.c
nsprpub/pr/src/misc/prtrace.c
nsprpub/pr/src/pthreads/ptio.c
nsprpub/pr/src/pthreads/ptsynch.c
nsprpub/pr/src/threads/combined/prucv.c
nsprpub/pr/src/threads/combined/prulock.c
nsprpub/pr/src/threads/prmon.c
nsprpub/pr/tests/instrumt.c
--- a/nsprpub/TAG-INFO
+++ b/nsprpub/TAG-INFO
@@ -1,1 +1,1 @@
-NSPR_4_10_4_BETA3
+NSPR_4_10_4_BETA4
--- 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
@@ -50,16 +50,18 @@ ac_help="$ac_help
 ac_help="$ac_help
   --enable-symbian-target=\$t
                           Specify symbian flavor. (WINSCW or GCCE)"
 ac_help="$ac_help
   --enable-debug-rtl      Use the MSVC debug runtime library"
 ac_help="$ac_help
   --enable-n32            Enable n32 ABI support (IRIX only)"
 ac_help="$ac_help
+  --enable-x32            Enable x32 ABI support (x86_64 only)"
+ac_help="$ac_help
   --enable-64bit          Enable 64-bit support (on certain platforms)"
 ac_help="$ac_help
   --enable-mdupdate       Enable use of certain compilers' mdupdate feature"
 ac_help="$ac_help
   --enable-cplus          Enable some c++ api routines"
 ac_help="$ac_help
   --with-arm-kuser        Use kuser helpers (Linux/ARM only)
                           (Requires kernel 2.6.13 or later)"
@@ -667,17 +669,17 @@ esac
 
 
 # Make sure we can run config.sub.
 if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
 else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:676: checking host system type" >&5
+echo "configure:678: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
 NONE)
   case $nonopt in
   NONE)
     if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
     else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
@@ -688,17 +690,17 @@ esac
 
 host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
 host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$host" 1>&6
 
 echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:697: checking target system type" >&5
+echo "configure:699: checking target system type" >&5
 
 target_alias=$target
 case "$target_alias" in
 NONE)
   case $nonopt in
   NONE) target_alias=$host_alias ;;
   *) target_alias=$nonopt ;;
   esac ;;
@@ -706,17 +708,17 @@ esac
 
 target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
 target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$target" 1>&6
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:715: checking build system type" >&5
+echo "configure:717: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
 NONE)
   case $nonopt in
   NONE) build_alias=$host_alias ;;
   *) build_alias=$nonopt ;;
   esac ;;
@@ -738,16 +740,17 @@ MOD_MAJOR_VERSION=4
 MOD_MINOR_VERSION=10
 MOD_PATCH_VERSION=4
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
+USE_X32=
 USE_64=
 USE_CPLUS=
 USE_IPV6=
 USE_MDUPDATE=
 _MACOSX_DEPLOYMENT_TARGET=
 _OPTIMIZE_FLAGS=-O
 _DEBUG_FLAGS=-g
 MOZ_DEBUG=1
@@ -782,17 +785,17 @@ case "$target" in
 *-cygwin*|*-mingw*)
     # Check to see if we are really running in a msvc environemnt
     _WIN32_MSVC=
     for ac_prog in cl
 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:791: checking for $ac_word" >&5
+echo "configure:794: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -926,17 +929,17 @@ else
 case "$target" in
 *-android*|*-linuxandroid*)
     if test -z "$android_ndk" ; then
        { echo "configure: error: You must specify --with-android-ndk=/path/to/ndk when targeting Android." 1>&2; exit 1; }
     fi
 
     if test -z "$android_toolchain" ; then
         echo $ac_n "checking for android toolchain directory""... $ac_c" 1>&6
-echo "configure:935: checking for android toolchain directory" >&5
+echo "configure:938: checking for android toolchain directory" >&5
 
         kernel_name=`uname -s | tr "[:upper:]" "[:lower:]"`
 
         case "$target_cpu" in
         arm)
             target_name=arm-linux-androideabi-4.4.3
             ;;
         i?86)
@@ -952,17 +955,17 @@ echo "configure:935: checking for androi
             echo "$ac_t""$android_toolchain" 1>&6
         else
             { echo "configure: error: not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain." 1>&2; exit 1; }
         fi
     fi
 
     if test -z "$android_platform" ; then
         echo $ac_n "checking for android platform directory""... $ac_c" 1>&6
-echo "configure:961: checking for android platform directory" >&5
+echo "configure:964: checking for android platform directory" >&5
 
         case "$target_cpu" in
         arm)
             target_name=arm
             ;;
         i?86)
             target_name=x86
             ;;
@@ -1168,16 +1171,28 @@ if test "${enable_n32+set}" = set; then
 	USE_N32=1
       else if test "$enableval" = "no"; then
 	USE_N32=
       fi
     fi 
 fi
 
 
+# Check whether --enable-x32 or --disable-x32 was given.
+if test "${enable_x32+set}" = set; then
+  enableval="$enable_x32"
+   if test "$enableval" = "yes"; then
+        USE_X32=1
+      else if test "$enableval" = "no"; then
+        USE_X32=
+      fi
+    fi 
+fi
+
+
 # Check whether --enable-64bit or --disable-64bit was given.
 if test "${enable_64bit+set}" = set; then
   enableval="$enable_64bit"
    if test "$enableval" = "yes"; then
 	    USE_64=1
       fi 
 fi
 
@@ -1310,17 +1325,17 @@ if test -z "$CXX"; then
 
     esac
 fi
 
 if test -z "$SKIP_PATH_CHECKS"; then
     # Extract the first word of "$WHOAMI whoami", so it can be a program name with args.
 set dummy $WHOAMI whoami; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1319: checking for $ac_word" >&5
+echo "configure:1334: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_WHOAMI'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$WHOAMI" in
   /*)
   ac_cv_path_WHOAMI="$WHOAMI" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -1382,23 +1397,23 @@ if test "$target" != "$host" -o -n "$CRO
     echo "cross compiling from $host to $target"
     cross_compiling=yes
 
     _SAVE_CC="$CC"
     _SAVE_CFLAGS="$CFLAGS"
     _SAVE_LDFLAGS="$LDFLAGS"
 
     echo $ac_n "checking for $host compiler""... $ac_c" 1>&6
-echo "configure:1391: checking for $host compiler" >&5
+echo "configure:1406: checking for $host compiler" >&5
     for ac_prog in $HOST_CC gcc cc /usr/ucb/cc
 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:1397: checking for $ac_word" >&5
+echo "configure:1412: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_HOST_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$HOST_CC"; then
   ac_cv_prog_HOST_CC="$HOST_CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1434,26 +1449,26 @@ test -n "$HOST_CC" || HOST_CC=""""
         HOST_LDFLAGS="$LDFLAGS"
     fi
 
     CC="$HOST_CC"
     CFLAGS="$HOST_CFLAGS"
     LDFLAGS="$HOST_LDFLAGS"
 
     echo $ac_n "checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1443: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
+echo "configure:1458: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
     cat > conftest.$ac_ext <<EOF
-#line 1445 "configure"
+#line 1460 "configure"
 #include "confdefs.h"
 
 int main() {
 return 0;
 ; return 0; }
 EOF
-if { (eval echo configure:1452: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1467: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   { echo "configure: error: installation or configuration problem: $host compiler $HOST_CC cannot create executables." 1>&2; exit 1; } 
 fi
@@ -1478,17 +1493,17 @@ rm -f conftest*
         ;;
     esac
 
     for ac_prog in $CC "${target_alias}-gcc" "${target}-gcc"
 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:1487: checking for $ac_word" >&5
+echo "configure:1502: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1512,17 +1527,17 @@ fi
 test -n "$CC" && break
 done
 test -n "$CC" || CC="echo"
 
     unset ac_cv_prog_CC
     # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1521: checking for $ac_word" >&5
+echo "configure:1536: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1542,17 +1557,17 @@ if test -n "$CC"; then
 else
   echo "$ac_t""no" 1>&6
 fi
 
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1551: checking for $ac_word" >&5
+echo "configure:1566: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
@@ -1593,17 +1608,17 @@ else
 fi
 
   if test -z "$CC"; then
     case "`uname -s`" in
     *win32* | *WIN32*)
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1602: checking for $ac_word" >&5
+echo "configure:1617: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1625,33 +1640,33 @@ else
 fi
  ;;
     esac
   fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1634: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1649: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 1645 "configure"
+#line 1660 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1650: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1665: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
     ac_cv_prog_cc_cross=no
   else
     ac_cv_prog_cc_cross=yes
   fi
 else
@@ -1667,31 +1682,31 @@ ac_compile='${CC-cc} -c $CFLAGS $CPPFLAG
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1676: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1691: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1681: checking whether we are using GNU C" >&5
+echo "configure:1696: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.c <<EOF
 #ifdef __GNUC__
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1690: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1705: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
 fi
 fi
 
 echo "$ac_t""$ac_cv_prog_gcc" 1>&6
 
@@ -1700,17 +1715,17 @@ if test $ac_cv_prog_gcc = yes; then
 else
   GCC=
 fi
 
 ac_test_CFLAGS="${CFLAGS+set}"
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1709: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1724: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
   ac_cv_prog_cc_g=yes
 else
   ac_cv_prog_cc_g=no
@@ -1737,17 +1752,17 @@ else
 fi
 
     if test -n "$USE_CPLUS"; then
         for ac_prog in $CXX "${target_alias}-g++" "${target}-g++"
 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:1746: checking for $ac_word" >&5
+echo "configure:1761: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CXX"; then
   ac_cv_prog_CXX="$CXX" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1773,17 +1788,17 @@ done
 test -n "$CXX" || CXX="echo"
 
         unset ac_cv_prog_CXX
         for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
 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:1782: checking for $ac_word" >&5
+echo "configure:1797: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CXX"; then
   ac_cv_prog_CXX="$CXX" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1805,33 +1820,33 @@ else
 fi
 
 test -n "$CXX" && break
 done
 test -n "$CXX" || CXX="gcc"
 
 
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1814: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:1829: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
 
 ac_ext=C
 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
 ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cxx_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 1825 "configure"
+#line 1840 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:1830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1845: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cxx_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
     ac_cv_prog_cxx_cross=no
   else
     ac_cv_prog_cxx_cross=yes
   fi
 else
@@ -1847,31 +1862,31 @@ ac_compile='${CC-cc} -c $CFLAGS $CPPFLAG
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
 if test $ac_cv_prog_cxx_works = no; then
   { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1856: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1871: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
 cross_compiling=$ac_cv_prog_cxx_cross
 
 echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
-echo "configure:1861: checking whether we are using GNU C++" >&5
+echo "configure:1876: checking whether we are using GNU C++" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.C <<EOF
 #ifdef __GNUC__
   yes;
 #endif
 EOF
-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1870: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1885: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gxx=yes
 else
   ac_cv_prog_gxx=no
 fi
 fi
 
 echo "$ac_t""$ac_cv_prog_gxx" 1>&6
 
@@ -1880,17 +1895,17 @@ if test $ac_cv_prog_gxx = yes; then
 else
   GXX=
 fi
 
 ac_test_CXXFLAGS="${CXXFLAGS+set}"
 ac_save_CXXFLAGS="$CXXFLAGS"
 CXXFLAGS=
 echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
-echo "configure:1889: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:1904: checking whether ${CXX-g++} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   echo 'void f(){}' > conftest.cc
 if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
   ac_cv_prog_cxx_g=yes
 else
   ac_cv_prog_cxx_g=no
@@ -1925,17 +1940,17 @@ fi
         ;;
     esac
 
     for ac_prog in $RANLIB "${target_alias}-ranlib" "${target}-ranlib"
 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:1934: checking for $ac_word" >&5
+echo "configure:1949: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1960,17 +1975,17 @@ test -n "$RANLIB" && break
 done
 test -n "$RANLIB" || RANLIB="echo"
 
     for ac_prog in $AR "${target_alias}-ar" "${target}-ar"
 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:1969: checking for $ac_word" >&5
+echo "configure:1984: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$AR"; then
   ac_cv_prog_AR="$AR" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1995,17 +2010,17 @@ test -n "$AR" && break
 done
 test -n "$AR" || AR="echo"
 
     for ac_prog in $AS "${target_alias}-as" "${target}-as"
 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:2004: checking for $ac_word" >&5
+echo "configure:2019: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$AS"; then
   ac_cv_prog_AS="$AS" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -2030,17 +2045,17 @@ test -n "$AS" && break
 done
 test -n "$AS" || AS="echo"
 
     for ac_prog in $LD "${target_alias}-ld" "${target}-ld"
 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:2039: checking for $ac_word" >&5
+echo "configure:2054: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$LD"; then
   ac_cv_prog_LD="$LD" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -2065,17 +2080,17 @@ test -n "$LD" && break
 done
 test -n "$LD" || LD="echo"
 
     for ac_prog in $STRIP "${target_alias}-strip" "${target}-strip"
 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:2074: checking for $ac_word" >&5
+echo "configure:2089: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$STRIP"; then
   ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -2100,17 +2115,17 @@ test -n "$STRIP" && break
 done
 test -n "$STRIP" || STRIP="echo"
 
     for ac_prog in $WINDRES "${target_alias}-windres" "${target}-windres"
 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:2109: checking for $ac_word" >&5
+echo "configure:2124: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$WINDRES"; then
   ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -2135,17 +2150,17 @@ test -n "$WINDRES" && break
 done
 test -n "$WINDRES" || WINDRES="echo"
 
 
 else
     # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2144: checking for $ac_word" >&5
+echo "configure:2159: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -2165,17 +2180,17 @@ if test -n "$CC"; then
 else
   echo "$ac_t""no" 1>&6
 fi
 
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2174: checking for $ac_word" >&5
+echo "configure:2189: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
@@ -2216,17 +2231,17 @@ else
 fi
 
   if test -z "$CC"; then
     case "`uname -s`" in
     *win32* | *WIN32*)
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2225: checking for $ac_word" >&5
+echo "configure:2240: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -2248,33 +2263,33 @@ else
 fi
  ;;
     esac
   fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:2257: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:2272: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 2268 "configure"
+#line 2283 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:2273: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2288: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
     ac_cv_prog_cc_cross=no
   else
     ac_cv_prog_cc_cross=yes
   fi
 else
@@ -2290,31 +2305,31 @@ ac_compile='${CC-cc} -c $CFLAGS $CPPFLAG
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:2299: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2314: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:2304: checking whether we are using GNU C" >&5
+echo "configure:2319: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.c <<EOF
 #ifdef __GNUC__
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2313: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2328: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
 fi
 fi
 
 echo "$ac_t""$ac_cv_prog_gcc" 1>&6
 
@@ -2323,17 +2338,17 @@ if test $ac_cv_prog_gcc = yes; then
 else
   GCC=
 fi
 
 ac_test_CFLAGS="${CFLAGS+set}"
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:2332: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:2347: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
   ac_cv_prog_cc_g=yes
 else
   ac_cv_prog_cc_g=no
@@ -2363,17 +2378,17 @@ fi
         if test "$CC" = "cl" -a -z "$CXX"; then
             CXX=$CC
         else        
             for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
 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:2372: checking for $ac_word" >&5
+echo "configure:2387: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CXX"; then
   ac_cv_prog_CXX="$CXX" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -2395,33 +2410,33 @@ else
 fi
 
 test -n "$CXX" && break
 done
 test -n "$CXX" || CXX="gcc"
 
 
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:2404: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:2419: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
 
 ac_ext=C
 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
 ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cxx_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 2415 "configure"
+#line 2430 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:2420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cxx_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
     ac_cv_prog_cxx_cross=no
   else
     ac_cv_prog_cxx_cross=yes
   fi
 else
@@ -2437,31 +2452,31 @@ ac_compile='${CC-cc} -c $CFLAGS $CPPFLAG
 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
 if test $ac_cv_prog_cxx_works = no; then
   { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:2446: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2461: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
 cross_compiling=$ac_cv_prog_cxx_cross
 
 echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
-echo "configure:2451: checking whether we are using GNU C++" >&5
+echo "configure:2466: checking whether we are using GNU C++" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.C <<EOF
 #ifdef __GNUC__
   yes;
 #endif
 EOF
-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:2460: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:2475: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gxx=yes
 else
   ac_cv_prog_gxx=no
 fi
 fi
 
 echo "$ac_t""$ac_cv_prog_gxx" 1>&6
 
@@ -2470,17 +2485,17 @@ if test $ac_cv_prog_gxx = yes; then
 else
   GXX=
 fi
 
 ac_test_CXXFLAGS="${CXXFLAGS+set}"
 ac_save_CXXFLAGS="$CXXFLAGS"
 CXXFLAGS=
 echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
-echo "configure:2479: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:2494: checking whether ${CXX-g++} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   echo 'void f(){}' > conftest.cc
 if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
   ac_cv_prog_cxx_g=yes
 else
   ac_cv_prog_cxx_g=no
@@ -2504,72 +2519,72 @@ else
   else
     CXXFLAGS=
   fi
 fi
 
         fi
     fi
     echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:2513: checking how to run the C preprocessor" >&5
+echo "configure:2528: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
 if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
     # This must be in double quotes, not single quotes, because CPP may get
   # substituted into the Makefile and "${CC-cc}" will confuse make.
   CPP="${CC-cc} -E"
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 2528 "configure"
+#line 2543 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2534: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2549: \"$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
   :
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 2545 "configure"
+#line 2560 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2551: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2566: \"$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
   :
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 2562 "configure"
+#line 2577 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2568: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2583: \"$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
   :
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
@@ -2586,17 +2601,17 @@ fi
 else
   ac_cv_prog_CPP="$CPP"
 fi
 echo "$ac_t""$CPP" 1>&6
 
     # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2595: checking for $ac_word" >&5
+echo "configure:2610: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -2618,17 +2633,17 @@ else
   echo "$ac_t""no" 1>&6
 fi
 
     for ac_prog in as
 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:2627: checking for $ac_word" >&5
+echo "configure:2642: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_AS'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$AS" in
   /*)
   ac_cv_path_AS="$AS" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2659,17 +2674,17 @@ test -n "$AS" && break
 done
 test -n "$AS" || AS="$CC"
 
     for ac_prog in ar
 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:2668: checking for $ac_word" >&5
+echo "configure:2683: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_AR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$AR" in
   /*)
   ac_cv_path_AR="$AR" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2700,17 +2715,17 @@ test -n "$AR" && break
 done
 test -n "$AR" || AR="echo not_ar"
 
     for ac_prog in ld link
 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:2709: checking for $ac_word" >&5
+echo "configure:2724: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$LD" in
   /*)
   ac_cv_path_LD="$LD" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2741,17 +2756,17 @@ test -n "$LD" && break
 done
 test -n "$LD" || LD="echo not_ld"
 
     for ac_prog in strip
 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:2750: checking for $ac_word" >&5
+echo "configure:2765: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_STRIP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$STRIP" in
   /*)
   ac_cv_path_STRIP="$STRIP" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2782,17 +2797,17 @@ test -n "$STRIP" && break
 done
 test -n "$STRIP" || STRIP="echo not_strip"
 
     for ac_prog in windres
 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:2791: checking for $ac_word" >&5
+echo "configure:2806: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_WINDRES'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$WINDRES" in
   /*)
   ac_cv_path_WINDRES="$WINDRES" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2850,39 +2865,39 @@ esac
 
 if test "$cross_compiling"  = "yes"; then
     CROSS_COMPILE=1
 else
     CROSS_COMPILE=
 fi
 
 echo $ac_n "checking for gcc -pipe support""... $ac_c" 1>&6
-echo "configure:2859: checking for gcc -pipe support" >&5
+echo "configure:2874: checking for gcc -pipe support" >&5
 if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then
     echo '#include <stdio.h>' > dummy-hello.c
     echo 'int main() { printf("Hello World\n"); return 0; }' >> dummy-hello.c
     ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5
     cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5
     if test $? = 0; then
         _res_as_stdin="yes"
     else
         _res_as_stdin="no"
     fi
     if test "$_res_as_stdin" = "yes"; then
         _SAVE_CFLAGS=$CFLAGS
         CFLAGS="$CFLAGS -pipe"
         cat > conftest.$ac_ext <<EOF
-#line 2874 "configure"
+#line 2889 "configure"
 #include "confdefs.h"
  #include <stdio.h> 
 int main() {
 printf("Hello World\n");
 ; return 0; }
 EOF
-if { (eval echo configure:2881: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2896: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   _res_gcc_pipe="yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   _res_gcc_pipe="no" 
 fi
@@ -2902,26 +2917,26 @@ else
     echo "$ac_t""no" 1>&6
 fi
 
 
 _SAVE_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
 
 echo $ac_n "checking whether C compiler supports -fprofile-generate""... $ac_c" 1>&6
-echo "configure:2911: checking whether C compiler supports -fprofile-generate" >&5
+echo "configure:2926: checking whether C compiler supports -fprofile-generate" >&5
 cat > conftest.$ac_ext <<EOF
-#line 2913 "configure"
+#line 2928 "configure"
 #include "confdefs.h"
 
 int main() {
 return 0;
 ; return 0; }
 EOF
-if { (eval echo configure:2920: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2935: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
    PROFILE_GEN_CFLAGS="-fprofile-generate"
                  result="yes" 
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   result="no"
@@ -2934,17 +2949,17 @@ if test $result = "yes"; then
    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:2943: checking for visibility(hidden) attribute" >&5
+echo "configure:2958: checking for visibility(hidden) attribute" >&5
 if eval "test \"`echo '$''{'ac_cv_visibility_hidden'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.c <<EOF
         int foo __attribute__ ((visibility ("hidden"))) = 1;
 EOF
         ac_cv_visibility_hidden=no
         if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
@@ -2958,17 +2973,17 @@ fi
 
 echo "$ac_t""$ac_cv_visibility_hidden" 1>&6
     if test "$ac_cv_visibility_hidden" = "yes"; then
         cat >> confdefs.h <<\EOF
 #define HAVE_VISIBILITY_HIDDEN_ATTRIBUTE 1
 EOF
 
         echo $ac_n "checking for visibility pragma support""... $ac_c" 1>&6
-echo "configure:2967: checking for visibility pragma support" >&5
+echo "configure:2982: checking for visibility pragma support" >&5
 if eval "test \"`echo '$''{'ac_cv_visibility_pragma'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.c <<EOF
 #pragma GCC visibility push(hidden)
             int foo_hidden = 1;
 #pragma GCC visibility push(default)
             int foo_default = 1;
@@ -3011,17 +3026,17 @@ fi # GNU_CC
 fi # SKIP_COMPILER_CHECKS
 
 if test -z "$SKIP_PATH_CHECKS"; then
     for ac_prog in perl5 perl
 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:3020: checking for $ac_word" >&5
+echo "configure:3035: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$PERL" in
   /*)
   ac_cv_path_PERL="$PERL" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -3336,24 +3351,24 @@ yes)
 no)
     MOZ_THUMB2=
     thumb_flag="-marm"
     ;;
 *)
     _SAVE_CFLAGS="$CFLAGS"
     CFLAGS="$arch_flag"
     cat > conftest.$ac_ext <<EOF
-#line 3345 "configure"
+#line 3360 "configure"
 #include "confdefs.h"
 
 int main() {
 return sizeof(__thumb2__);
 ; return 0; }
 EOF
-if { (eval echo configure:3352: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3367: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   MOZ_THUMB2=1
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   MOZ_THUMB2=
 fi
@@ -3419,52 +3434,52 @@ yes)
     align_flag=""
     ;;
 esac
 
 if test -n "$align_flag"; then
   _SAVE_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS $align_flag"
   echo $ac_n "checking whether alignment flag ($align_flag) is supported""... $ac_c" 1>&6
-echo "configure:3428: checking whether alignment flag ($align_flag) is supported" >&5
+echo "configure:3443: checking whether alignment flag ($align_flag) is supported" >&5
   cat > conftest.$ac_ext <<EOF
-#line 3430 "configure"
+#line 3445 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3437: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3452: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   align_flag=""
 fi
 rm -f conftest*
   CFLAGS="$_SAVE_CFLAGS"
 fi
 
 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
 if test -n "$all_flags"; then
     _SAVE_CFLAGS="$CFLAGS"
     CFLAGS="$all_flags"
     echo $ac_n "checking whether the chosen combination of compiler flags ($all_flags) works""... $ac_c" 1>&6
-echo "configure:3454: checking whether the chosen combination of compiler flags ($all_flags) works" >&5
+echo "configure:3469: checking whether the chosen combination of compiler flags ($all_flags) works" >&5
     cat > conftest.$ac_ext <<EOF
-#line 3456 "configure"
+#line 3471 "configure"
 #include "confdefs.h"
 
 int main() {
 return 0;
 ; return 0; }
 EOF
-if { (eval echo configure:3463: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3478: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   { echo "configure: error: no" 1>&2; exit 1; }
 fi
@@ -3511,27 +3526,27 @@ EOF
 
     cat >> confdefs.h <<\EOF
 #define SYSV 1
 EOF
 
     DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
     ac_safe=`echo "sys/atomic_op.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/atomic_op.h""... $ac_c" 1>&6
-echo "configure:3520: checking for sys/atomic_op.h" >&5
+echo "configure:3535: checking for sys/atomic_op.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 3525 "configure"
+#line 3540 "configure"
 #include "confdefs.h"
 #include <sys/atomic_op.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3530: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3545: \"$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
@@ -3678,36 +3693,36 @@ EOF
     PR_MD_ARCH_DIR=beos
     RESOLVE_LINK_SYMBOLS=1
     case "${target_cpu}" in
     i*86)
         _OPTIMIZE_FLAGS=-O2
         _DEBUG_FLAGS='-gdwarf-2 -O0'
         MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
         echo $ac_n "checking for gethostbyaddr in -lbind""... $ac_c" 1>&6
-echo "configure:3687: checking for gethostbyaddr in -lbind" >&5
+echo "configure:3702: checking for gethostbyaddr in -lbind" >&5
 ac_lib_var=`echo bind'_'gethostbyaddr | 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="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3695 "configure"
+#line 3710 "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 gethostbyaddr();
 
 int main() {
 gethostbyaddr()
 ; return 0; }
 EOF
-if { (eval echo configure:3706: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3721: \"$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
@@ -3906,27 +3921,27 @@ EOF
             CPU_ARCH=ppc
             ;;
     esac
     if test "`echo $CC | grep -c '\-arch '`" = "0"; then
         CC="$CC -arch $CPU_ARCH"
     fi
     ac_safe=`echo "crt_externs.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for crt_externs.h""... $ac_c" 1>&6
-echo "configure:3915: checking for crt_externs.h" >&5
+echo "configure:3930: checking for crt_externs.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 3920 "configure"
+#line 3935 "configure"
 #include "confdefs.h"
 #include <crt_externs.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3925: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3940: \"$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
@@ -4523,16 +4538,20 @@ EOF
         PR_MD_ASFILES=os_Linux_x86.s
         ;;
     ia64)
         PR_MD_ASFILES=os_Linux_ia64.s
         ;;
     x86_64)
         if test -n "$USE_64"; then
             PR_MD_ASFILES=os_Linux_x86_64.s
+        elif test -n "$USE_X32"; then
+            PR_MD_ASFILES=os_Linux_x86_64.s
+            CC="$CC -mx32"
+            CXX="$CXX -mx32"
         else
             cat >> confdefs.h <<\EOF
 #define i386 1
 EOF
 
             PR_MD_ASFILES=os_Linux_x86.s
             CC="$CC -m32"
             CXX="$CXX -m32"
@@ -4966,27 +4985,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:4975: checking for machine/builtins.h" >&5
+echo "configure:4994: 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 4980 "configure"
+#line 4999 "configure"
 #include "confdefs.h"
 #include <machine/builtins.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4985: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5004: \"$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
@@ -5535,63 +5554,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:5544: checking for dlopen in -ldl" >&5
+echo "configure:5563: 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 5552 "configure"
+#line 5571 "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:5563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5582: \"$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:5580: checking for dlfcn.h" >&5
+echo "configure:5599: 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 5585 "configure"
+#line 5604 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5590: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5609: \"$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
@@ -5614,23 +5633,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:5623: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:5642: 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 5629 "configure"
+#line 5648 "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
@@ -5638,17 +5657,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 5647 "configure"
+#line 5666 "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
@@ -5664,22 +5683,22 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional
   fi
 fi
 
 _SAVE_LIBS="$LIBS"
 LIBS="$LIBS $OS_LIBS"
 for ac_func in dladdr gettid lchown setpriority strerror syscall
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5673: checking for $ac_func" >&5
+echo "configure:5692: 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 5678 "configure"
+#line 5697 "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();
@@ -5692,17 +5711,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:5701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5720: \"$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
@@ -5744,17 +5763,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:5753: checking for $ac_word" >&5
+echo "configure:5772: 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.
   ;;
   ?:/*)			 
@@ -5803,17 +5822,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:5812: checking for +Olit support" >&5
+echo "configure:5831: 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
@@ -5845,17 +5864,17 @@ darwin*)
     _HAVE_PTHREADS=1
     ;;
 wince*)
     _HAVE_PTHREADS=
     ;;
 *)
     
 echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:5854: checking for pthread_create in -lpthreads" >&5
+echo "configure:5873: 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);
         }
@@ -5867,17 +5886,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:5876: checking for pthread_create in -lpthread" >&5
+echo "configure:5895: 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);
         }
@@ -5889,17 +5908,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:5898: checking for pthread_create in -lc_r" >&5
+echo "configure:5917: 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);
         }
@@ -5911,17 +5930,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:5920: checking for pthread_create in -lc" >&5
+echo "configure:5939: 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);
         }
@@ -6029,17 +6048,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:6038: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:6057: 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
@@ -6052,17 +6071,17 @@ echo "configure:6038: 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:6061: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:6080: 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
@@ -17,16 +17,17 @@ MOD_MAJOR_VERSION=4
 MOD_MINOR_VERSION=10
 MOD_PATCH_VERSION=4
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
+USE_X32=
 USE_64=
 USE_CPLUS=
 USE_IPV6=
 USE_MDUPDATE=
 _MACOSX_DEPLOYMENT_TARGET=
 _OPTIMIZE_FLAGS=-O
 _DEBUG_FLAGS=-g
 MOZ_DEBUG=1
@@ -391,16 +392,25 @@ AC_ARG_ENABLE(n32,
     [  --enable-n32            Enable n32 ABI support (IRIX only)],
     [ if test "$enableval" = "yes"; then
 	USE_N32=1
       else if test "$enableval" = "no"; then
 	USE_N32=
       fi
     fi ])
 
+AC_ARG_ENABLE(x32,
+    [  --enable-x32            Enable x32 ABI support (x86_64 only)],
+    [ if test "$enableval" = "yes"; then
+        USE_X32=1
+      else if test "$enableval" = "no"; then
+        USE_X32=
+      fi
+    fi ])
+
 AC_ARG_ENABLE(64bit,
     [  --enable-64bit          Enable 64-bit support (on certain platforms)],
     [ if test "$enableval" = "yes"; then
 	    USE_64=1
       fi ])
 
 AC_ARG_ENABLE(mdupdate,
     [  --enable-mdupdate       Enable use of certain compilers' mdupdate feature],
@@ -1862,16 +1872,20 @@ tools are selected during the Xcode/Deve
         PR_MD_ASFILES=os_Linux_x86.s
         ;;
     ia64)
         PR_MD_ASFILES=os_Linux_ia64.s
         ;;
     x86_64)
         if test -n "$USE_64"; then
             PR_MD_ASFILES=os_Linux_x86_64.s
+        elif test -n "$USE_X32"; then
+            PR_MD_ASFILES=os_Linux_x86_64.s
+            CC="$CC -mx32"
+            CXX="$CXX -mx32"
         else
             AC_DEFINE(i386)
             PR_MD_ASFILES=os_Linux_x86.s
             CC="$CC -m32"
             CXX="$CXX -m32"
         fi
         ;;
     ppc|powerpc)
--- a/nsprpub/pr/include/md/_darwin.cfg
+++ b/nsprpub/pr/include/md/_darwin.cfg
@@ -15,17 +15,17 @@
 #ifdef __LITTLE_ENDIAN__
 #undef IS_BIG_ENDIAN
 #define  IS_LITTLE_ENDIAN 1
 #else
 #undef IS_LITTLE_ENDIAN
 #define  IS_BIG_ENDIAN 1
 #endif
 
-#ifdef __x86_64__
+#ifdef __LP64__
 #define IS_64
 #endif
 
 #ifndef HAVE_LONG_LONG
 #define	HAVE_LONG_LONG
 #endif
 #undef	HAVE_ALIGNED_DOUBLES
 #define	HAVE_ALIGNED_LONGLONGS 1
--- a/nsprpub/pr/include/md/_darwin.h
+++ b/nsprpub/pr/include/md/_darwin.h
@@ -21,16 +21,18 @@
 #ifdef __i386__
 #define _PR_SI_ARCHITECTURE "x86"
 #elif defined(__x86_64__)
 #define _PR_SI_ARCHITECTURE "x86-64"
 #elif defined(__ppc__)
 #define _PR_SI_ARCHITECTURE "ppc"
 #elif defined(__arm__)
 #define _PR_SI_ARCHITECTURE "arm"
+#elif defined(__aarch64__)
+#define _PR_SI_ARCHITECTURE "aarch64"
 #else
 #error "Unknown CPU architecture"
 #endif
 #define PR_DLL_SUFFIX		".dylib"
 
 #define _PR_VMBASE              0x30000000
 #define _PR_STACK_VMBASE	0x50000000
 #define _MD_DEFAULT_STACK_SIZE	65536L
@@ -117,31 +119,31 @@ extern PRInt32 _PR_Darwin_x86_64_AtomicI
 extern PRInt32 _PR_Darwin_x86_64_AtomicDecrement(PRInt32 *val);
 #define _MD_ATOMIC_DECREMENT(val)   _PR_Darwin_x86_64_AtomicDecrement(val)
 extern PRInt32 _PR_Darwin_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
 #define _MD_ATOMIC_SET(val, newval) _PR_Darwin_x86_64_AtomicSet(val, newval)
 extern PRInt32 _PR_Darwin_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
 #define _MD_ATOMIC_ADD(ptr, val)    _PR_Darwin_x86_64_AtomicAdd(ptr, val)
 #endif /* __x86_64__ */
 
-#ifdef __arm__
+#if defined(__arm__) || defined(__aarch64__)
 #define _PR_HAVE_ATOMIC_OPS
 #define _MD_INIT_ATOMIC()
 #define _MD_ATOMIC_INCREMENT(val)   OSAtomicIncrement32(val)
 #define _MD_ATOMIC_DECREMENT(val)   OSAtomicDecrement32(val)
 static inline PRInt32 _MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval)
 {
     PRInt32 oldval;
     do {
         oldval = *val;
     } while (!OSAtomicCompareAndSwap32(oldval, newval, val));
     return oldval;
 }
 #define _MD_ATOMIC_ADD(ptr, val)    OSAtomicAdd32(val, ptr)
-#endif /* __arm__ */
+#endif /* __arm__ || __aarch64__ */
 
 #define USE_SETJMP
 
 #if !defined(_PR_PTHREADS)
 
 #include <setjmp.h>
 
 #define PR_CONTEXT_TYPE	jmp_buf
--- a/nsprpub/pr/include/pratom.h
+++ b/nsprpub/pr/include/pratom.h
@@ -105,17 +105,17 @@ long __cdecl _InterlockedExchangeAdd(lon
            (defined(__ppc__) || defined(__i386__) || defined(__x86_64__))) || \
        (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))))
+           defined(__aarch64__) || defined(__alpha))))
 
 /*
  * Because the GCC manual warns that some processors may support
  * reduced functionality of __sync_lock_test_and_set, we test for the
  * processors that we believe support a full atomic exchange operation.
  */
 
 #define PR_ATOMIC_INCREMENT(val) __sync_add_and_fetch(val, 1)
--- a/nsprpub/pr/include/private/primpl.h
+++ b/nsprpub/pr/include/private/primpl.h
@@ -534,29 +534,34 @@ NSPR_API(void) _PR_PauseCPU(void);
 /************************************************************************/
 
 #define _PR_LOCK_LOCK(_lock) \
     _PR_MD_LOCK(&(_lock)->ilock);
 #define _PR_LOCK_UNLOCK(_lock) \
     _PR_MD_UNLOCK(&(_lock)->ilock);
     
 extern void _PR_UnblockLockWaiter(PRLock *lock);
+extern PRStatus _PR_InitLock(PRLock *lock);
+extern void _PR_FreeLock(PRLock *lock);
 
 #define _PR_LOCK_PTR(_qp) \
     ((PRLock*) ((char*) (_qp) - offsetof(PRLock,links)))
 
 /************************************************************************/
 
 #define _PR_CVAR_LOCK(_cvar) \
     _PR_MD_LOCK(&(_cvar)->ilock); 
 #define _PR_CVAR_UNLOCK(_cvar) \
     _PR_MD_UNLOCK(&(_cvar)->ilock);
 
+extern PRStatus _PR_InitCondVar(PRCondVar *cvar, PRLock *lock);
+extern void _PR_FreeCondVar(PRCondVar *cvar);
 extern PRStatus _PR_WaitCondVar(
     PRThread *thread, PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout);
+extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me);
 extern PRUint32 _PR_CondVarToString(PRCondVar *cvar, char *buf, PRUint32 buflen);
 
 NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky);
 
 /* PRThread.flags */
 #define _PR_SYSTEM          0x01
 #define _PR_INTERRUPT       0x02
 #define _PR_ATTACHED        0x04        /* created via PR_AttachThread */
@@ -1415,18 +1420,16 @@ struct PRLock {
     struct PRThread *owner;         /* current lock owner */
     PRCList waitQ;                  /* list of threads waiting for lock */
     PRThreadPriority priority;      /* priority of lock */ 
     PRThreadPriority boostPriority; /* boosted priority of lock owner */
     _MDLock ilock;                  /* Internal Lock to protect user-level fields */
 #endif
 };
 
-extern void _PR_InitLocks(void);
-
 struct PRCondVar {
     PRLock *lock;               /* associated lock that protects the condition */
 #if defined(_PR_PTHREADS)
     pthread_cond_t cv;          /* underlying pthreads condition */
     PRInt32 notify_pending;     /* CV has destroy pending notification */
 #elif defined(_PR_BTHREADS)
     sem_id    sem;              /* the underlying lock */
     sem_id    handshakeSem;     /* the lock for 'notify'-threads waiting for confirmation */
@@ -1441,20 +1444,16 @@ struct PRCondVar {
 #endif
 };
 
 /************************************************************************/
 
 struct PRMonitor {
     const char* name;           /* monitor name for debugging */
 #if defined(_PR_PTHREADS)
-    PRIntn notifyTimes;         /* number of pending notifies for waitCV.
-                                 * The special value -1 means a broadcast
-                                 * (PR_NotifyAll). */
-
     pthread_mutex_t lock;       /* lock is only held when accessing fields
                                  * of the PRMonitor, instead of being held
                                  * while the monitor is entered. The only
                                  * exception is notifyTimes, which is
                                  * protected by the monitor. */
     pthread_t owner;            /* the owner of the monitor or invalid */
     pthread_cond_t entryCV;     /* for threads waiting to enter the monitor */
 
@@ -1463,19 +1462,30 @@ struct PRMonitor {
                                  * PR_NewMonitor adds a reference to the
                                  * newly created PRMonitor, and
                                  * PR_DestroyMonitor releases that reference.
                                  * PR_ExitMonitor adds a reference before
                                  * unlocking the internal lock if it needs to
                                  * signal entryCV, and releases the reference
                                  * after signaling entryCV. */
 #else  /* defined(_PR_PTHREADS) */
-    PRCondVar *cvar;            /* associated lock and condition variable queue */
+    PRLock lock;                /* lock is only held when accessing fields
+                                 * of the PRMonitor, instead of being held
+                                 * while the monitor is entered. The only
+                                 * exception is notifyTimes, which is
+                                 * protected by the monitor. */
+    PRThread *owner;            /* the owner of the monitor or invalid */
+    PRCondVar entryCV;          /* for threads waiting to enter the monitor */
+
+    PRCondVar waitCV;           /* for threads waiting on the monitor */
 #endif /* defined(_PR_PTHREADS) */
     PRUint32 entryCount;        /* # of times re-entered */
+    PRIntn notifyTimes;         /* number of pending notifies for waitCV.
+                                 * The special value -1 means a broadcast
+                                 * (PR_NotifyAll). */
 };
 
 /************************************************************************/
 
 struct PRSemaphore {
 #if defined(_PR_BTHREADS)
     sem_id  sem;
     int32   benaphoreCount;
@@ -1485,18 +1495,16 @@ struct PRSemaphore {
     PRUint32 waiters;            /* threads waiting on the semaphore */
 #if defined(_PR_PTHREADS)
 #else  /* defined(_PR_PTHREADS) */
     _MDSemaphore md;
 #endif /* defined(_PR_PTHREADS) */
 #endif /* defined(_PR_BTHREADS) */
 };
 
-NSPR_API(void) _PR_InitSem(void);
-
 /*************************************************************************/
 
 struct PRSem {
 #ifdef _PR_HAVE_POSIX_SEMAPHORES
     sem_t *sem;
 #elif defined(_PR_HAVE_SYSV_SEMAPHORES)
     int semid;
 #elif defined(WIN32)
@@ -1760,16 +1768,17 @@ struct PRDir {
 
 #ifdef MOZ_UNICODE
 struct PRDirUTF16 { 
     PRDirEntry d; 
     _MDDirUTF16 md; 
 }; 
 #endif /* MOZ_UNICODE */
 
+extern void _PR_InitLocks(void);
 extern void _PR_InitSegs(void);
 extern void _PR_InitStacks(void);
 extern void _PR_InitTPD(void);
 extern void _PR_InitMem(void);
 extern void _PR_InitEnv(void);
 extern void _PR_InitCMon(void);
 extern void _PR_InitIO(void);
 extern void _PR_InitLog(void);
@@ -1777,17 +1786,16 @@ extern void _PR_InitNet(void);
 extern void _PR_InitClock(void);
 extern void _PR_InitLinker(void);
 extern void _PR_InitAtomic(void);
 extern void _PR_InitCPUs(void);
 extern void _PR_InitDtoa(void);
 extern void _PR_InitTime(void);
 extern void _PR_InitMW(void);
 extern void _PR_InitRWLocks(void);
-extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me);
 extern void _PR_CleanupThread(PRThread *thread);
 extern void _PR_CleanupCallOnce(void);
 extern void _PR_CleanupMW(void);
 extern void _PR_CleanupTime(void);
 extern void _PR_CleanupDtoa(void);
 extern void _PR_ShutdownLinker(void);
 extern void _PR_CleanupEnv(void);
 extern void _PR_CleanupIO(void);
--- a/nsprpub/pr/src/misc/prcountr.c
+++ b/nsprpub/pr/src/misc/prcountr.c
@@ -140,17 +140,17 @@ PR_IMPLEMENT(PRCounterHandle)
         qnp = (QName *) PR_LIST_HEAD( &qNameList );
         do {
             if ( strcmp(qnp->name, qName) == 0)
             {
                 matchQname = PR_TRUE;
                 break;
             }
             qnp = (QName *)PR_NEXT_LINK( &qnp->link );
-        } while( qnp != (QName *)PR_LIST_HEAD( &qNameList ));
+        } while( qnp != (QName *)&qNameList );
     }
     /*
     ** If we did not find a matching QName,
     **    allocate one and initialize it.
     **    link it onto the qNameList.
     **
     */
     if ( matchQname != PR_TRUE )
@@ -169,17 +169,17 @@ PR_IMPLEMENT(PRCounterHandle)
         rnp = (RName *) PR_LIST_HEAD( &qnp->rNameList );
         do {
             /*
             ** No duplicate RNames are allowed within a QName
             **
             */
             PR_ASSERT( strcmp(rnp->name, rName));
             rnp = (RName *)PR_NEXT_LINK( &rnp->link );
-        } while( rnp != (RName *)PR_LIST_HEAD( &qnp->rNameList ));
+        } while( rnp != (RName *)&qnp->rNameList );
     }
 
     /* Get a new RName structure; initialize its members */
     rnp = PR_NEWZAP( RName );
     PR_ASSERT( rnp != NULL );
     PR_INIT_CLIST( &rnp->link );
     strcpy( rnp->name, rName );
     strcpy( rnp->desc, description );
--- a/nsprpub/pr/src/misc/prnetdb.c
+++ b/nsprpub/pr/src/misc/prnetdb.c
@@ -2223,29 +2223,30 @@ PR_IMPLEMENT(PRStatus) PR_StringToNetAdd
     {
         PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
         return PR_FAILURE;
     }
 
 #if !defined(_PR_HAVE_GETADDRINFO)
     return pr_StringToNetAddrFB(string, addr);
 #else
-#if defined(_PR_INET6_PROBE)
-    if (!_pr_ipv6_is_present())
-        return pr_StringToNetAddrFB(string, addr);
-#endif
     /*
      * getaddrinfo with AI_NUMERICHOST is much slower than pr_inet_aton on some
      * platforms, such as Mac OS X (bug 404399), Linux glibc 2.10 (bug 344809),
      * and most likely others. So we only use it to convert literal IP addresses
      * that contain IPv6 scope IDs, which pr_inet_aton cannot convert.
      */
     if (!strchr(string, '%'))
         return pr_StringToNetAddrFB(string, addr);
 
+#if defined(_PR_INET6_PROBE)
+    if (!_pr_ipv6_is_present())
+        return pr_StringToNetAddrFB(string, addr);
+#endif
+
     return pr_StringToNetAddrGAI(string, addr);
 #endif
 }
 
 #if defined(_PR_HAVE_GETADDRINFO)
 static PRStatus pr_NetAddrToStringGNI(
     const PRNetAddr *addr, char *string, PRUint32 size)
 {
--- a/nsprpub/pr/src/misc/prtrace.c
+++ b/nsprpub/pr/src/misc/prtrace.c
@@ -217,17 +217,17 @@ PR_IMPLEMENT(PRTraceHandle)
         qnp = (QName *) PR_LIST_HEAD( &qNameList );
         do {
             if ( strcmp(qnp->name, qName) == 0)
             {
                 matchQname = PR_TRUE;
                 break;
             }
             qnp = (QName *)PR_NEXT_LINK( &qnp->link );
-        } while( qnp != (QName *)PR_LIST_HEAD( &qNameList ));
+        } while( qnp != (QName *)&qNameList );
     }
     /*
     ** If we did not find a matching QName,
     **    allocate one and initialize it.
     **    link it onto the qNameList.
     **
     */
     if ( matchQname != PR_TRUE )
@@ -246,17 +246,17 @@ PR_IMPLEMENT(PRTraceHandle)
         rnp = (RName *) PR_LIST_HEAD( &qnp->rNameList );
         do {
             /*
             ** No duplicate RNames are allowed within a QName
             **
             */
             PR_ASSERT( strcmp(rnp->name, rName));
             rnp = (RName *)PR_NEXT_LINK( &rnp->link );
-        } while( rnp != (RName *)PR_LIST_HEAD( &qnp->rNameList ));
+        } while( rnp != (RName *)&qnp->rNameList );
     }
 
     /* Get a new RName structure; initialize its members */
     rnp = PR_NEWZAP( RName );
     PR_ASSERT( rnp != NULL );
     PR_INIT_CLIST( &rnp->link );
     strcpy( rnp->name, rName );
     strcpy( rnp->desc, description );
--- a/nsprpub/pr/src/pthreads/ptio.c
+++ b/nsprpub/pr/src/pthreads/ptio.c
@@ -3395,46 +3395,42 @@ failed:
 }  /* PR_AllocFileDesc */
 
 #if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
 PR_EXTERN(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc *fd);
 #if defined(_PR_INET6_PROBE)
 extern PRBool _pr_ipv6_is_present(void);
 PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket()
 {
+    int osfd;
+
 #if defined(DARWIN)
     /*
      * Disable IPv6 if Darwin version is less than 7.0.0 (OS X 10.3).  IPv6 on
      * lesser versions is not ready for general use (see bug 222031).
      */
     {
         struct utsname u;
         if (uname(&u) != 0 || atoi(u.release) < 7)
             return PR_FALSE;
     }
 #endif
 
-#if defined(LINUX)
-    /* If /proc/net/if_inet6 exists, the Linux kernel supports IPv6. */
-    int rv = access("/proc/net/if_inet6", F_OK);
-    return (rv == 0);
-#else
     /*
      * HP-UX only: HP-UX IPv6 Porting Guide (dated February 2001)
      * suggests that we call open("/dev/ip6", O_RDWR) to determine
      * whether IPv6 APIs and the IPv6 stack are on the system.
      * Our portable test below seems to work fine, so I am using it.
      */
-    PRInt32 osfd = socket(AF_INET6, SOCK_STREAM, 0);
+    osfd = socket(AF_INET6, SOCK_STREAM, 0);
     if (osfd != -1) {
         close(osfd);
         return PR_TRUE;
     }
     return PR_FALSE;
-#endif
 }
 #endif	/* _PR_INET6_PROBE */
 #endif
 
 PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto)
 {
     PRIntn osfd;
     PRDescType ftype;
--- a/nsprpub/pr/src/pthreads/ptsynch.c
+++ b/nsprpub/pr/src/pthreads/ptsynch.c
@@ -424,21 +424,22 @@ PR_IMPLEMENT(PRStatus) PR_NotifyAllCondV
 /**************************************************************/
 /**************************************************************/
 /***************************MONITORS***************************/
 /**************************************************************/
 /**************************************************************/
 
 /*
  * Notifies just get posted to the monitor. The actual notification is done
- * when the monitor is exited so that MP systems don't contend for a monitor
- * that they can't enter.
+ * when the monitor is fully exited so that MP systems don't contend for a
+ * monitor that they can't enter.
  */
 static void pt_PostNotifyToMonitor(PRMonitor *mon, PRBool broadcast)
 {
+    PR_ASSERT(NULL != mon);
     PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mon);
 
     /* mon->notifyTimes is protected by the monitor, so we don't need to
      * acquire mon->lock.
      */
     if (broadcast)
         mon->notifyTimes = -1;
     else if (-1 != mon->notifyTimes)
@@ -499,16 +500,17 @@ PR_IMPLEMENT(PRMonitor*) PR_NewMonitor(v
     rv = _PT_PTHREAD_COND_INIT(mon->waitCV, _pt_cvar_attr);
     PR_ASSERT(0 == rv);
     if (0 != rv)
         goto error3;
 
     mon->notifyTimes = 0;
     mon->entryCount = 0;
     mon->refCount = 1;
+    mon->name = NULL;
     return mon;
 
 error3:
     pthread_cond_destroy(&mon->entryCV);
 error2:
     pthread_mutex_destroy(&mon->lock);
 error1:
     PR_Free(mon);
@@ -648,17 +650,17 @@ PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PR
         PR_DestroyMonitor(mon);
     }
     return PR_SUCCESS;
 }  /* PR_ExitMonitor */
 
 PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime timeout)
 {
     PRStatus rv;
-    PRInt16 saved_entries;
+    PRUint32 saved_entries;
     pthread_t saved_owner;
 
     PR_ASSERT(mon != NULL);
     rv = pthread_mutex_lock(&mon->lock);
     PR_ASSERT(0 == rv);
     /* the entries better be positive */
     PR_ASSERT(mon->entryCount > 0);
     /* and it better be owned by us */
@@ -703,24 +705,22 @@ PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor
 
     rv = pthread_mutex_unlock(&mon->lock);
     PR_ASSERT(0 == rv);
     return rv;
 }  /* PR_Wait */
 
 PR_IMPLEMENT(PRStatus) PR_Notify(PRMonitor *mon)
 {
-    PR_ASSERT(NULL != mon);
     pt_PostNotifyToMonitor(mon, PR_FALSE);
     return PR_SUCCESS;
 }  /* PR_Notify */
 
 PR_IMPLEMENT(PRStatus) PR_NotifyAll(PRMonitor *mon)
 {
-    PR_ASSERT(NULL != mon);
     pt_PostNotifyToMonitor(mon, PR_TRUE);
     return PR_SUCCESS;
 }  /* PR_NotifyAll */
 
 /**************************************************************/
 /**************************************************************/
 /**************************SEMAPHORES**************************/
 /**************************************************************/
--- a/nsprpub/pr/src/threads/combined/prucv.c
+++ b/nsprpub/pr/src/threads/combined/prucv.c
@@ -441,57 +441,67 @@ void _PR_ClockInterrupt(void)
 **
 ** This may fail if memory is tight or if some operating system resource
 ** is low.
 */
 PR_IMPLEMENT(PRCondVar*) PR_NewCondVar(PRLock *lock)
 {
     PRCondVar *cvar;
 
-    PR_ASSERT(lock != NULL);
-
     cvar = PR_NEWZAP(PRCondVar);
     if (cvar) {
-#ifdef _PR_GLOBAL_THREADS_ONLY
-	if(_PR_MD_NEW_CV(&cvar->md)) {
-		PR_DELETE(cvar);
-		PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
-		return NULL;
-	}
-#endif
-        if (_PR_MD_NEW_LOCK(&(cvar->ilock)) == PR_FAILURE) {
-		PR_DELETE(cvar);
-		PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
-		return NULL;
-	}
-    cvar->lock = lock;
-	PR_INIT_CLIST(&cvar->condQ);
-
+        if (_PR_InitCondVar(cvar, lock) != PR_SUCCESS) {
+            PR_DELETE(cvar);
+            return NULL;
+        }
     } else {
         PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
     }
     return cvar;
 }
 
+PRStatus _PR_InitCondVar(PRCondVar *cvar, PRLock *lock)
+{
+    PR_ASSERT(lock != NULL);
+
+#ifdef _PR_GLOBAL_THREADS_ONLY
+    if(_PR_MD_NEW_CV(&cvar->md)) {
+        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
+        return PR_FAILURE;
+    }
+#endif
+    if (_PR_MD_NEW_LOCK(&(cvar->ilock)) != PR_SUCCESS) {
+        PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
+        return PR_FAILURE;
+    }
+    cvar->lock = lock;
+    PR_INIT_CLIST(&cvar->condQ);
+    return PR_SUCCESS;
+}
+
 /*
 ** Destroy a condition variable. There must be no thread
 ** waiting on the condvar. The caller is responsible for guaranteeing
 ** that the condvar is no longer in use.
 **
 */
 PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar *cvar)
 {
+    _PR_FreeCondVar(cvar);
+    PR_DELETE(cvar);
+}
+
+void _PR_FreeCondVar(PRCondVar *cvar)
+{
     PR_ASSERT(cvar->condQ.next == &cvar->condQ);
 
 #ifdef _PR_GLOBAL_THREADS_ONLY
     _PR_MD_FREE_CV(&cvar->md);
 #endif
     _PR_MD_FREE_LOCK(&(cvar->ilock));
- 
-    PR_DELETE(cvar);
 }
 
 /*
 ** Wait for a notify on the condition variable. Sleep for "tiemout" amount
 ** of ticks (if "timeout" is zero then the sleep is indefinite). While
 ** the thread is waiting it unlocks lock. When the wait has
 ** finished the thread regains control of the condition variable after
 ** locking the associated lock.
--- a/nsprpub/pr/src/threads/combined/prulock.c
+++ b/nsprpub/pr/src/threads/combined/prulock.c
@@ -155,36 +155,49 @@ void _PR_UnblockLockWaiter(PRLock *lock)
 PR_IMPLEMENT(PRLock*) PR_NewLock(void)
 {
     PRLock *lock;
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     lock = PR_NEWZAP(PRLock);
     if (lock) {
-        if (_PR_MD_NEW_LOCK(&lock->ilock) == PR_FAILURE) {
-		PR_DELETE(lock);
-		return(NULL);
-	}
-        PR_INIT_CLIST(&lock->links);
-        PR_INIT_CLIST(&lock->waitQ);
+        if (_PR_InitLock(lock) != PR_SUCCESS) {
+            PR_DELETE(lock);
+            return NULL;
+        }
     }
     return lock;
 }
 
+PRStatus _PR_InitLock(PRLock *lock)
+{
+    if (_PR_MD_NEW_LOCK(&lock->ilock) != PR_SUCCESS) {
+        return PR_FAILURE;
+    }
+    PR_INIT_CLIST(&lock->links);
+    PR_INIT_CLIST(&lock->waitQ);
+    return PR_SUCCESS;
+}
+
 /*
 ** Destroy the given lock "lock". There is no point in making this race
 ** free because if some other thread has the pointer to this lock all
 ** bets are off.
 */
 PR_IMPLEMENT(void) PR_DestroyLock(PRLock *lock)
 {
+    _PR_FreeLock(lock);
+    PR_DELETE(lock);
+}
+
+void _PR_FreeLock(PRLock *lock)
+{
     PR_ASSERT(lock->owner == 0);
-	_PR_MD_FREE_LOCK(&lock->ilock);
-    PR_DELETE(lock);
+    _PR_MD_FREE_LOCK(&lock->ilock);
 }
 
 extern PRThread *suspendAllThread;
 /*
 ** Lock the lock.
 */
 PR_IMPLEMENT(void) PR_Lock(PRLock *lock)
 {
--- a/nsprpub/pr/src/threads/prmon.c
+++ b/nsprpub/pr/src/threads/prmon.c
@@ -3,42 +3,100 @@
  * 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 "primpl.h"
 
 /************************************************************************/
 
 /*
+ * Notifies just get posted to the monitor. The actual notification is done
+ * when the monitor is fully exited so that MP systems don't contend for a
+ * monitor that they can't enter.
+ */
+static void _PR_PostNotifyToMonitor(PRMonitor *mon, PRBool broadcast)
+{
+    PR_ASSERT(mon != NULL);
+    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mon);
+
+    /* mon->notifyTimes is protected by the monitor, so we don't need to
+     * acquire mon->lock.
+     */
+    if (broadcast)
+        mon->notifyTimes = -1;
+    else if (mon->notifyTimes != -1)
+        mon->notifyTimes += 1;
+}
+
+static void _PR_PostNotifiesFromMonitor(PRCondVar *cv, PRIntn times)
+{
+    PRStatus rv;
+
+    /*
+     * Time to actually notify any waits that were affected while the monitor
+     * was entered.
+     */
+    PR_ASSERT(cv != NULL);
+    PR_ASSERT(times != 0);
+    if (times == -1) {
+        rv = PR_NotifyAllCondVar(cv);
+        PR_ASSERT(rv == PR_SUCCESS);
+    } else {
+        while (times-- > 0) {
+            rv = PR_NotifyCondVar(cv);
+            PR_ASSERT(rv == PR_SUCCESS);
+        }
+    }
+}
+
+/*
 ** Create a new monitor.
 */
 PR_IMPLEMENT(PRMonitor*) PR_NewMonitor()
 {
     PRMonitor *mon;
-	PRCondVar *cvar;
-	PRLock *lock;
+    PRStatus rv;
+
+    if (!_pr_initialized) _PR_ImplicitInitialization();
 
     mon = PR_NEWZAP(PRMonitor);
-    if (mon) {
-		lock = PR_NewLock();
-	    if (!lock) {
-			PR_DELETE(mon);
-			return 0;
-    	}
+    if (mon == NULL) {
+        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
+        return NULL;
+    }
+
+    rv = _PR_InitLock(&mon->lock);
+    PR_ASSERT(rv == PR_SUCCESS);
+    if (rv != PR_SUCCESS)
+        goto error1;
+
+    mon->owner = NULL;
+
+    rv = _PR_InitCondVar(&mon->entryCV, &mon->lock);
+    PR_ASSERT(rv == PR_SUCCESS);
+    if (rv != PR_SUCCESS)
+        goto error2;
 
-	    cvar = PR_NewCondVar(lock);
-	    if (!cvar) {
-	    	PR_DestroyLock(lock);
-			PR_DELETE(mon);
-			return 0;
-    	}
-    	mon->cvar = cvar;
-	mon->name = NULL;
-    }
+    rv = _PR_InitCondVar(&mon->waitCV, &mon->lock);
+    PR_ASSERT(rv == PR_SUCCESS);
+    if (rv != PR_SUCCESS)
+        goto error3;
+
+    mon->notifyTimes = 0;
+    mon->entryCount = 0;
+    mon->name = NULL;
     return mon;
+
+error3:
+    _PR_FreeCondVar(&mon->entryCV);
+error2:
+    _PR_FreeLock(&mon->lock);
+error1:
+    PR_Free(mon);
+    return NULL;
 }
 
 PR_IMPLEMENT(PRMonitor*) PR_NewNamedMonitor(const char* name)
 {
     PRMonitor* mon = PR_NewMonitor();
     if (mon)
         mon->name = name;
     return mon;
@@ -46,154 +104,243 @@ PR_IMPLEMENT(PRMonitor*) PR_NewNamedMoni
 
 /*
 ** Destroy a monitor. There must be no thread waiting on the monitor's
 ** condition variable. The caller is responsible for guaranteeing that the
 ** monitor is no longer in use.
 */
 PR_IMPLEMENT(void) PR_DestroyMonitor(PRMonitor *mon)
 {
-	PR_DestroyLock(mon->cvar->lock);
-    PR_DestroyCondVar(mon->cvar);
-    PR_DELETE(mon);
+    PR_ASSERT(mon != NULL);
+    _PR_FreeCondVar(&mon->waitCV);
+    _PR_FreeCondVar(&mon->entryCV);
+    _PR_FreeLock(&mon->lock);
+#if defined(DEBUG)
+    memset(mon, 0xaf, sizeof(PRMonitor));
+#endif
+    PR_Free(mon);
 }
 
 /*
 ** Enter the lock associated with the monitor.
 */
 PR_IMPLEMENT(void) PR_EnterMonitor(PRMonitor *mon)
 {
-    if (mon->cvar->lock->owner == _PR_MD_CURRENT_THREAD()) {
-		mon->entryCount++;
-    } else {
-		PR_Lock(mon->cvar->lock);
-		mon->entryCount = 1;
+    PRThread *me = _PR_MD_CURRENT_THREAD();
+    PRStatus rv;
+
+    PR_ASSERT(mon != NULL);
+    PR_Lock(&mon->lock);
+    if (mon->entryCount != 0) {
+        if (mon->owner == me)
+            goto done;
+        while (mon->entryCount != 0) {
+            rv = PR_WaitCondVar(&mon->entryCV, PR_INTERVAL_NO_TIMEOUT);
+            PR_ASSERT(rv == PR_SUCCESS);
+        }
     }
+    /* and now I have the monitor */
+    PR_ASSERT(mon->notifyTimes == 0);
+    PR_ASSERT(mon->owner == NULL);
+    mon->owner = me;
+
+done:
+    mon->entryCount += 1;
+    rv = PR_Unlock(&mon->lock);
+    PR_ASSERT(rv == PR_SUCCESS);
 }
 
 /*
 ** Test and then enter the lock associated with the monitor if it's not
 ** already entered by some other thread. Return PR_FALSE if some other
 ** thread owned the lock at the time of the call.
 */
 PR_IMPLEMENT(PRBool) PR_TestAndEnterMonitor(PRMonitor *mon)
 {
-    if (mon->cvar->lock->owner == _PR_MD_CURRENT_THREAD()) {
-		mon->entryCount++;
-		return PR_TRUE;
-    } else {
-		if (PR_TestAndLock(mon->cvar->lock)) {
-	    	mon->entryCount = 1;
-	   	 	return PR_TRUE;
-		}
+    PRThread *me = _PR_MD_CURRENT_THREAD();
+    PRStatus rv;
+
+    PR_ASSERT(mon != NULL);
+    PR_Lock(&mon->lock);
+    if (mon->entryCount != 0) {
+        if (mon->owner == me)
+            goto done;
+        rv = PR_Unlock(&mon->lock);
+        PR_ASSERT(rv == PR_SUCCESS);
+        return PR_FALSE;
     }
-    return PR_FALSE;
+    /* and now I have the monitor */
+    PR_ASSERT(mon->notifyTimes == 0);
+    PR_ASSERT(mon->owner == NULL);
+    mon->owner = me;
+
+done:
+    mon->entryCount += 1;
+    rv = PR_Unlock(&mon->lock);
+    PR_ASSERT(rv == PR_SUCCESS);
+    return PR_TRUE;
 }
 
 /*
 ** Exit the lock associated with the monitor once.
 */
 PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PRMonitor *mon)
 {
-    if (mon->cvar->lock->owner != _PR_MD_CURRENT_THREAD()) {
+    PRThread *me = _PR_MD_CURRENT_THREAD();
+    PRStatus rv;
+
+    PR_ASSERT(mon != NULL);
+    PR_Lock(&mon->lock);
+    /* the entries should be > 0 and we'd better be the owner */
+    PR_ASSERT(mon->entryCount > 0);
+    PR_ASSERT(mon->owner == me);
+    if (mon->entryCount == 0 || mon->owner != me)
+    {
+        rv = PR_Unlock(&mon->lock);
+        PR_ASSERT(rv == PR_SUCCESS);
         return PR_FAILURE;
     }
-    if (--mon->entryCount == 0) {
-		return PR_Unlock(mon->cvar->lock);
+
+    mon->entryCount -= 1;  /* reduce by one */
+    if (mon->entryCount == 0)
+    {
+        /* and if it transitioned to zero - notify an entry waiter */
+        /* make the owner unknown */
+        mon->owner = NULL;
+        if (mon->notifyTimes != 0) {
+            _PR_PostNotifiesFromMonitor(&mon->waitCV, mon->notifyTimes);
+            mon->notifyTimes = 0;
+        }
+        rv = PR_NotifyCondVar(&mon->entryCV);
+        PR_ASSERT(rv == PR_SUCCESS);
     }
+    rv = PR_Unlock(&mon->lock);
+    PR_ASSERT(rv == PR_SUCCESS);
     return PR_SUCCESS;
 }
 
 /*
 ** Return the number of times that the current thread has entered the
 ** lock. Returns zero if the current thread has not entered the lock.
 */
 PR_IMPLEMENT(PRIntn) PR_GetMonitorEntryCount(PRMonitor *mon)
 {
-    return (mon->cvar->lock->owner == _PR_MD_CURRENT_THREAD()) ?
-        mon->entryCount : 0;
+    PRThread *me = _PR_MD_CURRENT_THREAD();
+    PRStatus rv;
+    PRIntn count = 0;
+
+    PR_Lock(&mon->lock);
+    if (mon->owner == me)
+        count = mon->entryCount;
+    rv = PR_Unlock(&mon->lock);
+    PR_ASSERT(rv == PR_SUCCESS);
+    return count;
 }
 
-/*
-** If the current thread is in |mon|, this assertion is guaranteed to
-** succeed.  Otherwise, the behavior of this function is undefined.
-*/
 PR_IMPLEMENT(void) PR_AssertCurrentThreadInMonitor(PRMonitor *mon)
 {
-    PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(mon->cvar->lock);
+#if defined(DEBUG) || defined(FORCE_PR_ASSERT)
+    PRStatus rv;
+
+    PR_Lock(&mon->lock);
+    PR_ASSERT(mon->entryCount != 0 &&
+              mon->owner == _PR_MD_CURRENT_THREAD());
+    rv = PR_Unlock(&mon->lock);
+    PR_ASSERT(rv == PR_SUCCESS);
+#endif
 }
 
 /*
 ** Wait for a notify on the condition variable. Sleep for "ticks" amount
 ** of time (if "tick" is 0 then the sleep is indefinite). While
 ** the thread is waiting it exits the monitors lock (as if it called
 ** PR_ExitMonitor as many times as it had called PR_EnterMonitor).  When
 ** the wait has finished the thread regains control of the monitors lock
 ** with the same entry count as before the wait began.
 **
 ** The thread waiting on the monitor will be resumed when the monitor is
 ** notified (assuming the thread is the next in line to receive the
 ** notify) or when the "ticks" elapses.
 **
 ** Returns PR_FAILURE if the caller has not locked the lock associated
 ** with the condition variable.
-** This routine can return PR_PENDING_INTERRUPT if the waiting thread 
+** This routine can return PR_PENDING_INTERRUPT_ERROR if the waiting thread
 ** has been interrupted.
 */
 PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime ticks)
 {
-    PRUintn entryCount;
-	PRStatus status;
-    PRThread *me = _PR_MD_CURRENT_THREAD();
+    PRStatus rv;
+    PRUint32 saved_entries;
+    PRThread *saved_owner;
 
-    if (mon->cvar->lock->owner != me) return PR_FAILURE;
+    PR_ASSERT(mon != NULL);
+    PR_Lock(&mon->lock);
+    /* the entries better be positive */
+    PR_ASSERT(mon->entryCount > 0);
+    /* and it better be owned by us */
+    PR_ASSERT(mon->owner == _PR_MD_CURRENT_THREAD());  /* XXX return failure */
 
-    entryCount = mon->entryCount;
+    /* tuck these away 'till later */
+    saved_entries = mon->entryCount;
     mon->entryCount = 0;
+    saved_owner = mon->owner;
+    mon->owner = NULL;
+    /* If we have pending notifies, post them now. */
+    if (mon->notifyTimes != 0) {
+        _PR_PostNotifiesFromMonitor(&mon->waitCV, mon->notifyTimes);
+        mon->notifyTimes = 0;
+    }
+    rv = PR_NotifyCondVar(&mon->entryCV);
+    PR_ASSERT(rv == PR_SUCCESS);
 
-	status = _PR_WaitCondVar(me, mon->cvar, mon->cvar->lock, ticks);
+    rv = PR_WaitCondVar(&mon->waitCV, ticks);
+    PR_ASSERT(rv == PR_SUCCESS);
 
-    mon->entryCount = entryCount;
+    while (mon->entryCount != 0) {
+        rv = PR_WaitCondVar(&mon->entryCV, PR_INTERVAL_NO_TIMEOUT);
+        PR_ASSERT(rv == PR_SUCCESS);
+    }
+    PR_ASSERT(mon->notifyTimes == 0);
+    /* reinstate the interesting information */
+    mon->entryCount = saved_entries;
+    mon->owner = saved_owner;
 
-    return status;
+    rv = PR_Unlock(&mon->lock);
+    PR_ASSERT(rv == PR_SUCCESS);
+    return rv;
 }
 
 /*
 ** Notify the highest priority thread waiting on the condition
 ** variable. If a thread is waiting on the condition variable (using
 ** PR_Wait) then it is awakened and begins waiting on the monitor's lock.
 */
 PR_IMPLEMENT(PRStatus) PR_Notify(PRMonitor *mon)
 {
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-    if (mon->cvar->lock->owner != me) return PR_FAILURE;
-    PR_NotifyCondVar(mon->cvar);
+    _PR_PostNotifyToMonitor(mon, PR_FALSE);
     return PR_SUCCESS;
 }
 
 /*
 ** Notify all of the threads waiting on the condition variable. All of
 ** threads are notified in turn. The highest priority thread will
 ** probably acquire the monitor first when the monitor is exited.
 */
 PR_IMPLEMENT(PRStatus) PR_NotifyAll(PRMonitor *mon)
 {
-    PRThread *me = _PR_MD_CURRENT_THREAD();
-    if (mon->cvar->lock->owner != me) return PR_FAILURE;
-    PR_NotifyAllCondVar(mon->cvar);
+    _PR_PostNotifyToMonitor(mon, PR_TRUE);
     return PR_SUCCESS;
 }
 
 /************************************************************************/
 
 PRUint32 _PR_MonitorToString(PRMonitor *mon, char *buf, PRUint32 buflen)
 {
     PRUint32 nb;
 
-    if (mon->cvar->lock->owner) {
+    if (mon->owner) {
 	nb = PR_snprintf(buf, buflen, "[%p] owner=%d[%p] count=%ld",
-			 mon, mon->cvar->lock->owner->id,
-			 mon->cvar->lock->owner, mon->entryCount);
+			 mon, mon->owner->id, mon->owner, mon->entryCount);
     } else {
 	nb = PR_snprintf(buf, buflen, "[%p]", mon);
     }
     return nb;
 }
--- a/nsprpub/pr/tests/instrumt.c
+++ b/nsprpub/pr/tests/instrumt.c
@@ -88,17 +88,17 @@ static void ListCounters(void)
     PR_FIND_NEXT_COUNTER_QNAME(qh, qh );
     while ( qh != NULL )
     {
         PR_INIT_COUNTER_HANDLE( rh, NULL );
         PR_FIND_NEXT_COUNTER_RNAME(rh, rh, qh );
         while ( rh != NULL )
         {
             PR_GET_COUNTER_NAME_FROM_HANDLE( rh, qname, rname, desc );
-            tCtr = PR_GET_COUNTER(tCtr, rh);
+            PR_GET_COUNTER(tCtr, rh);
             PR_LOG( lm, msgLevel,
                 ( "QName: %s  RName: %s  Desc: %s  Value: %ld\n", 
                 qn, rn, dn, tCtr ));
             PR_FIND_NEXT_COUNTER_RNAME(rh, rh, qh );
         } 
         PR_FIND_NEXT_COUNTER_QNAME(qh, qh);
     }
     return;