Bug 598036 - update nspr to NSPR_HEAD_20101015 a=beltzner
authorMichael Wu <mwu@mozilla.com>
Fri, 15 Oct 2010 11:38:02 -0700
changeset 55920 38cf9ade344b6a26ee1e8902168f958912fae69a
parent 55919 e3cdf1619342ae514900bd41db1c2d7582b4dc91
child 55921 1025790e0c072e738da9d37547537f4ee8ca977a
push idunknown
push userunknown
push dateunknown
reviewersbeltzner
bugs598036
milestone2.0b8pre
Bug 598036 - update nspr to NSPR_HEAD_20101015 a=beltzner
nsprpub/Makefile.in
nsprpub/TAG-INFO
nsprpub/aclocal.m4
nsprpub/admin/repackage.sh
nsprpub/build/autoconf/acwinpaths.m4
nsprpub/config/autoconf.mk.in
nsprpub/config/prdepend.h
nsprpub/configure
nsprpub/configure.in
nsprpub/lib/prstreams/Makefile.in
nsprpub/lib/prstreams/prstrms.cpp
nsprpub/lib/prstreams/prstrms.h
nsprpub/lib/prstreams/tests/testprstrm/testprstrm.cpp
nsprpub/lib/tests/Makefile.in
nsprpub/pr/include/prinit.h
nsprpub/pr/include/private/primpl.h
nsprpub/pr/include/prvrsion.h
nsprpub/pr/src/Makefile.in
nsprpub/pr/src/cplus/rcthread.cpp
nsprpub/pr/src/io/prlog.c
nsprpub/pr/src/linking/prlink.c
nsprpub/pr/src/md/windows/ntmisc.c
nsprpub/pr/src/memory/Makefile.in
nsprpub/pr/src/memory/prgcleak.c
nsprpub/pr/src/misc/prdtoa.c
nsprpub/pr/src/misc/prinit.c
nsprpub/pr/src/misc/prthinfo.c
nsprpub/pr/src/pthreads/ptio.c
nsprpub/pr/src/pthreads/ptthread.c
nsprpub/pr/src/threads/combined/prucpu.c
nsprpub/pr/src/threads/combined/pruthr.c
nsprpub/pr/tests/Makefile.in
nsprpub/pr/tests/op_filok.c
nsprpub/pr/tests/poll_er.c
nsprpub/pr/tests/selct_er.c
nsprpub/pr/tests/suspend.c
nsprpub/pr/tests/vercheck.c
--- a/nsprpub/Makefile.in
+++ b/nsprpub/Makefile.in
@@ -40,18 +40,16 @@
 
 MOD_DEPTH	= .
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(MOD_DEPTH)/config/autoconf.mk
 
-MAKE := $(patsubst -j%,,$(MAKE)) -j1
-
 DIRS = config pr lib
 
 ifdef MOZILLA_CLIENT
 # Make nsinstall use absolute symlinks by default for Mozilla OSX builds
 # http://bugzilla.mozilla.org/show_bug.cgi?id=193164
 ifeq ($(OS_ARCH),Darwin)
 ifndef NSDISTMODE
 NSDISTMODE=absolute_symlink
--- a/nsprpub/TAG-INFO
+++ b/nsprpub/TAG-INFO
@@ -1,1 +1,1 @@
-NSPR_4_8_6_BETA3
+NSPR_HEAD_20101015
new file mode 100644
--- /dev/null
+++ b/nsprpub/aclocal.m4
@@ -0,0 +1,6 @@
+dnl
+dnl Local autoconf macros used with Mozilla.
+dnl The contents of this file are under the Public Domain.
+dnl 
+
+builtin(include, build/autoconf/acwinpaths.m4)
--- a/nsprpub/admin/repackage.sh
+++ b/nsprpub/admin/repackage.sh
@@ -59,20 +59,20 @@
 # Note! Files written with Gnu tar are not readable by some non-Gnu
 # versions. Sun, in particular.
 # 
 # 
 # 
 # 
 # ------------------------------------------------------------------
 
-FROMTOP=/share/builds/components/nspr20/v4.8.6
-TOTOP=./v4.8.6
-NSPRDIR=nspr-4.8.6
-SOURCETAG=NSPR_4_8_6_RTM
+FROMTOP=/share/builds/components/nspr20/v4.8.7
+TOTOP=./v4.8.7
+NSPRDIR=nspr-4.8.7
+SOURCETAG=NSPR_4_8_7_RTM
 
 #
 # enumerate Unix object directories on /s/b/c
 UNIX_OBJDIRS="
 HP-UXB.11.11_64_DBG.OBJ
 HP-UXB.11.11_64_OPT.OBJ
 HP-UXB.11.11_DBG.OBJ
 HP-UXB.11.11_OPT.OBJ
new file mode 100644
--- /dev/null
+++ b/nsprpub/build/autoconf/acwinpaths.m4
@@ -0,0 +1,65 @@
+dnl ***** BEGIN LICENSE BLOCK *****
+dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1
+dnl
+dnl The contents of this file are subject to the Mozilla Public License Version
+dnl 1.1 (the "License"); you may not use this file except in compliance with
+dnl the License. You may obtain a copy of the License at
+dnl http://www.mozilla.org/MPL/
+dnl
+dnl Software distributed under the License is distributed on an "AS IS" basis,
+dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+dnl for the specific language governing rights and limitations under the
+dnl License.
+dnl
+dnl The Original Code is mozilla.org code.
+dnl
+dnl The Initial Developer of the Original Code is the
+dnl Mozilla Foundation <http://www.mozilla.org>
+dnl
+dnl Portions created by the Initial Developer are Copyright (C) 2009
+dnl the Initial Developer. All Rights Reserved.
+dnl
+dnl Contributor(s):
+dnl   Benjamin Smedberg <benjamin@smedbergs.us>
+dnl
+dnl Alternatively, the contents of this file may be used under the terms of
+dnl either of the GNU General Public License Version 2 or later (the "GPL"),
+dnl or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+dnl in which case the provisions of the GPL or the LGPL are applicable instead
+dnl of those above. If you wish to allow use of your version of this file only
+dnl under the terms of either the GPL or the LGPL, and not to allow others to
+dnl use your version of this file under the terms of the MPL, indicate your
+dnl decision by deleting the provisions above and replace them with the notice
+dnl and other provisions required by the GPL or the LGPL. If you do not delete
+dnl the provisions above, a recipient may use your version of this file under
+dnl the terms of any one of the MPL, the GPL or the LGPL.
+dnl
+dnl ***** END LICENSE BLOCK *****
+
+define(GENERATE_SUB_ABS, [
+define([AC_OUTPUT_FILES_SUB1], [
+patsubst($@, [/\*)], [/* | ?:/*)])
+])
+])
+GENERATE_SUB_ABS(defn([AC_OUTPUT_FILES]))
+
+define(GENERATE_SUB_NOSPLIT, [
+define([AC_OUTPUT_FILES], [
+patsubst($@, [-e "s%:% \$ac_given_srcdir/%g"], [])
+])
+])
+GENERATE_SUB_NOSPLIT(defn([AC_OUTPUT_FILES_SUB1]))
+
+define(GENERATE_HEADER_NOSPLIT, [
+define([AC_OUTPUT_HEADER], [
+patsubst($@, [-e "s%:% \$ac_given_srcdir/%g"], [])
+])
+])
+GENERATE_HEADER_NOSPLIT(defn([AC_OUTPUT_HEADER]))
+
+define(GENERATE_SUBDIRS_ABS, [
+define([AC_OUTPUT_SUBDIRS], [
+patsubst($@, [/\*)], [/* | ?:/*)])
+])
+])
+GENERATE_SUBDIRS_ABS(defn([AC_OUTPUT_SUBDIRS]))
--- a/nsprpub/config/autoconf.mk.in
+++ b/nsprpub/config/autoconf.mk.in
@@ -39,17 +39,16 @@ CROSS_COMPILE	= @CROSS_COMPILE@
 MOZ_OPTIMIZE	= @MOZ_OPTIMIZE@
 MOZ_DEBUG	= @MOZ_DEBUG@
 MOZ_DEBUG_SYMBOLS = @MOZ_DEBUG_SYMBOLS@
 
 USE_CPLUS	= @USE_CPLUS@
 USE_IPV6	= @USE_IPV6@
 USE_N32		= @USE_N32@
 USE_64		= @USE_64@
-GC_LEAK_DETECTOR = @GC_LEAK_DETECTOR@
 ENABLE_STRIP	= @ENABLE_STRIP@
 
 USE_PTHREADS	= @USE_PTHREADS@
 USE_BTHREADS	= @USE_BTHREADS@
 PTHREADS_USER	= @USE_USER_PTHREADS@
 CLASSIC_NSPR	= @USE_NSPR_THREADS@
 
 AS		= @AS@
--- a/nsprpub/config/prdepend.h
+++ b/nsprpub/config/prdepend.h
@@ -37,8 +37,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
@@ -67,31 +67,32 @@ ac_help="$ac_help
 ac_help="$ac_help
   --disable-os2-high-mem  Disable high-memory support on OS/2"
 ac_help="$ac_help
   --enable-thumb2              Enable Thumb2 instruction set"
 ac_help="$ac_help
   --with-symbian-sdk=SYMBIAN_SDK_DIR
                           The path to the Symbian SDK"
 ac_help="$ac_help
+  --with-ccache[=path/to/ccache]
+                          Enable compiling with ccache"
+ac_help="$ac_help
   --enable-strip          Enable stripping of shared libs and programs"
 ac_help="$ac_help
   --with-pthreads         Use system pthreads library as thread subsystem"
 ac_help="$ac_help
   --enable-user-pthreads  Build using userland pthreads"
 ac_help="$ac_help
   --enable-nspr-threads   Build using classic nspr threads"
 ac_help="$ac_help
   --with-bthreads         Use system bthreads library as thread subsystem
                           (BeOS only)"
 ac_help="$ac_help
   --enable-ipv6           Compile ipv6 support"
 ac_help="$ac_help
-  --enable-boehm          Enable the Boehm Garbage Collector"
-ac_help="$ac_help
   --enable-wrap-malloc    Wrap malloc calls (gnu linker only)"
 ac_help="$ac_help
   --with-wrap-malloc=SHAREDLIB  Location of malloc wrapper library"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
 # dashes changed to underlines.
 build=NONE
@@ -643,17 +644,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:652: checking host system type" >&5
+echo "configure:653: 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; }
@@ -664,17 +665,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:673: checking target system type" >&5
+echo "configure:674: 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 ;;
@@ -682,17 +683,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:691: checking build system type" >&5
+echo "configure:692: 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 ;;
@@ -707,17 +708,17 @@ echo "$ac_t""$build" 1>&6
 test "$host_alias" != "$target_alias" &&
   test "$program_prefix$program_suffix$program_transform_name" = \
     NONENONEs,x,x, &&
   program_prefix=${target_alias}-
 
 
 MOD_MAJOR_VERSION=4
 MOD_MINOR_VERSION=8
-MOD_PATCH_VERSION=6
+MOD_PATCH_VERSION=7
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_64=
 USE_CPLUS=
@@ -759,17 +760,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:768: checking for $ac_word" >&5
+echo "configure:769: 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"
@@ -876,16 +877,18 @@ if test "$target" = "arm-android-eabi" ;
     fi
     if test -z "$HOST_CXXFLAGS" ; then
         HOST_CXXFLAGS=" "
     fi
     if test -z "$HOST_LDFLAGS" ; then
         HOST_LDFLAGS=" "
     fi
 
+    WRAP_MALLOC_CFLAGS="-Wl,--wrap=dlopen -Wl,--wrap=dlclose -Wl,--wrap=dlerror -Wl,--wrap=dlsym -Wl,--wrap=dladdr"
+
     cat >> confdefs.h <<\EOF
 #define ANDROID 1
 EOF
 
 fi
 
 dist_prefix='${MOD_DEPTH}/dist'
 dist_bindir='${dist_prefix}/bin'
@@ -1174,17 +1177,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:1183: checking for $ac_word" >&5
+echo "configure:1186: 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.
   ;;
   ?:/*)			 
@@ -1245,23 +1248,23 @@ if test "$target" != "$host"; then
     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:1254: checking for $host compiler" >&5
+echo "configure:1257: 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:1260: checking for $ac_word" >&5
+echo "configure:1263: 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"
@@ -1297,26 +1300,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:1306: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
+echo "configure:1309: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
     cat > conftest.$ac_ext <<EOF
-#line 1308 "configure"
+#line 1311 "configure"
 #include "confdefs.h"
 
 int main() {
 return(0);
 ; return 0; }
 EOF
-if { (eval echo configure:1315: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1318: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_prog_host_cc_works=1 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
@@ -1335,17 +1338,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:1344: checking for $ac_word" >&5
+echo "configure:1347: 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"
@@ -1369,17 +1372,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:1378: checking for $ac_word" >&5
+echo "configure:1381: 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"
@@ -1399,17 +1402,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:1408: checking for $ac_word" >&5
+echo "configure:1411: 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
@@ -1450,17 +1453,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:1459: checking for $ac_word" >&5
+echo "configure:1462: 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"
@@ -1482,33 +1485,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:1491: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1494: 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 1502 "configure"
+#line 1505 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1507: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1510: \"$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
@@ -1524,31 +1527,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:1533: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1536: 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:1538: checking whether we are using GNU C" >&5
+echo "configure:1541: 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:1547: \"$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:1550: \"$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
 
@@ -1557,17 +1560,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:1566: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1569: 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
@@ -1594,17 +1597,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:1603: checking for $ac_word" >&5
+echo "configure:1606: 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"
@@ -1630,17 +1633,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:1639: checking for $ac_word" >&5
+echo "configure:1642: 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"
@@ -1662,33 +1665,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:1671: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:1674: 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 1682 "configure"
+#line 1685 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:1687: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1690: \"$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
@@ -1704,31 +1707,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:1713: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1716: 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:1718: checking whether we are using GNU C++" >&5
+echo "configure:1721: 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:1727: \"$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:1730: \"$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
 
@@ -1737,17 +1740,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:1746: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:1749: 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
@@ -1782,17 +1785,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:1791: checking for $ac_word" >&5
+echo "configure:1794: 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"
@@ -1817,17 +1820,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:1826: checking for $ac_word" >&5
+echo "configure:1829: 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"
@@ -1852,17 +1855,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:1861: checking for $ac_word" >&5
+echo "configure:1864: 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"
@@ -1887,17 +1890,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:1896: checking for $ac_word" >&5
+echo "configure:1899: 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"
@@ -1922,17 +1925,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:1931: checking for $ac_word" >&5
+echo "configure:1934: 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"
@@ -1957,17 +1960,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:1966: checking for $ac_word" >&5
+echo "configure:1969: 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"
@@ -1992,17 +1995,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:2001: checking for $ac_word" >&5
+echo "configure:2004: 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"
@@ -2022,17 +2025,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:2031: checking for $ac_word" >&5
+echo "configure:2034: 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
@@ -2073,17 +2076,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:2082: checking for $ac_word" >&5
+echo "configure:2085: 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"
@@ -2105,33 +2108,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:2114: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:2117: 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 2125 "configure"
+#line 2128 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:2130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2133: \"$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
@@ -2147,31 +2150,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:2156: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2159: 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:2161: checking whether we are using GNU C" >&5
+echo "configure:2164: 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:2170: \"$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:2173: \"$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
 
@@ -2180,17 +2183,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:2189: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:2192: 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
@@ -2220,17 +2223,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:2229: checking for $ac_word" >&5
+echo "configure:2232: 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"
@@ -2252,33 +2255,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:2261: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:2264: 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 2272 "configure"
+#line 2275 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:2277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2280: \"$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
@@ -2294,31 +2297,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:2303: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2306: 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:2308: checking whether we are using GNU C++" >&5
+echo "configure:2311: 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:2317: \"$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:2320: \"$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
 
@@ -2327,17 +2330,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:2336: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:2339: 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
@@ -2361,72 +2364,72 @@ else
   else
     CXXFLAGS=
   fi
 fi
 
         fi
     fi
     echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:2370: checking how to run the C preprocessor" >&5
+echo "configure:2373: 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 2385 "configure"
+#line 2388 "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:2391: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2394: \"$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 2402 "configure"
+#line 2405 "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:2408: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2411: \"$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 2419 "configure"
+#line 2422 "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:2425: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2428: \"$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*
@@ -2443,17 +2446,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:2452: checking for $ac_word" >&5
+echo "configure:2455: 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"
@@ -2475,17 +2478,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:2484: checking for $ac_word" >&5
+echo "configure:2487: 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.
   ;;
   ?:/*)			 
@@ -2516,17 +2519,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:2525: checking for $ac_word" >&5
+echo "configure:2528: 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.
   ;;
   ?:/*)			 
@@ -2557,17 +2560,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:2566: checking for $ac_word" >&5
+echo "configure:2569: 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.
   ;;
   ?:/*)			 
@@ -2598,17 +2601,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:2607: checking for $ac_word" >&5
+echo "configure:2610: 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.
   ;;
   ?:/*)			 
@@ -2639,17 +2642,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:2648: checking for $ac_word" >&5
+echo "configure:2651: 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.
   ;;
   ?:/*)			 
@@ -2707,39 +2710,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:2716: checking for gcc -pipe support" >&5
+echo "configure:2719: 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 2731 "configure"
+#line 2734 "configure"
 #include "confdefs.h"
  #include <stdio.h> 
 int main() {
 printf("Hello World\n");
 ; return 0; }
 EOF
-if { (eval echo configure:2738: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2741: \"$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
@@ -2759,26 +2762,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:2768: checking whether C compiler supports -fprofile-generate" >&5
+echo "configure:2771: checking whether C compiler supports -fprofile-generate" >&5
 cat > conftest.$ac_ext <<EOF
-#line 2770 "configure"
+#line 2773 "configure"
 #include "confdefs.h"
 
 int main() {
 return 0;
 ; return 0; }
 EOF
-if { (eval echo configure:2777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2780: \"$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"
@@ -2791,17 +2794,17 @@ if test $result = "yes"; then
    PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch -freorder-blocks-and-partition"
    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:2800: checking for visibility(hidden) attribute" >&5
+echo "configure:2803: 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
@@ -2815,17 +2818,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:2824: checking for visibility pragma support" >&5
+echo "configure:2827: 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;
@@ -2868,17 +2871,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:2877: checking for $ac_word" >&5
+echo "configure:2880: 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.
   ;;
   ?:/*)			 
@@ -3104,16 +3107,26 @@ if test -n "$MOZ_THUMB2"; then
       else
         { echo "configure: error: --enable-thumb2 is not supported for non-GNU toolchains" 1>&2; exit 1; }
       fi
     ;;
     *)
       { echo "configure: error: --enable-thumb2 is not supported for non-ARM CPU architectures" 1>&2; exit 1; }
     ;;
   esac
+else
+  case "$target_cpu" in
+    arm*)
+      if test "$GNU_CC"; then
+       CFLAGS="$CFLAGS -march=armv5te -mthumb-interwork -Wa, -march=armv5te -Wa, -mthumb-interwork"
+        CXXFLAGS="$CXXFLAGS -march=armv5te -mthumb-interwork -Wa, -march=armv5te -Wa, -mthumb-interwork"
+        ASFLAGS="$ASFLAGS -march=armv5te -mthumb-interwork"
+      fi
+      ;;
+  esac
 fi
 
 case "$host" in
 *-mingw*)
     NSINSTALL=nsinstall
     ;;
 *-cygwin*|*-msvc*|*-mks*|*-wince*|*-winmo*)
     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
@@ -3144,27 +3157,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:3153: checking for sys/atomic_op.h" >&5
+echo "configure:3166: 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 3158 "configure"
+#line 3171 "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:3163: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3176: \"$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
@@ -3311,36 +3324,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:3320: checking for gethostbyaddr in -lbind" >&5
+echo "configure:3333: 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 3328 "configure"
+#line 3341 "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:3339: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3352: \"$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
@@ -4226,18 +4239,34 @@ EOF
         MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
 
         if test "$_CC_MAJOR_VERSION" -eq "14"; then
                                             if test $_CC_RELEASE -gt 50727; then
               _USE_DYNAMICBASE=1
            elif test $_CC_BUILD -ge 762; then
               _USE_DYNAMICBASE=1
            fi
+           cat >> confdefs.h <<\EOF
+#define _CRT_SECURE_NO_DEPRECATE 1
+EOF
+
+           cat >> confdefs.h <<\EOF
+#define _CRT_NONSTDC_NO_DEPRECATE 1
+EOF
+
         elif test $_CC_MAJOR_VERSION -ge 15; then
            _USE_DYNAMICBASE=1    
+           cat >> confdefs.h <<\EOF
+#define _CRT_SECURE_NO_WARNINGS 1
+EOF
+
+           cat >> confdefs.h <<\EOF
+#define _CRT_NONSTDC_NO_WARNINGS 1
+EOF
+
         fi
 
         if test -n "$_USE_DYNAMICBASE"; then
            DLLFLAGS="$DLLFLAGS -DYNAMICBASE"
         fi
 
         # Ensure that mt is Microsoft (R) Manifest Tool and not magnetic
         # tape manipulation utility (or something else)
@@ -4705,27 +4734,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:4714: checking for machine/builtins.h" >&5
+echo "configure:4743: 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 4719 "configure"
+#line 4748 "configure"
 #include "confdefs.h"
 #include <machine/builtins.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4724: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4753: \"$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
@@ -5364,63 +5393,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:5373: checking for dlopen in -ldl" >&5
+echo "configure:5402: 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 5381 "configure"
+#line 5410 "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:5392: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5421: \"$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:5409: checking for dlfcn.h" >&5
+echo "configure:5438: 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 5414 "configure"
+#line 5443 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5419: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5448: \"$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
@@ -5443,23 +5472,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:5452: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:5481: 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 5458 "configure"
+#line 5487 "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
@@ -5467,17 +5496,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 5476 "configure"
+#line 5505 "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
@@ -5491,22 +5520,22 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
 fi
 
 for ac_func in lchown strerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5500: checking for $ac_func" >&5
+echo "configure:5529: 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 5505 "configure"
+#line 5534 "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();
@@ -5519,17 +5548,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:5528: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5557: \"$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
@@ -5546,31 +5575,100 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 fi
 done
 
 
 
 
+# Check whether --with-ccache or --without-ccache was given.
+if test "${with_ccache+set}" = set; then
+  withval="$with_ccache"
+  CCACHE=$withval
+else
+  CCACHE="no"
+fi
+
+
+if test "$CCACHE" != "no"; then
+    if test -n "$CCACHE"; then
+        if test "$CCACHE" = "yes"; then
+            CCACHE=
+        else
+            if test ! -e "$CCACHE"; then
+                { echo "configure: error: $CCACHE not found" 1>&2; exit 1; }
+            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:5608: 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.
+  ;;
+  ?:/*)			 
+  ac_cv_path_CCACHE="$CCACHE" # Let the user override the test with a dos path.
+  ;;
+  *)
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do 
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_path_CCACHE="$ac_dir/$ac_word"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+fi
+CCACHE="$ac_cv_path_CCACHE"
+if test -n "$CCACHE"; then
+  echo "$ac_t""$CCACHE" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$CCACHE" && break
+done
+
+    if test -z "$CCACHE" -o "$CCACHE" = ":"; then
+        { echo "configure: error: ccache not found" 1>&2; exit 1; }
+    elif test -x "$CCACHE"; then
+        CC="$CCACHE $CC"
+        CXX="$CCACHE $CXX"
+    else
+        { echo "configure: error: $CCACHE is not executable" 1>&2; exit 1; }
+    fi
+fi
+
 # Check whether --enable-strip or --disable-strip was given.
 if test "${enable_strip+set}" = set; then
   enableval="$enable_strip"
    if test "$enableval" = "yes"; then
 	    ENABLE_STRIP=1
       fi 
 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:5569: checking for +Olit support" >&5
+echo "configure:5667: 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
@@ -5602,17 +5700,17 @@ darwin*)
     _HAVE_PTHREADS=1
     ;;
 wince*)
     _HAVE_PTHREADS=
     ;;
 *)
     
 echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:5611: checking for pthread_create in -lpthreads" >&5
+echo "configure:5709: 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);
         }
@@ -5624,17 +5722,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:5633: checking for pthread_create in -lpthread" >&5
+echo "configure:5731: 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);
         }
@@ -5646,17 +5744,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:5655: checking for pthread_create in -lc_r" >&5
+echo "configure:5753: 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);
         }
@@ -5668,17 +5766,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:5677: checking for pthread_create in -lc" >&5
+echo "configure:5775: 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);
         }
@@ -5782,35 +5880,21 @@ if test "${enable_ipv6+set}" = set; then
    if test "$enableval" = "yes"; then
 	    USE_IPV6=1
       else
 	    USE_IPV6=
       fi
 fi
 
 
-
-# Check whether --enable-boehm or --disable-boehm was given.
-if test "${enable_boehm+set}" = set; then
-  enableval="$enable_boehm"
-   if test "$enableval" = "yes"; then
-        cat >> confdefs.h <<\EOF
-#define GC_LEAK_DETECTOR 1
-EOF
-
-        GC_LEAK_DETECTOR=1
-    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:5809: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5893: 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
@@ -5823,17 +5907,17 @@ echo "configure:5809: 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:5832: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5916: 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
@@ -6147,17 +6231,17 @@ if test "${enable_wrap_malloc+set}" = se
        if test "$enableval" = "yes"; then
 	    _WRAP_MALLOC=1
       fi 
 fi
 
 
 if test -n "$_WRAP_MALLOC"; then
     if test "$GNU_CC"; then
-       WRAP_MALLOC_CFLAGS="${LDFLAGS} -Wl,--wrap -Wl,malloc -Wl,--wrap -Wl,calloc -Wl,--wrap -Wl,valloc -Wl,--wrap -Wl,free -Wl,--wrap -Wl,realloc -Wl,--wrap -Wl,memalign -Wl,--wrap -Wl,__builtin_new -Wl,--wrap -Wl,__builtin_vec_new -Wl,--wrap -Wl,__builtin_delete -Wl,--wrap -Wl,__builtin_vec_delete -Wl,--wrap -Wl,PR_Free -Wl,--wrap -Wl,PR_Malloc -Wl,--wrap -Wl,PR_Calloc -Wl,--wrap -Wl,PR_Realloc -Wl,--wrap -Wl,strdup -Wl,--wrap -Wl,strndup -Wl,--wrap -Wl,posix_memalign"
+       WRAP_MALLOC_CFLAGS="${LDFLAGS} ${WRAP_MALLOC_CFLAGS} -Wl,--wrap -Wl,malloc -Wl,--wrap -Wl,calloc -Wl,--wrap -Wl,valloc -Wl,--wrap -Wl,free -Wl,--wrap -Wl,realloc -Wl,--wrap -Wl,memalign -Wl,--wrap -Wl,__builtin_new -Wl,--wrap -Wl,__builtin_vec_new -Wl,--wrap -Wl,__builtin_delete -Wl,--wrap -Wl,__builtin_vec_delete -Wl,--wrap -Wl,PR_Free -Wl,--wrap -Wl,PR_Malloc -Wl,--wrap -Wl,PR_Calloc -Wl,--wrap -Wl,PR_Realloc -Wl,--wrap -Wl,strdup -Wl,--wrap -Wl,strndup -Wl,--wrap -Wl,posix_memalign"
        DSO_LDOPTS="$DSO_LDOPTS $WRAP_MALLOC_CFLAGS"
     else
        { echo "configure: error: --enable-wrap-malloc is not supported for non-GNU toolchains" 1>&2; exit 1; }
     fi
 fi
 
 # Check whether --with-wrap-malloc or --without-wrap-malloc was given.
 if test "${with_wrap_malloc+set}" = set; then
@@ -6266,17 +6350,16 @@ fi
 
 
 
 
 
 
 
 
-
 MAKEFILES="
 Makefile 
 config/Makefile
 config/autoconf.mk
 config/nsprincl.mk
 config/nsprincl.sh
 config/nspr-config
 lib/Makefile 
@@ -6391,17 +6474,17 @@ trap 'rm -f $CONFIG_STATUS conftest*; ex
 # Protect against Makefile macro expansion.
 cat > conftest.defs <<\EOF
 s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
 s%[ 	`~#$^&*(){}\\|;'"<>?]%\\&%g
 s%\[%\\&%g
 s%\]%\\&%g
 s%\$%$$%g
 EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' ' | tr '\015' ' '` # Manually modified for MKS support.
 rm -f conftest.defs
 
 
 # Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
 
 echo creating $CONFIG_STATUS
 rm -f $CONFIG_STATUS
@@ -6434,16 +6517,18 @@ do
 done
 
 ac_given_srcdir=$srcdir
 
 trap 'rm -fr `echo "$MAKEFILES" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
+
+
 # Protect against being on the right side of a sed subst in config.status.
 sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
  s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
 s%@SHELL@%$SHELL%g
 s%@CFLAGS@%$CFLAGS%g
 s%@CPPFLAGS@%$CPPFLAGS%g
@@ -6493,33 +6578,33 @@ s%@CXX@%$CXX%g
 s%@RANLIB@%$RANLIB%g
 s%@AR@%$AR%g
 s%@AS@%$AS%g
 s%@LD@%$LD%g
 s%@STRIP@%$STRIP%g
 s%@WINDRES@%$WINDRES%g
 s%@CPP@%$CPP%g
 s%@PERL@%$PERL%g
+s%@CCACHE@%$CCACHE%g
 s%@SHELL_OVERRIDE@%$SHELL_OVERRIDE%g
 s%@MOZILLA_CLIENT@%$MOZILLA_CLIENT%g
 s%@HOST_CFLAGS@%$HOST_CFLAGS%g
 s%@HOST_LDFLAGS@%$HOST_LDFLAGS%g
 s%@GNU_CC@%$GNU_CC%g
 s%@GCC_USE_GNU_LD@%$GCC_USE_GNU_LD%g
 s%@MSC_VER@%$MSC_VER%g
 s%@CROSS_COMPILE@%$CROSS_COMPILE%g
 s%@MOZ_OPTIMIZE@%$MOZ_OPTIMIZE%g
 s%@MOZ_DEBUG@%$MOZ_DEBUG%g
 s%@MOZ_DEBUG_SYMBOLS@%$MOZ_DEBUG_SYMBOLS%g
 s%@USE_CPLUS@%$USE_CPLUS%g
 s%@USE_IPV6@%$USE_IPV6%g
 s%@USE_N32@%$USE_N32%g
 s%@USE_64@%$USE_64%g
 s%@OBJECT_MODE@%$OBJECT_MODE%g
-s%@GC_LEAK_DETECTOR@%$GC_LEAK_DETECTOR%g
 s%@ENABLE_STRIP@%$ENABLE_STRIP%g
 s%@USE_PTHREADS@%$USE_PTHREADS%g
 s%@USE_BTHREADS@%$USE_BTHREADS%g
 s%@USE_USER_PTHREADS@%$USE_USER_PTHREADS%g
 s%@USE_NSPR_THREADS@%$USE_NSPR_THREADS%g
 s%@LIBNSPR@%$LIBNSPR%g
 s%@LIBPLC@%$LIBPLC%g
 s%@MOD_MAJOR_VERSION@%$MOD_MAJOR_VERSION%g
@@ -6642,41 +6727,43 @@ for ac_file in .. $CONFIG_FILES; do if t
   else
     ac_dir_suffix= ac_dots=
   fi
 
   case "$ac_given_srcdir" in
   .)  srcdir=.
       if test -z "$ac_dots"; then top_srcdir=.
       else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
-  /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+  /* | ?:/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
   *) # Relative path.
     srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
     top_srcdir="$ac_dots$ac_given_srcdir" ;;
   esac
 
 
   echo creating "$ac_file"
   rm -f "$ac_file"
   configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
   case "$ac_file" in
   *Makefile*) ac_comsub="1i\\
 # $configure_input" ;;
   *) ac_comsub= ;;
   esac
 
-  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" `
   sed -e "$ac_comsub
 s%@configure_input@%$configure_input%g
 s%@srcdir@%$srcdir%g
 s%@top_srcdir@%$top_srcdir%g
 " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
 fi; done
 rm -f conftest.s*
 
+
+
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 chmod +x config/nspr-config
 exit 0
 EOF
--- a/nsprpub/configure.in
+++ b/nsprpub/configure.in
@@ -45,17 +45,17 @@ AC_INIT(config/libc_r.h)
 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
 AC_CANONICAL_SYSTEM
 
 dnl ========================================================
 dnl = Defaults
 dnl ========================================================
 MOD_MAJOR_VERSION=4
 MOD_MINOR_VERSION=8
-MOD_PATCH_VERSION=6
+MOD_PATCH_VERSION=7
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_64=
 USE_CPLUS=
@@ -189,16 +189,18 @@ if test "$target" = "arm-android-eabi" ;
     fi
     if test -z "$HOST_CXXFLAGS" ; then
         HOST_CXXFLAGS=" "
     fi
     if test -z "$HOST_LDFLAGS" ; then
         HOST_LDFLAGS=" "
     fi
 
+    WRAP_MALLOC_CFLAGS="-Wl,--wrap=dlopen -Wl,--wrap=dlclose -Wl,--wrap=dlerror -Wl,--wrap=dlsym -Wl,--wrap=dladdr"
+
     AC_DEFINE(ANDROID)
 fi
 
 dnl ========================================================
 dnl =
 dnl = Check options that may affect the compiler
 dnl =
 dnl ========================================================
@@ -929,16 +931,26 @@ if test -n "$MOZ_THUMB2"; then
       else
         AC_MSG_ERROR([--enable-thumb2 is not supported for non-GNU toolchains])
       fi
     ;;
     *)
       AC_MSG_ERROR([--enable-thumb2 is not supported for non-ARM CPU architectures])
     ;;
   esac
+else
+  case "$target_cpu" in
+    arm*)
+      if test "$GNU_CC"; then
+       CFLAGS="$CFLAGS -march=armv5te -mthumb-interwork -Wa, -march=armv5te -Wa, -mthumb-interwork"
+        CXXFLAGS="$CXXFLAGS -march=armv5te -mthumb-interwork -Wa, -march=armv5te -Wa, -mthumb-interwork"
+        ASFLAGS="$ASFLAGS -march=armv5te -mthumb-interwork"
+      fi
+      ;;
+  esac
 fi
 
 dnl ========================================================
 dnl Override of system specific host options
 dnl ========================================================
 case "$host" in
 *-mingw*)
     NSINSTALL=nsinstall
@@ -1693,18 +1705,22 @@ arm-android-eabi)
            dnl -DYNAMICBASE is only supported on VC8SP1 or newer,
            dnl so be very specific here!
            dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762
            if test $_CC_RELEASE -gt 50727; then
               _USE_DYNAMICBASE=1
            elif test $_CC_BUILD -ge 762; then
               _USE_DYNAMICBASE=1
            fi
+           AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
+           AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
         elif test $_CC_MAJOR_VERSION -ge 15; then
            _USE_DYNAMICBASE=1    
+           AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
+           AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
         fi
 
         if test -n "$_USE_DYNAMICBASE"; then
            DLLFLAGS="$DLLFLAGS -DYNAMICBASE"
         fi
 
         # Ensure that mt is Microsoft (R) Manifest Tool and not magnetic
         # tape manipulation utility (or something else)
@@ -2506,16 +2522,45 @@ dnl AC_FUNC_STRFTIME
 dnl AC_FUNC_UTIME_NULL
 dnl AC_FUNC_VPRINTF
 dnl AC_CHECK_FUNCS(ftime getcwd gethostname gettimeofday getwd mkdir mktime putenv rmdir select socket strdup strerror strstr strtol strtoul uname)
 
 dnl ========================================================
 dnl Check options
 dnl ========================================================
 
+dnl ======================================================
+dnl = Enable compiling with ccache
+dnl ======================================================
+AC_ARG_WITH(ccache,
+[  --with-ccache[=path/to/ccache]
+                          Enable compiling with ccache],
+    CCACHE=$withval, CCACHE="no")
+
+if test "$CCACHE" != "no"; then
+    if test -n "$CCACHE"; then
+        if test "$CCACHE" = "yes"; then
+            CCACHE=
+        else
+            if test ! -e "$CCACHE"; then
+                AC_MSG_ERROR([$CCACHE not found])
+            fi
+        fi
+    fi
+    AC_PATH_PROGS(CCACHE, $CCACHE ccache)
+    if test -z "$CCACHE" -o "$CCACHE" = ":"; then
+        AC_MSG_ERROR([ccache not found])
+    elif test -x "$CCACHE"; then
+        CC="$CCACHE $CC"
+        CXX="$CCACHE $CXX"
+    else
+        AC_MSG_ERROR([$CCACHE is not executable])
+    fi
+fi
+
 dnl ========================================================
 dnl =
 dnl = --enable-strip
 dnl = 
 dnl = Enable stripping of libs and executables
 dnl = 
 dnl ========================================================
 AC_ARG_ENABLE(strip,
@@ -2669,24 +2714,16 @@ fi # SKIP_LIBRARY_CHECKS
 AC_ARG_ENABLE(ipv6,
     [  --enable-ipv6           Compile ipv6 support],
     [ if test "$enableval" = "yes"; then
 	    USE_IPV6=1
       else
 	    USE_IPV6=
       fi])
 
-
-AC_ARG_ENABLE(boehm,
-    [  --enable-boehm          Enable the Boehm Garbage Collector],
-    [ if test "$enableval" = "yes"; then
-        AC_DEFINE(GC_LEAK_DETECTOR)
-        GC_LEAK_DETECTOR=1
-    fi])
-
 if test -n "$USE_PTHREADS"; then
    dnl See if -pthread is supported.
    rm -f conftest*
    ac_cv_have_dash_pthread=no
    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
    echo 'int main() { return 0; }' | cat > conftest.c
    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
    if test $? -eq 0; then
@@ -2949,17 +2986,17 @@ dnl ====================================
 AC_ARG_ENABLE(wrap-malloc,
 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
 [     if test "$enableval" = "yes"; then
 	    _WRAP_MALLOC=1
       fi ])
 
 if test -n "$_WRAP_MALLOC"; then
     if test "$GNU_CC"; then
-       WRAP_MALLOC_CFLAGS="${LDFLAGS} -Wl,--wrap -Wl,malloc -Wl,--wrap -Wl,calloc -Wl,--wrap -Wl,valloc -Wl,--wrap -Wl,free -Wl,--wrap -Wl,realloc -Wl,--wrap -Wl,memalign -Wl,--wrap -Wl,__builtin_new -Wl,--wrap -Wl,__builtin_vec_new -Wl,--wrap -Wl,__builtin_delete -Wl,--wrap -Wl,__builtin_vec_delete -Wl,--wrap -Wl,PR_Free -Wl,--wrap -Wl,PR_Malloc -Wl,--wrap -Wl,PR_Calloc -Wl,--wrap -Wl,PR_Realloc -Wl,--wrap -Wl,strdup -Wl,--wrap -Wl,strndup -Wl,--wrap -Wl,posix_memalign"
+       WRAP_MALLOC_CFLAGS="${LDFLAGS} ${WRAP_MALLOC_CFLAGS} -Wl,--wrap -Wl,malloc -Wl,--wrap -Wl,calloc -Wl,--wrap -Wl,valloc -Wl,--wrap -Wl,free -Wl,--wrap -Wl,realloc -Wl,--wrap -Wl,memalign -Wl,--wrap -Wl,__builtin_new -Wl,--wrap -Wl,__builtin_vec_new -Wl,--wrap -Wl,__builtin_delete -Wl,--wrap -Wl,__builtin_vec_delete -Wl,--wrap -Wl,PR_Free -Wl,--wrap -Wl,PR_Malloc -Wl,--wrap -Wl,PR_Calloc -Wl,--wrap -Wl,PR_Realloc -Wl,--wrap -Wl,strdup -Wl,--wrap -Wl,strndup -Wl,--wrap -Wl,posix_memalign"
        DSO_LDOPTS="$DSO_LDOPTS $WRAP_MALLOC_CFLAGS"
     else
        AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
     fi
 fi
 
 dnl ========================================================
 dnl = Location of malloc wrapper lib
@@ -2992,17 +3029,16 @@ AC_SUBST(MOZ_OPTIMIZE)
 AC_SUBST(MOZ_DEBUG)
 AC_SUBST(MOZ_DEBUG_SYMBOLS)
 
 AC_SUBST(USE_CPLUS)
 AC_SUBST(USE_IPV6)
 AC_SUBST(USE_N32)
 AC_SUBST(USE_64)
 AC_SUBST(OBJECT_MODE)
-AC_SUBST(GC_LEAK_DETECTOR)
 AC_SUBST(ENABLE_STRIP)
 
 AC_SUBST(USE_PTHREADS)
 AC_SUBST(USE_BTHREADS)
 AC_SUBST(USE_USER_PTHREADS)
 AC_SUBST(USE_NSPR_THREADS)
 
 AC_SUBST(LIBNSPR)
--- a/nsprpub/lib/prstreams/Makefile.in
+++ b/nsprpub/lib/prstreams/Makefile.in
@@ -41,33 +41,16 @@ MOD_DEPTH	= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(MOD_DEPTH)/config/autoconf.mk
 
 include $(topsrcdir)/config/config.mk
 
-# Disable optimization of the nspr on SunOS4.1.3
-ifeq ($(OS_ARCH),SunOS)
-    ifeq ($(OS_RELEASE),4.1.3_U1)
-        OPTIMIZER =
-    else
-        # The C++ compiler in Workshop 5.0 uses standard
-        # iostreams as default.  -library=iostream will
-        # allow Workshop 5.0 to work with classic iostreams.
-        ifndef NS_USE_GCC
-        CCC_VERSION := $(shell $(CCC) -V 2>&1)
-        ifneq (,$(findstring 5.0,$(CCC_VERSION)))
-        CCC_ONLY_FLAGS += -library=iostream
-        endif
-        endif
-    endif
-endif
-
 ifeq ($(OS_ARCH), IRIX)
     ifneq ($(OS_RELEASE),5.3)
         CCC_ONLY_FLAGS += -exceptions
     endif
 endif
 
 ifeq ($(OS_ARCH), BeOS)
     CFLAGS += -frtti -fexceptions
--- a/nsprpub/lib/prstreams/prstrms.cpp
+++ b/nsprpub/lib/prstreams/prstrms.cpp
@@ -32,515 +32,517 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /*
  * Robin J. Maxwell 11-22-96
+ * Fredrik Roubert <roubert@google.com> 2010-07-23
+ * Matt Austern <austern@google.com> 2010-07-23
  */
 
 #include "prstrms.h"
-#include <string.h> // memmove
 
-//
-// Definition of macros _PRSTR_BP, _PRSTR_DELBUF, and _PRSTR_DELBUF_C.
-//
-// _PRSTR_BP is the protected member of class ios that is returned
-// by the public method rdbuf().
-//
-// _PRSTR_DELBUF is the method or data member of class ios, if available,
-// with which we can ensure that the ios destructor does not delete
-// the associated streambuf.  If such a method or data member does not
-// exist, define _PRSTR_DELBUF to be empty.
-//
-// _PRSTR_DELBUF_C is just _PRSTR_DELBUF qualified by a base class.
-//
+#include <cstdio>
+#include <cstring>
+#include <ios>
+#include <new>
 
-#if defined(__GNUC__)
-#define _PRSTR_BP _strbuf
-#define _PRSTR_DELBUF(x)    /* as nothing */
-#define _PRSTR_DELBUF_C(c, x)  /* as nothing */
-#elif defined(WIN32)
-#define _PRSTR_BP bp
-#define _PRSTR_DELBUF(x)	delbuf(x)
-#define _PRSTR_DELBUF_C(c, x)	c::_PRSTR_DELBUF(x)
-#elif defined(OSF1)
-#define _PRSTR_BP m_psb
-#define _PRSTR_DELBUF(x) /* as nothing */
-#define _PRSTR_DELBUF_C(c, x)	/* as nothing */
-#elif defined(QNX)
-#define PRFSTREAMS_BROKEN
-#else
-#define _PRSTR_BP bp
-// Unix compilers don't believe in encapsulation
-// At least on Solaris this is also ignored
-#define _PRSTR_DELBUF(x)	delbuf = x
-#define _PRSTR_DELBUF_C(c, x)	c::_PRSTR_DELBUF(x)
-#endif
+using std::ios_base;
+using std::iostream;
+using std::istream;
+using std::nothrow;
+using std::ostream;
+using std::streambuf;
+using std::streamsize;
 
-const PRIntn STRM_BUFSIZ = 8192;
-
-#if !defined (PRFSTREAMS_BROKEN)   
 
 PRfilebuf::PRfilebuf():
-_fd(0),
-_opened(PR_FALSE),
-_allocated(PR_FALSE)
-{
-}
+    _fd(NULL),
+    _opened(false),
+    _allocated(false),
+    _unbuffered(false),
+    _user_buf(false),
+    _buf_base(NULL),
+    _buf_end(NULL) { }
+
 
 PRfilebuf::PRfilebuf(PRFileDesc *fd):
-streambuf(),
-_fd(fd),
-_opened(PR_FALSE),
-_allocated(PR_FALSE)
+    _fd(fd),
+    _opened(false),
+    _allocated(false),
+    _unbuffered(false),
+    _user_buf(false),
+    _buf_base(NULL),
+    _buf_end(NULL) { }
+
+
+PRfilebuf::PRfilebuf(PRFileDesc *fd, char_type *ptr, streamsize len):
+    _fd(fd),
+    _opened(false),
+    _allocated(false),
+    _unbuffered(false),
+    _user_buf(false),
+    _buf_base(NULL),
+    _buf_end(NULL)
 {
+    setbuf(ptr, len);
 }
 
-PRfilebuf::PRfilebuf(PRFileDesc *fd, char * buffptr, int bufflen):
-_fd(fd),
-_opened(PR_FALSE),
-_allocated(PR_FALSE)
-{
-    PRfilebuf::setbuf(buffptr, bufflen);
-}
 
 PRfilebuf::~PRfilebuf()
 {
-    if (_opened){
+    if (_opened) {
         close();
-    }else
+    } else {
         sync();
-	if (_allocated)
-		delete base();
+    }
+    if (_allocated) {
+        delete _buf_base;
+    }
 }
 
-PRfilebuf*	
-PRfilebuf::open(const char *name, int mode, int flags)
+
+PRfilebuf *PRfilebuf::open(
+    const char *name, ios_base::openmode flags, PRIntn mode)
 {
-     if (_fd != 0)
-        return 0;    // error if already open
-     PRIntn PRmode = 0;
-    // translate mode argument
-    if (!(mode & ios::nocreate))
-        PRmode |= PR_CREATE_FILE;
-    //if (mode & ios::noreplace)
-    //    PRmode |= O_EXCL;
-    if (mode & ios::app){
-        mode |= ios::out;
-        PRmode |= PR_APPEND;
-    }
-    if (mode & ios::trunc){
-        mode |= ios::out;  // IMPLIED
-        PRmode |= PR_TRUNCATE;
+    if (_fd != NULL) {
+        return NULL;  // Error if already open.
     }
-    if (mode & ios::out){
-        if (mode & ios::in)
-            PRmode |= PR_RDWR;
-        else
-            PRmode |= PR_WRONLY;
-        if (!(mode & (ios::in|ios::app|ios::ate|ios::noreplace))){
-            mode |= ios::trunc; // IMPLIED
-            PRmode |= PR_TRUNCATE;
-        }
-    }else if (mode & ios::in)
-        PRmode |= PR_RDONLY;
-    else
-        return 0;    // error if not ios:in or ios::out
+
+    // Translate flags argument.
+    PRIntn prflags = 0;
+    bool ate = (flags & ios_base::ate) != 0;
+    flags &= ~(ios_base::ate | ios_base::binary);
 
+    // TODO: The flag PR_CREATE_FILE should probably be used for the cases
+    // (out), (out|app), (out|trunc) and (in|out|trunc) as the C++ standard
+    // specifies that these cases should open files 'as if by using fopen with
+    // "w"'. But adding that flag here will cause the unit test to leave files
+    // behind after running (which might or might not be an error in the unit
+    // test) so the matter needs further investigation before any changes are
+    // made. The old prstreams implementation used the non-standard flag
+    // ios::nocreate to control the use of PR_CREATE_FILE.
 
-    //
-    // The usual portable across unix crap...
-    // NT gets a hokey piece of junk layer that prevents
-    // access to the API.
-#ifdef WIN32
-    _fd = PR_Open(name, PRmode, PRmode);
-#else
-    _fd = PR_Open(name, PRmode, flags);
-#endif
-    if (_fd == 0)
-        return 0;
-    _opened = PR_TRUE;
-    if ((!unbuffered()) && (!ebuf())){
-        char * sbuf = new char[STRM_BUFSIZ];
-        if (!sbuf)
-            unbuffered(1);
-        else{
-			_allocated = PR_TRUE;
-            streambuf::setb(sbuf,sbuf+STRM_BUFSIZ,0);
-		}
+    if (flags == (ios_base::out)) {
+        prflags = PR_WRONLY | PR_TRUNCATE;
+    } else if (flags == (ios_base::out | ios_base::app)) {
+        prflags = PR_RDWR | PR_APPEND;
+    } else if (flags == (ios_base::out | ios_base::trunc)) {
+        prflags = PR_WRONLY | PR_TRUNCATE;
+    } else if (flags == (ios_base::in)) {
+        prflags = PR_RDONLY;
+    } else if (flags == (ios_base::in | ios_base::out)) {
+        prflags = PR_RDWR;
+    } else if (flags == (ios_base::in | ios_base::out | ios_base::trunc)) {
+        prflags = PR_RDWR | PR_TRUNCATE;
+    } else {
+        return NULL;  // Unrecognized flag combination.
     }
-    if (mode & ios::ate){
-        if (seekoff(0,ios::end,mode)==EOF){
-            close();
-            return 0;
-        }
+
+    if ((_fd = PR_Open(name, prflags, mode)) == NULL) {
+        return NULL;
     }
+
+    _opened = true;
+
+    if (ate &&
+            seekoff(0, ios_base::end, flags) == pos_type(traits_type::eof())) {
+        close();
+        return NULL;
+    }
+
     return this;
 }
 
-PRfilebuf*	
-PRfilebuf::attach(PRFileDesc *fd)
+
+PRfilebuf *PRfilebuf::attach(PRFileDesc *fd)
 {
-    _opened = PR_FALSE;
+    if (_fd != NULL) {
+        return NULL;  // Error if already open.
+    }
+
+    _opened = false;
     _fd = fd;
     return this;
 }
 
-int	
-PRfilebuf::overflow(int c)
+
+PRfilebuf *PRfilebuf::close()
 {
-    if (allocate()==EOF)        // make sure there is a reserve area
-        return EOF;
-    if (PRfilebuf::sync()==EOF) // sync before new buffer created below
-        return EOF;
-
-    if (!unbuffered())
-        setp(base(),ebuf());
-
-    if (c!=EOF){
-        if ((!unbuffered()) && (pptr() < epptr())) // guard against recursion
-            sputc(c);
-        else{
-            if (PR_Write(_fd, &c, 1)!=1)
-                return(EOF);
-        }
-    }
-    return(1);  // return something other than EOF if successful
-}
-
-int	
-PRfilebuf::underflow()
-{
-    int count;
-    unsigned char tbuf;
+    if (_fd == NULL)
+        return NULL;
 
-    if (in_avail())
-        return (int)(unsigned char) *gptr();
-
-    if (allocate()==EOF)        // make sure there is a reserve area
-        return EOF;
-    if (PRfilebuf::sync()==EOF)
-        return EOF;
-
-    if (unbuffered())
-        {
-        if (PR_Read(_fd,(void *)&tbuf,1)<=0)
-            return EOF;
-        return (int)tbuf;
-        }
+    int status = sync();
 
-    if ((count=PR_Read(_fd,(void *)base(),blen())) <= 0)
-        return EOF;     // reached EOF
-    setg(base(),base(),base()+count);
-    return (int)(unsigned char) *gptr();
-}
+    if (PR_Close(_fd) == PR_FAILURE ||
+            traits_type::eq_int_type(status, traits_type::eof())) {
+        return NULL;
+    }
 
-streambuf*	
-PRfilebuf::setbuf(char *buffptr, PRstreambuflen bufflen)
-{
-    if (is_open() && (ebuf()))
-        return 0;
-    if ((!buffptr) || (bufflen <= 0))
-        unbuffered(1);
-    else
-        setb(buffptr, buffptr+bufflen, 0);
+    _fd = NULL;
     return this;
 }
 
-streampos	
-PRfilebuf::seekoff(streamoff offset, ios::seek_dir dir, int /* mode */)
+
+streambuf *PRfilebuf::setbuf(char_type *ptr, streamsize len)
 {
-    if (PR_GetDescType(_fd) == PR_DESC_FILE){
-        PRSeekWhence fdir;
-        PRInt32 retpos;
-        switch (dir) {
-            case ios::beg :
-                fdir = PR_SEEK_SET;
-                break;
-            case ios::cur :
-                fdir = PR_SEEK_CUR;
-                break;
-            case ios::end :
-                fdir = PR_SEEK_END;
-                break;
-            default:
-            // error
-                return(EOF);
-            }
-
-        if (PRfilebuf::sync()==EOF)
-            return EOF;
-        if ((retpos=PR_Seek(_fd, offset, fdir))==-1L)
-            return (EOF);
-        return((streampos)retpos);
-    }else
-        return (EOF);
-}
-
-
-int 
-PRfilebuf::sync()
-{
-    PRInt32 count; 
-
-    if (_fd==0)
-        return(EOF);
+    if (is_open() && _buf_end) {
+        return NULL;
+    }
 
-    if (!unbuffered()){
-        // Sync write area
-        if ((count=out_waiting())!=0){
-            PRInt32 nout;
-            if ((nout =PR_Write(_fd,
-                               (void *) pbase(),
-                               (unsigned int)count)) != count){
-                if (nout > 0) {
-                    // should set _pptr -= nout
-                    pbump(-(int)nout);
-                    memmove(pbase(), pbase()+nout, (int)(count-nout));
-                }
-                return(EOF);
-            }
-        }
-        setp(0,0); // empty put area
+    if (!ptr || len <= 0) {
+        _unbuffered = true;
+    } else {
+        setb(ptr, ptr + len, false);
+    }
 
-        if (PR_GetDescType(_fd) == PR_DESC_FILE){
-            // Sockets can't seek; don't need this
-            if ((count=in_avail()) > 0){
-                if (PR_Seek(_fd, -count, PR_SEEK_CUR)!=-1L)
-                {
-                    return (EOF);
-                }
-            }
-        }
-        setg(0,0,0); // empty get area
-    }
-    return(0);
-}
-
-PRfilebuf * 
-PRfilebuf::close()
-{
-    int retval;
-    if (_fd==0)
-        return 0;
-
-    retval = sync();
-
-    if ((PR_Close(_fd)==0) || (retval==EOF))
-        return 0;
-    _fd = 0;
     return this;
 }
 
-PRifstream::PRifstream():
-istream(new PRfilebuf)
+
+streambuf::pos_type PRfilebuf::seekoff(
+    off_type offset, ios_base::seekdir dir, ios_base::openmode /*flags*/)
 {
-    _PRSTR_DELBUF(0);
-}
+    if (PR_GetDescType(_fd) != PR_DESC_FILE) {
+        return traits_type::eof();
+    }
+
+    PRSeekWhence whence;
+    PRInt64 pos;
 
-PRifstream::PRifstream(PRFileDesc *fd):
-istream(new PRfilebuf(fd))
-{
-    _PRSTR_DELBUF(0);
-}
+    switch (dir) {
+        case ios_base::beg: whence = PR_SEEK_SET; break;
+        case ios_base::cur: whence = PR_SEEK_CUR; break;
+        case ios_base::end: whence = PR_SEEK_END; break;
+        default:
+            return traits_type::eof();  // This should never happen.
+    }
 
-PRifstream::PRifstream(PRFileDesc *fd, char *buff, int bufflen):
-istream(new PRfilebuf(fd, buff, bufflen))
-{
-    _PRSTR_DELBUF(0);
+    if (traits_type::eq_int_type(sync(), traits_type::eof())) {
+        return traits_type::eof();
+    }
+
+    if ((pos = PR_Seek64(_fd, offset, whence)) == -1) {
+        return traits_type::eof();
+    }
+
+    return pos;
 }
 
-PRifstream::PRifstream(const char * name, int mode, int flags):
-istream(new PRfilebuf)
+
+int PRfilebuf::sync()
 {
-    _PRSTR_DELBUF(0);
-    if (!rdbuf()->open(name, (mode|ios::in), flags))
-        clear(rdstate() | ios::failbit);
-}
-
-PRifstream::~PRifstream()
-{
-	sync();
+    if (_fd == NULL) {
+        return traits_type::eof();
+    }
 
-	delete rdbuf();
-#ifdef _PRSTR_BP
-	_PRSTR_BP = 0;
-#endif
-}
+    if (!_unbuffered) {
+        // Sync write area.
+        PRInt32 waiting;
+        if ((waiting = pptr() - pbase()) != 0) {
+            PRInt32 nout;
+            if ((nout = PR_Write(_fd, pbase(), waiting)) != waiting) {
+                if (nout > 0) {
+                    // Should set _pptr -= nout.
+                    pbump(-nout);
+                    memmove(pbase(), pbase() + nout, waiting - nout);
+                }
+                return traits_type::eof();
+            }
+        }
+        setp(NULL, NULL);  // Empty put area.
 
-streambuf * 
-PRifstream::setbuf(char * ptr, int len)
-{
-    if ((is_open()) || (!(rdbuf()->setbuf(ptr, len)))){
-        clear(rdstate() | ios::failbit);
-        return 0;
+        if (PR_GetDescType(_fd) == PR_DESC_FILE) {
+            // Sockets can't seek; don't need this.
+            PROffset64 avail;
+            if ((avail = in_avail()) > 0) {
+                if (PR_Seek64(_fd, -avail, PR_SEEK_CUR) != -1) {
+                    return traits_type::eof();
+                }
+            }
+        }
+        setg(NULL, NULL, NULL);  // Empty get area.
     }
-    return rdbuf();
+
+    return 0;
 }
 
-void 
-PRifstream::attach(PRFileDesc *fd)
-{
-    if (!(rdbuf()->attach(fd)))
-        clear(rdstate() | ios::failbit);
-}
 
-void 
-PRifstream::open(const char * name, int mode, int flags)
+streambuf::int_type PRfilebuf::underflow()
 {
-    if (is_open() || !(rdbuf()->open(name, (mode|ios::in), flags)))
-        clear(rdstate() | ios::failbit);
-}
+    PRInt32 count;
+    char_type byte;
+
+    if (gptr() != NULL && gptr() < egptr()) {
+        return traits_type::to_int_type(*gptr());
+    }
+
+    // Make sure there is a reserve area.
+    if (!_unbuffered && _buf_base == NULL && !allocate()) {
+        return traits_type::eof();
+    }
 
-void 
-PRifstream::close()
-{
-    clear((rdbuf()->close()) ? 0 : (rdstate() | ios::failbit));
-}
+    // Sync before new buffer created below.
+    if (traits_type::eq_int_type(sync(), traits_type::eof())) {
+        return traits_type::eof();
+    }
+
+    if (_unbuffered) {
+        if (PR_Read(_fd, &byte, 1) <= 0) {
+            return traits_type::eof();
+        }
 
-PRofstream::PRofstream():
-ostream(new PRfilebuf)
-{
-    _PRSTR_DELBUF(0);
+        return traits_type::to_int_type(byte);
+    }
+
+    if ((count = PR_Read(_fd, _buf_base, _buf_end - _buf_base)) <= 0) {
+        return traits_type::eof();  // Reached EOF.
+    }
+
+    setg(_buf_base, _buf_base, _buf_base + count);
+    return traits_type::to_int_type(*gptr());
 }
 
-PRofstream::PRofstream(PRFileDesc *fd):
-ostream(new PRfilebuf(fd))
+
+streambuf::int_type PRfilebuf::overflow(int_type c)
 {
-    _PRSTR_DELBUF(0);
-}
+    // Make sure there is a reserve area.
+    if (!_unbuffered && _buf_base == NULL && !allocate()) {
+        return traits_type::eof();
+    }
+
+    // Sync before new buffer created below.
+    if (traits_type::eq_int_type(sync(), traits_type::eof())) {
+        return traits_type::eof();
+    }
+
+    if (!_unbuffered) {
+        setp(_buf_base, _buf_end);
+    }
 
-PRofstream::PRofstream(PRFileDesc *fd, char *buff, int bufflen):
-ostream(new PRfilebuf(fd, buff, bufflen))
-{
-    _PRSTR_DELBUF(0);
+    if (!traits_type::eq_int_type(c, traits_type::eof())) {
+        // Extract the byte to be written.
+        // (Required on big-endian architectures.)
+        char_type byte = traits_type::to_char_type(c);
+        if (!_unbuffered && pptr() < epptr()) {  // Guard against recursion.
+            return sputc(byte);
+        } else {
+            if (PR_Write(_fd, &byte, 1) != 1) {
+                return traits_type::eof();
+            }
+        }
+    }
+
+    return traits_type::not_eof(c);
 }
 
-PRofstream::PRofstream(const char *name, int mode, int flags):
-ostream(new PRfilebuf)
+
+bool PRfilebuf::allocate()
 {
-    _PRSTR_DELBUF(0);
-    if (!rdbuf()->open(name, (mode|ios::out), flags))
-        clear(rdstate() | ios::failbit);
+    char_type *buf = new(nothrow) char_type[BUFSIZ];
+    if (buf == NULL) {
+        return false;
+    }
+
+    setb(buf, buf + BUFSIZ, true);
+    return true;
 }
 
-PRofstream::~PRofstream()
+
+void PRfilebuf::setb(char_type *buf_base, char_type *buf_end, bool user_buf)
 {
-	flush();
+    if (_buf_base && !_user_buf) {
+        delete[] _buf_base;
+    }
 
-	delete rdbuf();
-#ifdef _PRSTR_BP
-	_PRSTR_BP = 0;
-#endif
+    _buf_base = buf_base;
+    _buf_end = buf_end;
+    _user_buf = user_buf;
+}
+
+
+PRifstream::PRifstream():
+    istream(NULL),
+    _filebuf()
+{
+    init(&_filebuf);
 }
 
-streambuf * 
-PRofstream::setbuf(char * ptr, int len)
+
+PRifstream::PRifstream(PRFileDesc *fd):
+    istream(NULL),
+    _filebuf(fd)
 {
-    if ((is_open()) || (!(rdbuf()->setbuf(ptr, len)))){
-        clear(rdstate() | ios::failbit);
-        return 0;
-    }
-    return rdbuf();
+    init(&_filebuf);
+}
+
+
+PRifstream::PRifstream(PRFileDesc *fd, char_type *ptr, streamsize len):
+    istream(NULL),
+    _filebuf(fd, ptr, len)
+{
+    init(&_filebuf);
 }
 
-void 
-PRofstream::attach(PRFileDesc *fd)
+
+PRifstream::PRifstream(const char *name, openmode flags, PRIntn mode):
+    istream(NULL),
+    _filebuf()
 {
-    if (!(rdbuf()->attach(fd)))
-        clear(rdstate() | ios::failbit);
+    init(&_filebuf);
+    if (!_filebuf.open(name, flags | in, mode)) {
+        setstate(failbit);
+    }
 }
 
-void 
-PRofstream::open(const char * name, int mode, int flags)
+
+PRifstream::~PRifstream() { }
+
+
+void PRifstream::open(const char *name, openmode flags, PRIntn mode)
 {
-    if (is_open() || !(rdbuf()->open(name, (mode|ios::out), flags)))
-        clear(rdstate() | ios::failbit);
+    if (is_open() || !_filebuf.open(name, flags | in, mode)) {
+        setstate(failbit);
+    }
 }
 
-void 
-PRofstream::close()
+
+void PRifstream::attach(PRFileDesc *fd)
 {
-    clear((rdbuf()->close()) ? 0 : (rdstate() | ios::failbit));
+    if (!_filebuf.attach(fd)) {
+        setstate(failbit);
+    }
 }
 
-PRfstream::PRfstream():
-iostream(new PRfilebuf)
+
+void PRifstream::close()
 {
-	_PRSTR_DELBUF_C(istream, 0);
-	_PRSTR_DELBUF_C(ostream, 0);
+    if (_filebuf.close() == NULL) {
+        setstate(failbit);
+    }
+}
+
+
+PRofstream::PRofstream():
+    ostream(NULL),
+    _filebuf()
+{
+    init(&_filebuf);
 }
 
-PRfstream::PRfstream(PRFileDesc *fd):
-iostream(new PRfilebuf(fd))
+
+PRofstream::PRofstream(PRFileDesc *fd):
+    ostream(NULL),
+    _filebuf(fd)
 {
-	_PRSTR_DELBUF_C(istream, 0);
-	_PRSTR_DELBUF_C(ostream, 0);
+    init(&_filebuf);
 }
 
-PRfstream::PRfstream(PRFileDesc *fd, char *buff, int bufflen):
-iostream(new PRfilebuf(fd, buff, bufflen))
+
+PRofstream::PRofstream(PRFileDesc *fd, char_type *ptr, streamsize len):
+    ostream(NULL),
+    _filebuf(fd, ptr, len)
 {
-	_PRSTR_DELBUF_C(istream, 0);
-	_PRSTR_DELBUF_C(ostream, 0);
+    init(&_filebuf);
+}
+
+
+PRofstream::PRofstream(const char *name, openmode flags, PRIntn mode):
+    ostream(NULL),
+    _filebuf()
+{
+    init(&_filebuf);
+    if (!_filebuf.open(name, flags | out, mode)) {
+        setstate(failbit);
+    }
 }
 
-PRfstream::PRfstream(const char *name, int mode, int flags):
-iostream(new PRfilebuf)
+
+PRofstream::~PRofstream() { }
+
+
+void PRofstream::open(const char *name, openmode flags, PRIntn mode)
 {
-	_PRSTR_DELBUF_C(istream, 0);
-	_PRSTR_DELBUF_C(ostream, 0);
-    if (!rdbuf()->open(name, (mode|(ios::in|ios::out)), flags))
-        clear(rdstate() | ios::failbit);
+    if (is_open() || !_filebuf.open(name, flags | out, mode)) {
+        setstate(failbit);
+    }
+}
+
+
+void PRofstream::attach(PRFileDesc *fd)
+{
+    if (!_filebuf.attach(fd)) {
+        setstate(failbit);
+    }
 }
 
-PRfstream::~PRfstream()
+
+void PRofstream::close()
 {
-	sync();
-	flush();
+    if (_filebuf.close() == NULL) {
+        setstate(failbit);
+    }
+}
+
 
-	delete rdbuf();
-#ifdef _PRSTR_BP
-	istream::_PRSTR_BP = 0;
-	ostream::_PRSTR_BP = 0;
-#endif
+PRfstream::PRfstream():
+    iostream(NULL),
+    _filebuf()
+{
+    init(&_filebuf);
+}
+
+
+PRfstream::PRfstream(PRFileDesc *fd):
+    iostream(NULL),
+    _filebuf(fd)
+{
+    init(&_filebuf);
 }
 
-streambuf * 
-PRfstream::setbuf(char * ptr, int len)
+
+PRfstream::PRfstream(PRFileDesc *fd, char_type *ptr, streamsize len):
+    iostream(NULL),
+    _filebuf(fd, ptr, len)
 {
-    if ((is_open()) || (!(rdbuf()->setbuf(ptr, len)))){
-        clear(rdstate() | ios::failbit);
-        return 0;
-    }
-    return rdbuf();
+    init(&_filebuf);
 }
 
-void 
-PRfstream::attach(PRFileDesc *fd)
+
+PRfstream::PRfstream(const char *name, openmode flags, PRIntn mode):
+    iostream(NULL),
+    _filebuf()
 {
-    if (!(rdbuf()->attach(fd)))
-        clear(rdstate() | ios::failbit);
+    init(&_filebuf);
+    if (!_filebuf.open(name, flags | in | out, mode)) {
+        setstate(failbit);
+    }
 }
 
-void 
-PRfstream::open(const char * name, int mode, int flags)
+
+PRfstream::~PRfstream() { }
+
+
+void PRfstream::open(const char *name, openmode flags, PRIntn mode)
 {
-    if (is_open() || !(rdbuf()->open(name, (mode|(ios::in|ios::out)), flags)))
-        clear(rdstate() | ios::failbit);
+    if (is_open() || !_filebuf.open(name, flags | in | out, mode)) {
+        setstate(failbit);
+    }
 }
 
-void 
-PRfstream::close()
+
+void PRfstream::attach(PRFileDesc *fd)
 {
-    clear((rdbuf()->close()) ? 0 : (rdstate() | ios::failbit));
+    if (!_filebuf.attach(fd)) {
+        setstate(failbit);
+    }
 }
 
-#else
 
-// fix it sometime
-
-int fix_prfstreams ()	{	return 0; }
-
-#endif
+void PRfstream::close()
+{
+    if (_filebuf.close() == NULL) {
+        setstate(failbit);
+    }
+}
--- a/nsprpub/lib/prstreams/prstrms.h
+++ b/nsprpub/lib/prstreams/prstrms.h
@@ -32,122 +32,141 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /*
  * Robin J. Maxwell 11-22-96
+ * Fredrik Roubert <roubert@google.com> 2010-07-23
+ * Matt Austern <austern@google.com> 2010-07-23
  */
 
 #ifndef _PRSTRMS_H
 #define _PRSTRMS_H
 
-#include "prtypes.h"
+#include <cstddef>
+#include <istream>
+#include <ostream>
+#include <streambuf>
+
 #include "prio.h"
 
 #ifdef _MSC_VER
-#pragma warning( disable : 4275)
-#endif
-#include <iostream.h>
-
-#if defined(AIX) && defined(__64BIT__)
-typedef long PRstreambuflen;
-#else
-typedef int PRstreambuflen;
+// http://support.microsoft.com/kb/q168958/
+class PR_IMPLEMENT(std::_Mutex);
+class PR_IMPLEMENT(std::ios_base);
 #endif
 
-#if defined (PRFSTREAMS_BROKEN)
 
-// fix it sometime
-
-#define	 PRfilebuf	streambuf
-#define  PRifstream	ifstream
-#define	 PRofstream	ofstream
-#define	 PRfstream	fstream
-
-#else
-
-class PR_IMPLEMENT(PRfilebuf): public streambuf
+class PR_IMPLEMENT(PRfilebuf): public std::streambuf
 {
 public:
     PRfilebuf();
     PRfilebuf(PRFileDesc *fd);
-    PRfilebuf(PRFileDesc *fd, char * buffptr, int bufflen);
-    ~PRfilebuf();
-    virtual	int	overflow(int=EOF);
-    virtual	int	underflow();
-    virtual	streambuf *setbuf(char *buff, PRstreambuflen bufflen);
-    virtual	streampos seekoff(streamoff, ios::seek_dir, int);
+    PRfilebuf(PRFileDesc *fd, char_type *ptr, std::streamsize len);
+    virtual ~PRfilebuf();
+
+    bool is_open() const { return _fd != NULL; }
+
+    PRfilebuf *open(
+                  const char *name,
+                  std::ios_base::openmode flags,
+                  PRIntn mode);
+    PRfilebuf *attach(PRFileDesc *fd);
+    PRfilebuf *close();
+
+protected:
+    virtual std::streambuf *setbuf(char_type *ptr, std::streamsize len);
+    virtual pos_type seekoff(
+                         off_type offset,
+                         std::ios_base::seekdir dir,
+                         std::ios_base::openmode flags);
+    virtual pos_type seekpos(
+                         pos_type pos,
+                         std::ios_base::openmode flags) {
+        return seekoff(pos, std::ios_base::beg, flags);
+    }
     virtual int sync();
-    PRfilebuf *open(const char *name, int mode, int flags);
-   	PRfilebuf *attach(PRFileDesc *fd);
-    PRfilebuf *close();
-   	int	is_open() const {return (_fd != 0);}
-    PRFileDesc *fd(){return _fd;}
+    virtual int_type underflow();
+    virtual int_type overflow(int_type c = traits_type::eof());
+
+    // TODO: Override pbackfail(), showmanyc(), uflow(), xsgetn(), and xsputn().
 
 private:
-    PRFileDesc * _fd;
-    PRBool _opened;
-	PRBool _allocated;
-};
+    bool allocate();
+    void setb(char_type *buf_base, char_type *buf_end, bool user_buf);
 
-class PR_IMPLEMENT(PRifstream): public istream {
-public:
-	PRifstream();
-	PRifstream(const char *, int mode=ios::in, int flags = 0);
-	PRifstream(PRFileDesc *);
-	PRifstream(PRFileDesc *, char *, int);
-	~PRifstream();
-
-	streambuf * setbuf(char *, int);
-	PRfilebuf* rdbuf(){return (PRfilebuf*) ios::rdbuf(); }
-
-	void attach(PRFileDesc *fd);
-	PRFileDesc *fd() {return rdbuf()->fd();}
-
-	int is_open(){return rdbuf()->is_open();}
-	void open(const char *, int mode=ios::in, int flags= 0);
-	void close();
+    PRFileDesc *_fd;
+    bool _opened;
+    bool _allocated;
+    bool _unbuffered;
+    bool _user_buf;
+    char_type *_buf_base;
+    char_type *_buf_end;
 };
 
-class PR_IMPLEMENT(PRofstream) : public ostream {
+
+class PR_IMPLEMENT(PRifstream): public std::istream
+{
 public:
-	PRofstream();
-	PRofstream(const char *, int mode=ios::out, int flags = 0);
-	PRofstream(PRFileDesc *);
-	PRofstream(PRFileDesc *, char *, int);
-	~PRofstream();
-
-	streambuf * setbuf(char *, int);
-	PRfilebuf* rdbuf() { return (PRfilebuf*) ios::rdbuf(); }
-
-	void attach(PRFileDesc *);
-	PRFileDesc *fd() {return rdbuf()->fd();}
+    PRifstream();
+    PRifstream(PRFileDesc *fd);
+    PRifstream(PRFileDesc *fd, char_type *ptr, std::streamsize len);
+    PRifstream(const char *name, openmode flags = in, PRIntn mode = 0);
+    virtual ~PRifstream();
 
-	int is_open(){return rdbuf()->is_open();}
-	void open(const char *, int =ios::out, int = 0);
-	void close();
-};
-	
-class PR_IMPLEMENT(PRfstream) : public iostream {
-public:
-	PRfstream();
-	PRfstream(const char *name, int mode, int flags= 0);
-	PRfstream(PRFileDesc *fd);
-	PRfstream(PRFileDesc *fd, char *buff, int bufflen);
-	~PRfstream();
+    PRfilebuf *rdbuf() const { return &_filebuf; }
+    bool is_open() const { return _filebuf.is_open(); }
 
-	streambuf * setbuf(char *, int);
-	PRfilebuf* rdbuf(){ return (PRfilebuf*) ostream::rdbuf(); }
+    void open(const char *name, openmode flags = in, PRIntn mode = 0);
+    void attach(PRFileDesc *fd);
+    void close();
 
-	void attach(PRFileDesc *);
-	PRFileDesc *fd() { return rdbuf()->fd(); }
-
-	int is_open() { return rdbuf()->is_open(); }
-	void open(const char *, int, int = 0);
-	void close();
+private:
+    mutable PRfilebuf _filebuf;
 };
 
-#endif
+
+class PR_IMPLEMENT(PRofstream): public std::ostream
+{
+public:
+    PRofstream();
+    PRofstream(PRFileDesc *fd);
+    PRofstream(PRFileDesc *fd, char_type *ptr, std::streamsize len);
+    PRofstream(const char *name, openmode flags = out, PRIntn mode = 0);
+    virtual ~PRofstream();
+
+    PRfilebuf *rdbuf() const { return &_filebuf; }
+    bool is_open() const { return _filebuf.is_open(); }
+
+    void open(const char *name, openmode flags = out, PRIntn mode = 0);
+    void attach(PRFileDesc *fd);
+    void close();
+
+private:
+    mutable PRfilebuf _filebuf;
+};
+
+
+class PR_IMPLEMENT(PRfstream): public std::iostream
+{
+public:
+    PRfstream();
+    PRfstream(PRFileDesc *fd);
+    PRfstream(PRFileDesc *fd, char_type *ptr, std::streamsize len);
+    PRfstream(const char *name, openmode flags = in | out, PRIntn mode = 0);
+    virtual ~PRfstream();
+
+    PRfilebuf *rdbuf() const { return &_filebuf; }
+    bool is_open() const { return _filebuf.is_open(); }
+
+    void open(const char *name, openmode flags = in | out, PRIntn mode = 0);
+    void attach(PRFileDesc *fd);
+    void close();
+
+private:
+    mutable PRfilebuf _filebuf;
+};
+
 
 #endif /* _PRSTRMS_H */
--- a/nsprpub/lib/prstreams/tests/testprstrm/testprstrm.cpp
+++ b/nsprpub/lib/prstreams/tests/testprstrm/testprstrm.cpp
@@ -30,67 +30,71 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "prstrms.h"
+
 #include "prinit.h"
-#include "prstrms.h"
 #include "prio.h"
-#include <string.h>
-#include <stdio.h>
-#if defined(XP_UNIX) || defined(XP_OS2)
-#include <sys/types.h>
+#include "prthread.h"
+
+#include <cstring>
+#include <iostream>
+
+#ifdef XP_UNIX
 #include <sys/stat.h>
 #endif
 
+using std::cout;
+using std::endl;
+using std::ios;
+
 const unsigned int MaxCnt = 1;
 
-void threadwork(void *mytag);
-
+typedef struct threadarg {
+    const char *mytag;
+} threadarg;
 
-typedef struct threadarg {
-    void *mytag;
-} threadarg;
+void threadwork(threadarg *arg);
 
 void 
 threadmain(void *mytag)
 {
     threadarg arg;
 
-    arg.mytag = mytag;
+    arg.mytag = static_cast<const char *>(mytag);
 
     threadwork(&arg);
 }
 
-
 void
-threadwork(void *_arg)
+threadwork(threadarg *arg)
 {
-	threadarg *arg = (threadarg *)_arg;
 	unsigned int i;
 
 	char fname1[256];
 	char fname2[256];
 
-	strcpy(fname1, (char *)arg->mytag);
-	strcpy(fname2, (char *)arg->mytag);
+	strcpy(fname1, arg->mytag);
+	strcpy(fname2, arg->mytag);
 	strcat(fname2, "2");
 	PR_Delete(fname1);
 	PR_Delete(fname2);
 
 	PRfilebuf *fb[MaxCnt];
 	PRifstream *ifs[MaxCnt];
 	PRofstream *ofs[MaxCnt];
 	int mode = 0;
 #ifdef XP_UNIX
-	mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IRGRP|S_IWOTH|S_IROTH;
+	mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
 #endif
 
 	//
 	// Allocate a bunch
 	cout << "Testing unused filebufs ----------------" << endl;
 	for (i=0; i < MaxCnt; i++){
 		fb[i] = new PRfilebuf;
 	}
@@ -162,40 +166,38 @@ threadwork(void *_arg)
 		*ais2 >> achar;
 	}
 	delete ais2;
 	cout << "Testing use of ifstream 2 complete -------------" << endl;
 }
 
 #define STACKSIZE 1024*1024
 int
-main(int argc, char **argv)
+main()
 {
 	PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 256);
-	threadmain("TestFile");
+	threadmain(const_cast<char *>("TestFile"));
 	PRThread *thr1 = PR_CreateThread(PR_SYSTEM_THREAD, 
 					 threadmain, 
-					 (void *)"TestFile1",
+					 const_cast<char *>("TestFile1"),
 					 PR_PRIORITY_NORMAL,
 					 PR_GLOBAL_THREAD,
 					 PR_JOINABLE_THREAD,
 					 STACKSIZE);
 	PRThread *thr2 = PR_CreateThread(PR_SYSTEM_THREAD, 
 					 threadmain, 
-					 (void *)"TestFile2",
+					 const_cast<char *>("TestFile2"),
 					 PR_PRIORITY_NORMAL,
 					 PR_GLOBAL_THREAD,
 					 PR_JOINABLE_THREAD,
 					 STACKSIZE);
-
 	PRThread *thr3 = PR_CreateThread(PR_SYSTEM_THREAD, 
 					 threadmain, 
-					 (void *)"TestFile3",
+					 const_cast<char *>("TestFile3"),
 					 PR_PRIORITY_NORMAL,
 					 PR_GLOBAL_THREAD,
 					 PR_JOINABLE_THREAD,
 					 STACKSIZE);
 	PR_JoinThread(thr1);
 	PR_JoinThread(thr2);
 	PR_JoinThread(thr3);
 	return 0;
 }
-
--- a/nsprpub/lib/tests/Makefile.in
+++ b/nsprpub/lib/tests/Makefile.in
@@ -47,21 +47,21 @@ include $(MOD_DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/config.mk
 
 CSRCS = \
 	arena.c \
 	base64t.c \
 	getopt.c \
 	string.c
 
-ifeq (,$(filter-out WINNT OS2,$(OS_ARCH)))
+ifeq (,$(filter-out WINCE WINNT OS2,$(OS_ARCH)))
 CSRCS += arena.c
 endif
 
-ifeq (,$(filter-out WINNT OS2,$(OS_ARCH)))
+ifeq (,$(filter-out WINCE WINNT OS2,$(OS_ARCH)))
 PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS) $(OBJS)
@@ -70,19 +70,19 @@ INCLUDES = -I$(dist_includedir)
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
 LDOPTS = -L$(dist_libdir)
 LIBPR = -lnspr$(MOD_MAJOR_VERSION)
 LIBPLC = -lplc$(MOD_MAJOR_VERSION)
 LIBPLDS = -lplds$(MOD_MAJOR_VERSION)
 
-ifeq ($(OS_ARCH), WINNT)
+ifeq (,$(filter-out WINCE WINNT, $(OS_ARCH)))
   LDOPTS = -NOLOGO -DEBUG -INCREMENTAL:NO
-  ifeq ($(OS_TARGET), WIN95)
+  ifeq (,$(filter-out WIN95 WINCE WINMO, $(OS_TARGET)))
   LIBPR = $(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
   LIBPLC= $(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
   LIBPLDS= $(dist_libdir)/plds$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
   else
   LIBPR = $(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
   LIBPLC= $(dist_libdir)/libplc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
   LIBPLDS= $(dist_libdir)/libplds$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)
   endif
@@ -157,16 +157,20 @@ ifeq ($(OS_ARCH), NCR)
 # system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
 export LD_RUN_PATH = $(PWD)/$(dist_libdir)
 endif
 
+ifeq ($(OS_TARGET),Android)
+LDOPTS = $(OS_LDFLAGS) $(WRAP_MALLOC_LIB)
+endif
+
 #####################################################
 #
 # The rules
 #
 #####################################################
 
 include $(topsrcdir)/config/rules.mk
 
@@ -201,19 +205,23 @@ else
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 
 ifeq ($(OS_ARCH), WINNT)
 	link $(LDOPTS) $< $(LIBPLC) $(LIBPLDS) $(LIBPR) wsock32.lib -out:$@
 else
+ifeq ($(OS_ARCH), WINCE)
+	$(LD) $(LDOPTS) $< $(LIBPLC) $(LIBPLDS) $(LIBPR) ws2.lib -out:$@
+else
 ifeq ($(OS_ARCH),OS2)
 	$(LINK) $(EXEFLAGS) $(LDOPTS) $< $(LIBPLC)  $(LIBPLDS) $(LIBPR) $(OS_LIBS) $(EXTRA_LIBS)
 else
 	$(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBPLDS) $(LIBPR) $(EXTRA_LIBS) -o $@
 endif
 endif
 endif
+endif
 
 export:: $(TARGETS)
 clean::
 	rm -f $(TARGETS)
--- a/nsprpub/pr/include/prinit.h
+++ b/nsprpub/pr/include/prinit.h
@@ -58,20 +58,20 @@ PR_BEGIN_EXTERN_C
 /*
 ** NSPR's version is used to determine the likelihood that the version you
 ** used to build your component is anywhere close to being compatible with
 ** what is in the underlying library.
 **
 ** The format of the version string is
 **     "<major version>.<minor version>[.<patch level>] [<Beta>]"
 */
-#define PR_VERSION  "4.8.6 Beta 3"
+#define PR_VERSION  "4.8.7 Beta"
 #define PR_VMAJOR   4
 #define PR_VMINOR   8
-#define PR_VPATCH   6
+#define PR_VPATCH   7
 #define PR_BETA     PR_TRUE
 
 /*
 ** PRVersionCheck
 **
 ** The basic signature of the function that is called to provide version
 ** checking. The result will be a boolean that indicates the likelihood
 ** that the underling library will perform as the caller expects.
--- a/nsprpub/pr/include/private/primpl.h
+++ b/nsprpub/pr/include/private/primpl.h
@@ -187,22 +187,17 @@ struct _PT_Notified
 
 #define _PT_THREAD_INTERRUPTED(thr)					\
 		(!(thr->interrupt_blocked) && (thr->state & PT_THREAD_ABORTED))
 #define _PT_THREAD_BLOCK_INTERRUPT(thr)				\
 		(thr->interrupt_blocked = 1)
 #define _PT_THREAD_UNBLOCK_INTERRUPT(thr)			\
 		(thr->interrupt_blocked = 0)
 
-#ifdef GC_LEAK_DETECTOR
-/* All threads are GCable. */
-#define _PT_IS_GCABLE_THREAD(thr) 1
-#else
 #define _PT_IS_GCABLE_THREAD(thr) ((thr)->state & PT_THREAD_GCABLE)
-#endif /* GC_LEAK_DETECTOR */
 
 /* 
 ** Possible values for thread's suspend field
 ** Note that the first two can be the same as they are really mutually exclusive,
 ** i.e. both cannot be happening at the same time. We have two symbolic names
 ** just as a mnemonic.
 **/
 #define PT_THREAD_RESUMED   0x80    /* thread has been resumed */
@@ -628,22 +623,17 @@ NSPR_API(void) _PR_Notify(PRMonitor *mon
                 stackSize = _MD_MINIMUM_STACK_SIZE; \
     stackSize = (stackSize + (1 << _pr_pageShift) - 1) >> _pr_pageShift; \
     stackSize <<= _pr_pageShift; \
         PR_END_MACRO
 #else
 #define        _PR_ADJUST_STACKSIZE(stackSize)
 #endif
 
-#ifdef GC_LEAK_DETECTOR
-/* All threads are GCable. */
-#define _PR_IS_GCABLE_THREAD(thr) 1
-#else
 #define _PR_IS_GCABLE_THREAD(thr) ((thr)->flags & _PR_GCABLE_THREAD)
-#endif /* GC_LEAK_DETECTOR */
 
 #define _PR_PENDING_INTERRUPT(thr)					\
 		(!((thr)->flags & _PR_INTERRUPT_BLOCKED) && ((thr)->flags & _PR_INTERRUPT))
 #define _PR_THREAD_BLOCK_INTERRUPT(thr)			\
 		(thr->flags |= _PR_INTERRUPT_BLOCKED)
 #define _PR_THREAD_UNBLOCK_INTERRUPT(thr)			\
 		(thr->flags &= ~_PR_INTERRUPT_BLOCKED)
 
@@ -1798,19 +1788,16 @@ extern void _PR_CleanupStacks(void);
 #ifdef WINNT
 extern void _PR_CleanupCPUs(void);
 #endif
 extern void _PR_CleanupThreads(void);
 extern void _PR_CleanupTPD(void);
 extern void _PR_Cleanup(void);
 extern void _PR_LogCleanup(void);
 extern void _PR_InitLayerCache(void);
-#ifdef GC_LEAK_DETECTOR
-extern void _PR_InitGarbageCollector(void);
-#endif
 
 extern PRBool _pr_initialized;
 extern void _PR_ImplicitInitialization(void);
 extern PRBool _PR_Obsolete(const char *obsolete, const char *preferred);
 
 /************************************************************************/
 
 struct PRSegment {
old mode 100644
new mode 100755
--- a/nsprpub/pr/src/Makefile.in
+++ b/nsprpub/pr/src/Makefile.in
@@ -200,24 +200,24 @@ else
 OS_LIBS		= advapi32.lib wsock32.lib winmm.lib
 endif
 endif
 
 ifeq ($(OS_ARCH),WINCE)
 OS_LIBS		= ws2.lib
 endif
 
+ifeq ($(OS_TARGET),Android)
+OS_LIBS		+= -llog
+endif
+
 ifeq ($(OS_TARGET),MacOSX)
 OS_LIBS		= -framework CoreServices -framework CoreFoundation
 endif
 
-ifdef GC_LEAK_DETECTOR
-EXTRA_LIBS	= -L$(dist_libdir) -lboehm
-endif
-
 EXTRA_LIBS += $(OS_LIBS)
 
 #
 # Define platform-dependent OBJS
 #
 
 OBJS = \
     $(OBJDIR)/prvrsion.$(OBJ_SUFFIX) \
@@ -304,20 +304,16 @@ OBJS += \
 	cplus/$(OBJDIR)/rcio.$(OBJ_SUFFIX) \
 	cplus/$(OBJDIR)/rclock.$(OBJ_SUFFIX) \
 	cplus/$(OBJDIR)/rcnetdb.$(OBJ_SUFFIX) \
 	cplus/$(OBJDIR)/rcnetio.$(OBJ_SUFFIX) \
 	cplus/$(OBJDIR)/rcthread.$(OBJ_SUFFIX) \
 	cplus/$(OBJDIR)/rctime.$(OBJ_SUFFIX)
 endif
 
-ifdef GC_LEAK_DETECTOR
-OBJS += memory/$(OBJDIR)/prgcleak.$(OBJ_SUFFIX)
-endif
-
 ifeq ($(OS_ARCH), WINNT)
 RES=$(OBJDIR)/nspr.res
 RESNAME=nspr.rc
 endif # WINNT
 
 include $(srcdir)/md/$(PR_MD_ARCH_DIR)/objs.mk
 ifdef USE_BTHREADS
 include $(srcdir)/bthreads/objs.mk
@@ -379,22 +375,29 @@ ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
 else
 	$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<
 endif
 #
 # Version information generation (end)
 #
 
 
+# We use a 'build' target here to ensure that we build $(TARGETS) after
+# looping over $(DIRS) to create the object files in a parallel build.
+# Recipe commands are executed sequentially in a parallel build while
+# target dependencies are executed in parallel.
+export::
+	$(MAKE) build
+
 #
 # The Client build wants the shared libraries in $(dist_bindir)
 # so we also install them there.
 #
 
-export:: $(TARGETS)
+build:: $(TARGETS)
 	$(INSTALL) -m 444 $(TARGETS) $(dist_libdir)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
 	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_libdir)
 	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_bindir)
 else
 	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_bindir)
 endif
old mode 100644
new mode 100755
--- a/nsprpub/pr/src/io/prlog.c
+++ b/nsprpub/pr/src/io/prlog.c
@@ -36,16 +36,19 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "primpl.h"
 #include "prenv.h"
 #include "prprf.h"
 #include <string.h>
+#ifdef ANDROID
+#include <android/log.h>
+#endif
 
 /*
  * Lock used to lock the log.
  *
  * We can't define _PR_LOCK_LOG simply as PR_Lock because PR_Lock may
  * contain assertions.  We have to avoid assertions in _PR_LOCK_LOG
  * because PR_ASSERT calls PR_LogPrint, which in turn calls _PR_LOCK_LOG.
  * This can lead to infinite recursion.
@@ -121,16 +124,28 @@ static void OutputDebugStringA(const cha
         buf[nb] = savebyte; \
     } else { \
         fwrite(buf, 1, nb, fd); \
         fflush(fd); \
     } \
     PR_END_MACRO
 #elif defined(_PR_USE_STDIO_FOR_LOGGING)
 #define _PUT_LOG(fd, buf, nb) {fwrite(buf, 1, nb, fd); fflush(fd);}
+#elif defined(ANDROID)
+#define _PUT_LOG(fd, buf, nb)                                \
+    PR_BEGIN_MACRO                                           \
+    if (fd == _pr_stderr) {                                  \
+        char savebyte = buf[nb];                             \
+        buf[nb] = '\0';                                      \
+        __android_log_write(ANDROID_LOG_INFO, "PRLog", buf); \
+        buf[nb] = savebyte;                                  \
+    } else {                                                 \
+        PR_Write(fd, buf, nb);                               \
+    }                                                        \
+    PR_END_MACRO
 #elif defined(_PR_PTHREADS)
 #define _PUT_LOG(fd, buf, nb) PR_Write(fd, buf, nb)
 #else
 #define _PUT_LOG(fd, buf, nb) _PR_MD_WRITE(fd, buf, nb)
 #endif
 
 /************************************************************************/
 
--- a/nsprpub/pr/src/linking/prlink.c
+++ b/nsprpub/pr/src/linking/prlink.c
@@ -480,20 +480,26 @@ static NSModule
 pr_LoadMachDyldModule(const char *name)
 {
     NSObjectFileImage ofi;
     NSModule h = NULL;
     if (NSCreateObjectFileImageFromFile(name, &ofi)
             == NSObjectFileImageSuccess) {
         h = NSLinkModule(ofi, name, NSLINKMODULE_OPTION_PRIVATE
                          | NSLINKMODULE_OPTION_RETURN_ON_ERROR);
-        /*
-         * TODO: If NSLinkModule fails, use NSLinkEditError to retrieve
-         * error information.
-         */
+        if (h == NULL) {
+            NSLinkEditErrors linkEditError;
+            int errorNum;
+            const char *fileName;
+            const char *errorString;
+            NSLinkEditError(&linkEditError, &errorNum, &fileName, &errorString);
+            PR_LOG(_pr_linker_lm, PR_LOG_MIN, 
+                   ("LoadMachDyldModule error %d:%d for file %s:\n%s",
+                    linkEditError, errorNum, fileName, errorString));
+        }
         if (NSDestroyObjectFileImage(ofi) == FALSE) {
             if (h) {
                 (void)NSUnLinkModule(h, NSUNLINKMODULE_OPTION_NONE);
                 h = NULL;
             }
         }
     }
     return h;
@@ -643,18 +649,18 @@ pr_LoadViaDyld(const char *name, PRLibra
 {
     lm->dlh = pr_LoadMachDyldModule(name);
     if (lm->dlh == NULL) {
         lm->image = NSAddImage(name, NSADDIMAGE_OPTION_RETURN_ON_ERROR
                                | NSADDIMAGE_OPTION_WITH_SEARCHING);
         if (lm->image == NULL) {
             NSLinkEditErrors linkEditError;
             int errorNum;
+            const char *fileName;
             const char *errorString;
-            const char *fileName;
             NSLinkEditError(&linkEditError, &errorNum, &fileName, &errorString);
             PR_LOG(_pr_linker_lm, PR_LOG_MIN, 
                    ("LoadMachDyldModule error %d:%d for file %s:\n%s",
                     linkEditError, errorNum, fileName, errorString));
         }
     }
     return (lm->dlh != NULL || lm->image != NULL) ? PR_SUCCESS : PR_FAILURE;
 }
--- a/nsprpub/pr/src/md/windows/ntmisc.c
+++ b/nsprpub/pr/src/md/windows/ntmisc.c
@@ -592,16 +592,17 @@ PRProcess * _PR_CreateWindowsProcess(
 #ifdef WINCE
     STARTUPINFOW startupInfo;
     PRUnichar *wideCmdLine;
     PRUnichar *wideCwd;
     int len = 0;
 #else
     STARTUPINFO startupInfo;
 #endif
+    DWORD creationFlags = 0;
     PROCESS_INFORMATION procInfo;
     BOOL retVal;
     char *cmdLine = NULL;
     char *envBlock = NULL;
     char **newEnvp = NULL;
     const char *cwd = NULL; /* current working directory */
     PRProcess *proc = NULL;
     PRBool hasFdInheritBuffer;
@@ -672,16 +673,22 @@ PRProcess * _PR_CreateWindowsProcess(
         startupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
         if (attr->stdinFd) {
             startupInfo.hStdInput = (HANDLE) attr->stdinFd->secret->md.osfd;
             redirected = PR_TRUE;
         }
         if (attr->stdoutFd) {
             startupInfo.hStdOutput = (HANDLE) attr->stdoutFd->secret->md.osfd;
             redirected = PR_TRUE;
+            /*
+             * If stdout is redirected, we can assume that the process will
+             * not write anything useful to the console windows, and therefore
+             * automatically set the CREATE_NO_WINDOW flag.
+             */
+            creationFlags |= CREATE_NO_WINDOW;
         }
         if (attr->stderrFd) {
             startupInfo.hStdError = (HANDLE) attr->stderrFd->secret->md.osfd;
             redirected = PR_TRUE;
         }
         if (redirected) {
             startupInfo.dwFlags |= STARTF_USESTDHANDLES;
         }
@@ -698,17 +705,17 @@ PRProcess * _PR_CreateWindowsProcess(
     MultiByteToWideChar(CP_ACP, 0, cwd, -1, wideCwd, len);
     retVal = CreateProcessW(NULL,
                             wideCmdLine,
                             NULL,  /* security attributes for the new
                                     * process */
                             NULL,  /* security attributes for the primary
                                     * thread in the new process */
                             TRUE,  /* inherit handles */
-                            0,     /* creation flags */
+                            creationFlags,
                             envBlock,  /* an environment block, consisting
                                         * of a null-terminated block of
                                         * null-terminated strings.  Each
                                         * string is in the form:
                                         *     name=value
                                         * XXX: usually NULL */
                             wideCwd,  /* current drive and directory */
                             &startupInfo,
@@ -719,17 +726,17 @@ PRProcess * _PR_CreateWindowsProcess(
 #else
     retVal = CreateProcess(NULL,
                            cmdLine,
                            NULL,  /* security attributes for the new
                                    * process */
                            NULL,  /* security attributes for the primary
                                    * thread in the new process */
                            TRUE,  /* inherit handles */
-                           0,     /* creation flags */
+                           creationFlags,
                            envBlock,  /* an environment block, consisting
                                        * of a null-terminated block of
                                        * null-terminated strings.  Each
                                        * string is in the form:
                                        *     name=value
                                        * XXX: usually NULL */
                            cwd,  /* current drive and directory */
                            &startupInfo,
--- a/nsprpub/pr/src/memory/Makefile.in
+++ b/nsprpub/pr/src/memory/Makefile.in
@@ -43,27 +43,19 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(MOD_DEPTH)/config/autoconf.mk
 
 include $(topsrcdir)/config/config.mk
 
 CSRCS = prseg.c prshm.c prshma.c
 
-ifdef GC_LEAK_DETECTOR
-CSRCS += prgcleak.c
-endif
-
 TARGETS	= $(OBJS)
 
 INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
-ifdef GC_LEAK_DETECTOR
-INCLUDES += -I$(dist_includedir)/.. -I$(dist_includedir)/../boehm
-endif
-
 DEFINES += -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 
deleted file mode 100644
--- a/nsprpub/pr/src/memory/prgcleak.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the Netscape Portable Runtime (NSPR).
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999-2000
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Patrick Beard <beard@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * prgcleak.c
- */
-
-#ifdef GC_LEAK_DETECTOR
-
-/* for FILE */
-#include <stdio.h>
-
-/* NSPR stuff */
-#include "generic_threads.h"
-#include "primpl.h"
-
-extern FILE *GC_stdout, *GC_stderr;
-
-extern void GC_gcollect(void);
-extern void GC_clear_roots(void);
-
-static PRStatus PR_CALLBACK scanner(PRThread* t, void** baseAddr,
-                                    PRUword count, void* closure)
-{
-    if (count) {
-        char* begin = (char*)baseAddr;
-        char* end = (char*)(baseAddr + count);
-        GC_mark_range_proc marker = (GC_mark_range_proc) closure;
-        marker(begin, end);
-    }
-    return PR_SUCCESS;
-}
-
-static void mark_all_stacks(GC_mark_range_proc marker)
-{
-    PR_ScanStackPointers(&scanner, (void *)marker);
-}
-
-#if defined(_PR_PTHREADS)
-#define _PR_MD_CURRENT_CPU() 1
-#endif
-
-static void locker(void* mutex)
-{
-    if (_PR_MD_CURRENT_CPU())
-        PR_EnterMonitor(mutex);
-}
-
-static void unlocker(void* mutex)
-{
-    if (_PR_MD_CURRENT_CPU())
-        PR_ExitMonitor(mutex);
-}
-
-static void stopper(void* unused)
-{
-    if (_PR_MD_CURRENT_CPU())
-        PR_SuspendAll();
-}
-
-static void starter(void* unused)
-{
-    if (_PR_MD_CURRENT_CPU())
-        PR_ResumeAll();
-}
-
-void _PR_InitGarbageCollector()
-{
-    void* mutex;
-
-    /* redirect GC's stderr to catch startup leaks. */
-    GC_stderr = fopen("StartupLeaks", "w");
-
-    mutex = PR_NewMonitor();
-    PR_ASSERT(mutex != NULL);
-
-    GC_generic_init_threads(&mark_all_stacks, mutex,
-            &locker, &unlocker,
-            &stopper, &starter);
-}
-
-void _PR_ShutdownGarbageCollector()
-{
-    /* do anything you need to shut down the collector. */
-}
-
-#endif /* GC_LEAK_DETECTOR */
--- a/nsprpub/pr/src/misc/prdtoa.c
+++ b/nsprpub/pr/src/misc/prdtoa.c
@@ -79,16 +79,18 @@ void _PR_CleanupDtoa(void)
 #else
 #define IEEE_MC68k
 #endif
 
 #define Long PRInt32
 #define ULong PRUint32
 #define NO_LONG_LONG
 
+#define No_Hex_NaN
+
 /****************************************************************
  *
  * The author of this software is David M. Gay.
  *
  * Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose without fee is hereby granted, provided that this entire notice
--- a/nsprpub/pr/src/misc/prinit.c
+++ b/nsprpub/pr/src/misc/prinit.c
@@ -200,20 +200,16 @@ static void _PR_InitStuff(void)
 	_PR_InitTPD();
     _PR_InitEnv();
     _PR_InitLayerCache();
     _PR_InitClock();
 
     _pr_sleeplock = PR_NewLock();
     PR_ASSERT(NULL != _pr_sleeplock);
 
-#ifdef GC_LEAK_DETECTOR
-    _PR_InitGarbageCollector();
-#endif
-
     _PR_InitThreads(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
     
 #ifdef WIN16
 	{
 	PRInt32 top;   /* artificial top of stack, win16 */
     _pr_top_of_task_stack = (char *) &top;
 	}
 #endif    
--- a/nsprpub/pr/src/misc/prthinfo.c
+++ b/nsprpub/pr/src/misc/prthinfo.c
@@ -144,25 +144,23 @@ PR_ThreadScanStackPointers(PRThread* t,
     **
     ** The execution environment better be accounted for otherwise it
     ** will be collected
     */
     status = scanFun(t, (void**)&t->environment, 1, scanClosure);
     if (status != PR_SUCCESS)
         return status;
 
-#ifndef GC_LEAK_DETECTOR
     /* if thread is not allocated on stack, this is redundant. */
     ptd = t->privateData;
     for (index = 0; index < t->tpdLength; index++, ptd++) {
         status = scanFun(t, (void**)ptd, 1, scanClosure);
         if (status != PR_SUCCESS)
             return status;
     }
-#endif
     
     return PR_SUCCESS;
 }
 
 /* transducer for PR_EnumerateThreads */
 typedef struct PRScanStackData {
     PRScanStackFun      scanFun;
     void*               scanClosure;
--- a/nsprpub/pr/src/pthreads/ptio.c
+++ b/nsprpub/pr/src/pthreads/ptio.c
@@ -3447,17 +3447,19 @@ PRInt32 osfd;
 #endif	/* _PR_INET6_PROBE */
 #endif
 
 PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto)
 {
     PRIntn osfd;
     PRDescType ftype;
     PRFileDesc *fd = NULL;
-	PRInt32 tmp_domain = domain;
+#if defined(_PR_INET6_PROBE) || !defined(_PR_INET6)
+    PRInt32 tmp_domain = domain;
+#endif
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     if (pt_TestAbort()) return NULL;
 
     if (PF_INET != domain
         && PR_AF_INET6 != domain
         && PF_UNIX != domain)
--- a/nsprpub/pr/src/pthreads/ptthread.c
+++ b/nsprpub/pr/src/pthreads/ptthread.c
@@ -97,76 +97,35 @@ static PRIntn pt_PriorityMap(PRThreadPri
     return 10;
 #else
     return pt_book.minPrio +
 	    pri * (pt_book.maxPrio - pt_book.minPrio) / PR_PRIORITY_LAST;
 #endif
 }
 #endif
 
-#if defined(GC_LEAK_DETECTOR) && (__GLIBC__ >= 2) && defined(__i386__) 
-
-#include <setjmp.h>
-
-typedef struct stack_frame stack_frame;
-
-struct stack_frame {
-    stack_frame* next;
-    void* pc;
-};
-
-static stack_frame* GetStackFrame()
-{
-    jmp_buf jb;
-    stack_frame* currentFrame;
-    setjmp(jb);
-    currentFrame = (stack_frame*)(jb[0].__jmpbuf[JB_BP]);
-    currentFrame = currentFrame->next;
-    return currentFrame;
-}
-
-static void* GetStackTop()
-{
-    stack_frame* frame;
-    frame = GetStackFrame();
-    while (frame != NULL)
-    {
-        ptrdiff_t pc = (ptrdiff_t)frame->pc;
-        if ((pc < 0x08000000) || (pc > 0x7fffffff) || (frame->next < frame))
-            return frame;
-        frame = frame->next;
-    }
-    return NULL;
-}
-#endif /* GC_LEAK_DETECTOR && (__GLIBC__ >= 2) && __i386__ */
-
 /*
 ** Initialize a stack for a native pthread thread
 */
 static void _PR_InitializeStack(PRThreadStack *ts)
 {
     if( ts && (ts->stackTop == 0) ) {
         ts->allocBase = (char *) &ts;
         ts->allocSize = ts->stackSize;
 
         /*
         ** Setup stackTop and stackBottom values.
         */
 #ifdef HAVE_STACK_GROWING_UP
         ts->stackBottom = ts->allocBase + ts->stackSize;
         ts->stackTop = ts->allocBase;
 #else
-#ifdef GC_LEAK_DETECTOR
-        ts->stackTop    = GetStackTop();
-        ts->stackBottom = ts->stackTop - ts->stackSize;
-#else
         ts->stackTop    = ts->allocBase;
         ts->stackBottom = ts->allocBase - ts->stackSize;
 #endif
-#endif
     }
 }
 
 static void *_pt_root(void *arg)
 {
     PRIntn rv;
     PRThread *thred = (PRThread*)arg;
     PRBool detached = (thred->state & PT_THREAD_DETACHED) ? PR_TRUE : PR_FALSE;
--- a/nsprpub/pr/src/threads/combined/prucpu.c
+++ b/nsprpub/pr/src/threads/combined/prucpu.c
@@ -49,17 +49,17 @@ PRInt32 _pr_md_idle_cpus;       /* numbe
  */
 #if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY)
 #ifndef _PR_HAVE_ATOMIC_OPS
 static _MDLock _pr_md_idle_cpus_lock;
 #endif
 #endif
 PRUintn _pr_numCPU;
 PRInt32 _pr_cpus_exit;
-PRInt32 _pr_cpu_affinity_mask = 0;
+PRUint32 _pr_cpu_affinity_mask = 0;
 
 #if !defined (_PR_GLOBAL_THREADS_ONLY)
 
 static PRUintn _pr_cpuID;
 
 static void PR_CALLBACK _PR_CPU_Idle(void *);
 
 static _PRCPU *_PR_CreateCPU(void);
--- a/nsprpub/pr/src/threads/combined/pruthr.c
+++ b/nsprpub/pr/src/threads/combined/pruthr.c
@@ -1260,24 +1260,16 @@ PR_IMPLEMENT(PRThread*) _PR_CreateThread
             thread = (PRThread*) top;
             /*
              * Make stack 64-byte aligned
              */
             if ((PRUptrdiff)top & 0x3f) {
                 top = (char*)((PRUptrdiff)top & ~0x3f);
             }
 #endif
-#if defined(GC_LEAK_DETECTOR)
-            /*
-             * sorry, it is not safe to allocate the thread on the stack,
-             * because we assign to this object before the GC can learn
-             * about this thread. we'll just leak thread objects instead.
-             */
-            thread = PR_NEW(PRThread);
-#endif
             stack->thr = thread;
             memset(thread, 0, sizeof(PRThread));
             thread->threadAllocatedOnStack = 1;
 #else
             thread = _PR_MD_CREATE_USER_THREAD(stackSize, start, arg);
             if (!thread) {
                 PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
                 return NULL;
--- a/nsprpub/pr/tests/Makefile.in
+++ b/nsprpub/pr/tests/Makefile.in
@@ -446,19 +446,19 @@ ifeq (,$(filter-out FreeBSD OpenBSD BSD_
 LIBPTHREAD =
 endif
 ifeq ($(OS_ARCH)$(basename $(OS_RELEASE)),HP-UXB.10)
 LIBPTHREAD = -ldce
 endif
 endif
 
 ifeq ($(OS_TARGET),Android)
-LDOPTS=$(OS_LDFLAGS)
-LIBPTHREAD=
-XCFLAGS=${OS_CFLAGS}
+LDOPTS = $(OS_LDFLAGS) $(WRAP_MALLOC_LIB)
+LIBPTHREAD =
+XCFLAGS = $(OS_CFLAGS)
 endif
 
 #####################################################
 #
 # The rules
 #
 #####################################################
 
--- a/nsprpub/pr/tests/op_filok.c
+++ b/nsprpub/pr/tests/op_filok.c
@@ -50,48 +50,27 @@
 ***********************************************************************/
 /* Used to get the command line option */
 #include "prinit.h"
 #include "prmem.h"
 #include "prio.h"
 #include "prerror.h"
 #include <stdio.h>
 
-/*
- * The name of a file that is guaranteed to exist
- * on every machine of a particular OS.
- */
-#if defined(SYMBIAN)
-#define EXISTING_FILENAME "z:\\system\\install\\Series60v3.0.sis"
-#elif defined (XP_UNIX)
-#define EXISTING_FILENAME "/bin/sh"
-#elif defined(WINCE)
-#define EXISTING_FILENAME "/Windows/services.exe"
-#elif defined(WIN32)
-#define EXISTING_FILENAME "c:/autoexec.bat"
-#elif defined(OS2)
-#define EXISTING_FILENAME "c:/config.sys"
-#elif defined(BEOS)
-#define EXISTING_FILENAME "/boot/beos/bin/sh"
-#else
-#error "Unknown OS"
-#endif
-
 static PRFileDesc *t1;
 
 int main(int argc, char **argv)
 {
     PR_STDIO_INIT();
 
-	t1 = PR_Open(EXISTING_FILENAME, PR_RDONLY, 0666);
+ 	t1 = PR_Open(argv[0], PR_RDONLY, 0666);
 
 	if (t1 == NULL) {
 		printf ("error code is %d \n", PR_GetError());
-		printf ("File %s should be found\n",
-				EXISTING_FILENAME);
+ 		printf ("File %s should be found\n", argv[0]);
 		return 1;
 	} else {
 		if (PR_Close(t1) == PR_SUCCESS) {
 			printf ("Test passed \n");
 			return 0;
 		} else {
 			printf ("cannot close file\n");
 			printf ("error code is %d\n", PR_GetError());
old mode 100644
new mode 100755
old mode 100644
new mode 100755
--- a/nsprpub/pr/tests/suspend.c
+++ b/nsprpub/pr/tests/suspend.c
@@ -103,18 +103,19 @@ static PRStatus PR_CALLBACK print_thread
     PRInt32 words;
     PRWord *registers;
 
     printf(
         "\nprint_thread[0x%lx]: %-20s - i = %ld\n",thread, 
         (PR_GLOBAL_THREAD == PR_GetThreadScope(thread)) ?
         "PR_GLOBAL_THREAD" : "PR_LOCAL_THREAD", i);
     registers = PR_GetGCRegisters(thread, 0, (int *)&words);
-    printf("Regsters R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\n",
-        registers[0],registers[1],registers[2],registers[3]);
+    if (registers)
+        printf("Registers R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\n",
+            registers[0],registers[1],registers[2],registers[3]);
     printf("Stack Pointer = 0x%lx\n", PR_GetSP(thread));
     return PR_SUCCESS;
 }
 
 static void Level_0_Thread(PRThreadScope scope1, PRThreadScope scope2)
 {
     PRThread *thr;
     PRThread *me = PR_GetCurrentThread();
@@ -144,18 +145,19 @@ static void Level_0_Thread(PRThreadScope
             "PR_GLOBAL_THREAD" : "PR_LOCAL_THREAD",
             thr);
 
         PR_Sleep(0);
     }
     PR_SuspendAll();
     PR_EnumerateThreads(print_thread, NULL);
     registers = PR_GetGCRegisters(me, 1, (int *)&words);
-    printf("My Registers: R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\n",
-        registers[0],registers[1],registers[2],registers[3]);
+    if (registers)
+        printf("My Registers: R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\n",
+            registers[0],registers[1],registers[2],registers[3]);
     printf("My Stack Pointer = 0x%lx\n", PR_GetSP(me));
     PR_ResumeAll();
 
     /* Wait for all threads to exit */
     PR_EnterMonitor(mon);
     while (alive) {
         PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);
     }
--- a/nsprpub/pr/tests/vercheck.c
+++ b/nsprpub/pr/tests/vercheck.c
@@ -47,31 +47,31 @@
  */
 
 #include "prinit.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 
 /*
- * This release (4.8.6) is backward compatible with the
+ * This release (4.8.7) is backward compatible with the
  * 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, 4.5.x, 4.6.x, 4.7.x,
- * 4.8, 4.8.1, 4.8.2, 4.8.3, 4.8.4, and 4.8.5 releases.
+ * 4.8, 4.8.1, 4.8.2, 4.8.3, 4.8.4, 4.8.5, and 4.8.6 releases.
  * It, of course, is compatible with itself.
  */
 static char *compatible_version[] = {
     "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3",
     "4.2", "4.2.1", "4.2.2", "4.3", "4.4", "4.4.1",
     "4.5", "4.5.1",
     "4.6", "4.6.1", "4.6.2", "4.6.3", "4.6.4", "4.6.5",
     "4.6.6", "4.6.7", "4.6.8",
     "4.7", "4.7.1", "4.7.2", "4.7.3", "4.7.4", "4.7.5",
     "4.7.6",
     "4.8", "4.8.1", "4.8.2", "4.8.3", "4.8.4", "4.8.5",
-    PR_VERSION
+    "4.8.6", PR_VERSION
 };
 
 /*
  * This release is not backward compatible with the old
  * NSPR 2.1 and 3.x releases.
  *
  * Any release is incompatible with future releases and
  * patches.