fixup commit for branch 'CAMINO_1_0_1_MINIBRANCH' CAMINO_1_0_1_MINIBRANCH CAMINO_1_0_1_RELEASE CAMINO_1_0_2_RELEASE FIREFOX_1_5_0_2_RC1 FIREFOX_1_5_0_2_RC2 FIREFOX_1_5_0_2_RELEASE FIREFOX_1_5_0_3_RELEASE FIREFOX_1_5_0_4_RC1 FIREFOX_1_5_0_4_RC2 FIREFOX_1_5_0_4_RC3 FIREFOX_1_5_0_4_RELEASE MOZILLA_1_8_0_3_RELEASE MOZILLA_1_8_0_4_RELEASE SEAMONKEY_1_0_1_RELEASE SEAMONKEY_1_0_2_RELEASE THUNDERBIRD_1_5_0_2_RC1 THUNDERBIRD_1_5_0_2_RC2 THUNDERBIRD_1_5_0_2_RELEASE THUNDERBIRD_1_5_0_4_RC1 THUNDERBIRD_1_5_0_4_RC2 THUNDERBIRD_1_5_0_4_RC3 THUNDERBIRD_1_5_0_4_RELEASE XULRUNNER_1_8_0_4_RELEASE
authorcvs2hg
Wed, 22 Feb 2006 23:03:12 +0000
branchCAMINO_1_0_1_MINIBRANCH
changeset 3603 61502d85c7b2
parent 3399 0d0f14c8216a
child 3604 a93a35bbee83
push idunknown
push userunknown
push dateunknown
fixup commit for branch 'CAMINO_1_0_1_MINIBRANCH'
admin/repackage.sh
config/autoconf.mk.in
config/rules.mk
configure
configure.in
pkg/linux/Makefile.in
pkg/linux/sun-nspr.spec
pr/include/md/_darwin.cfg
pr/include/md/_darwin.h
pr/include/md/_linux.cfg
pr/include/md/_linux.h
pr/include/md/_pth.h
pr/include/md/_riscos.cfg
pr/include/md/_riscos.h
pr/include/md/_win95.h
pr/include/md/_winnt.h
pr/include/md/prosdep.h
pr/include/prinit.h
pr/include/private/primpl.h
pr/include/prlink.h
pr/include/prthread.h
pr/src/Makefile.in
pr/src/io/prprf.c
pr/src/io/prscanf.c
pr/src/linking/Makefile.in
pr/src/linking/prlink.c
pr/src/malloc/prmem.c
pr/src/md/unix/os_Darwin_x86.s
pr/src/md/unix/riscos.c
pr/src/md/unix/unix.c
pr/src/md/unix/uxrng.c
pr/src/md/windows/ntinrval.c
pr/src/md/windows/ntio.c
pr/src/md/windows/w95io.c
pr/src/misc/prdtoa.c
pr/src/misc/prnetdb.c
pr/src/misc/prsystem.c
pr/src/pthreads/ptio.c
pr/src/pthreads/ptthread.c
pr/tests/server_test.c
pr/tests/servr_kk.c
pr/tests/servr_ku.c
pr/tests/servr_uk.c
pr/tests/servr_uu.c
pr/tests/vercheck.c
--- a/admin/repackage.sh
+++ b/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.6
-TOTOP=./v4.6
-NSPRDIR=nspr-4.6
-SOURCETAG=NSPR_4_6_RTM
+FROMTOP=/share/builds/components/nspr20/v4.6.1
+TOTOP=./v4.6.1
+NSPRDIR=nspr-4.6.1
+SOURCETAG=NSPR_4_6_1_RTM
 
 #
 # enumerate Unix object directories on /s/b/c
 UNIX_OBJDIRS="
 AIX4.3_64_DBG.OBJ
 AIX4.3_64_OPT.OBJ
 AIX4.3_DBG.OBJ
 AIX4.3_OPT.OBJ
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -83,16 +83,17 @@ OPTIMIZER	= @OPTIMIZER@
 MKSHLIB		= @MKSHLIB@
 DSO_CFLAGS	= @DSO_CFLAGS@
 DSO_LDOPTS	= @DSO_LDOPTS@
 
 RESOLVE_LINK_SYMBOLS = @RESOLVE_LINK_SYMBOLS@
 
 HOST_CC		= @HOST_CC@
 HOST_CFLAGS	= @HOST_CFLAGS@
+HOST_LDFLAGS	= @HOST_LDFLAGS@
 
 DEFINES		= @DEFINES@ @DEFS@
 
 MDCPUCFG_H	= @MDCPUCFG_H@
 PR_MD_CSRCS	= @PR_MD_CSRCS@
 PR_MD_ASFILES	= @PR_MD_ASFILES@
 PR_MD_ARCH_DIR	= @PR_MD_ARCH_DIR@
 CPU_ARCH	= @CPU_ARCH@
@@ -109,8 +110,20 @@ ULTRASPARC_LIBRARY = @ULTRASPARC_LIBRARY
 
 OBJECT_MODE	= @OBJECT_MODE@
 ifdef OBJECT_MODE
 export OBJECT_MODE
 endif
 
 VISIBILITY_FLAGS = @VISIBILITY_FLAGS@
 WRAP_SYSTEM_INCLUDES = @WRAP_SYSTEM_INCLUDES@
+
+MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
+ifdef MACOSX_DEPLOYMENT_TARGET
+export MACOSX_DEPLOYMENT_TARGET
+endif
+
+MACOS_SDK_DIR = @MACOS_SDK_DIR@
+
+NEXT_ROOT = @NEXT_ROOT@
+ifdef NEXT_ROOT
+export NEXT_ROOT
+endif
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -82,16 +82,17 @@ endif
 
 ifdef USE_AUTOCONF
 ifdef CROSS_COMPILE
 ifdef INTERNAL_TOOLS
 CC=$(HOST_CC)
 CCC=$(HOST_CXX)
 CFLAGS=$(HOST_CFLAGS)
 CXXFLAGS=$(HOST_CXXFLAGS)
+LDFLAGS=$(HOST_LDFLAGS)
 endif
 endif
 endif
 
 #
 # This makefile contains rules for building the following kinds of
 # libraries:
 # - LIBRARY: a static (archival) library
--- a/configure
+++ b/configure
@@ -35,30 +35,35 @@ ac_help="$ac_help
   --enable-debug-rtl      Use the MSVC debug runtime library"
 ac_help="$ac_help
   --enable-n32            Enable n32 ABI support (IRIX only)"
 ac_help="$ac_help
   --enable-64bit          Enable 64-bit support (on certain platforms)"
 ac_help="$ac_help
   --enable-mdupdate       Enable use of certain compilers' mdupdate feature"
 ac_help="$ac_help
-  --enable-macos-target=VER (default=10.1)
-                          Set the minimum MacOS version needed at runtime"
+  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)"
+ac_help="$ac_help
+  --enable-macos-target=VER
+                          Set the minimum MacOS version needed at runtime
+                          [10.1 for ppc, 10.4 for x86]"
 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)"
+  --with-bthreads         Use system bthreads library as thread subsystem
+                          (BeOS only)"
 ac_help="$ac_help
-  --with-native-threads   Use native system threads as thread subsystem (Solaris only)"
+  --with-native-threads   Use native system threads as thread subsystem
+                          (Solaris only)"
 ac_help="$ac_help
   --enable-cplus          Enable some c++ api routines"
 ac_help="$ac_help
   --enable-ipv6           Compile ipv6 support"
 ac_help="$ac_help
   --enable-boehm          Enable the Boehm Garbage Collector"
 
 # Initialize some variables set by options.
@@ -613,17 +618,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:622: checking host system type" >&5
+echo "configure:627: 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; }
@@ -634,17 +639,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:643: checking target system type" >&5
+echo "configure:648: 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 ;;
@@ -652,17 +657,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:661: checking build system type" >&5
+echo "configure:666: 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 ;;
@@ -677,40 +682,42 @@ 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=6
-MOD_PATCH_VERSION=0
+MOD_PATCH_VERSION=1
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_64=
 USE_CPLUS=
 USE_IPV6=
 USE_MDUPDATE=
-MACOS_DEPLOYMENT_TARGET=
+_MACOSX_DEPLOYMENT_TARGET=
 _OPTIMIZE_FLAGS=-O
 _DEBUG_FLAGS=-g
 MOZ_DEBUG=1
 MOZ_OPTIMIZE=
 OBJDIR=.
 OBJDIR_NAME=.
 OBJDIR_SUFFIX=OBJ
 NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
 NOSUCHFILE=/no-such-file
 LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)'
 LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)'
 CYGWIN_WRAPPER=
+MACOS_SDK_DIR=
+NEXT_ROOT=
 
 RESOLVE_LINK_SYMBOLS=
 
 CFLAGS="${CFLAGS=}"
 CXXFLAGS="${CXXFLAGS=}"
 LDFLAGS="${LDFLAGS=}"
 HOST_CFLAGS="${HOST_CFLAGS=}"
 HOST_LDFLAGS="${HOST_LDFLAGS=}"
@@ -719,17 +726,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:728: checking for $ac_word" >&5
+echo "configure:735: 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"
@@ -915,22 +922,27 @@ fi
 if test "${enable_mdupdate+set}" = set; then
   enableval="$enable_mdupdate"
    if test "$enableval" = "yes"; then
 	    USE_MDUPDATE=1
       fi 
 fi
 
 
+# Check whether --with-macos-sdk or --without-macos-sdk was given.
+if test "${with_macos_sdk+set}" = set; then
+  withval="$with_macos_sdk"
+  MACOS_SDK_DIR=$withval
+fi
+
+
 # Check whether --enable-macos-target or --disable-macos-target was given.
 if test "${enable_macos_target+set}" = set; then
   enableval="$enable_macos_target"
-  MACOS_DEPLOYMENT_TARGET_STR=$enableval
-else
-  MACOS_DEPLOYMENT_TARGET_STR=10.1
+  _MACOSX_DEPLOYMENT_TARGET=$enableval
 fi
 
 
 case "$target" in
 
 *-aix*)
     case "${target_os}" in
     aix3.2*)
@@ -1021,17 +1033,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:1030: checking for $ac_word" >&5
+echo "configure:1042: 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.
   ;;
   ?:/*)			 
@@ -1092,23 +1104,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:1101: checking for $host compiler" >&5
+echo "configure:1113: 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:1107: checking for $ac_word" >&5
+echo "configure:1119: 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"
@@ -1144,46 +1156,55 @@ 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:1153: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
+echo "configure:1165: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
     cat > conftest.$ac_ext <<EOF
-#line 1155 "configure"
+#line 1167 "configure"
 #include "confdefs.h"
 
 int main() {
 return(0);
 ; return 0; }
 EOF
-if { (eval echo configure:1162: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1174: \"$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
 rm -f conftest*
 
     CC=$_SAVE_CC
     CFLAGS=$_SAVE_CFLAGS
     LDFLAGS=$_SAVE_LDFLAGS
 
+    case "$build:$target" in 
+      powerpc-apple-darwin8*:i?86-apple-darwin*)
+                                                _SAVE_CFLAGS=$CFLAGS 
+        _SAVE_CXXFLAGS=$CXXLAGS
+        CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
+        CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
+        ;;        
+    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:1182: checking for $ac_word" >&5
+echo "configure:1203: 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"
@@ -1207,17 +1228,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:1216: checking for $ac_word" >&5
+echo "configure:1237: 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"
@@ -1237,17 +1258,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:1246: checking for $ac_word" >&5
+echo "configure:1267: 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
@@ -1288,17 +1309,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:1297: checking for $ac_word" >&5
+echo "configure:1318: 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"
@@ -1320,33 +1341,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:1329: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1350: 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 1340 "configure"
+#line 1361 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1366: \"$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
@@ -1362,31 +1383,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:1371: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1392: 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:1376: checking whether we are using GNU C" >&5
+echo "configure:1397: 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:1385: \"$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:1406: \"$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
 
@@ -1395,17 +1416,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:1404: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1425: 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
@@ -1431,17 +1452,17 @@ else
   fi
 fi
 
     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:1440: checking for $ac_word" >&5
+echo "configure:1461: 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"
@@ -1467,17 +1488,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:1476: checking for $ac_word" >&5
+echo "configure:1497: 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"
@@ -1499,33 +1520,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:1508: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:1529: 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 1519 "configure"
+#line 1540 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:1524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1545: \"$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
@@ -1541,31 +1562,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:1550: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1571: 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:1555: checking whether we are using GNU C++" >&5
+echo "configure:1576: 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:1564: \"$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:1585: \"$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
 
@@ -1574,17 +1595,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:1583: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:1604: 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
@@ -1605,73 +1626,30 @@ elif test $ac_cv_prog_cxx_g = yes; then
 else
   if test "$GXX" = yes; then
     CXXFLAGS="-O2"
   else
     CXXFLAGS=
   fi
 fi
 
-for ac_declaration in \
-   ''\
-   '#include <stdlib.h>' \
-   'extern "C" void std::exit (int) throw (); using std::exit;' \
-   'extern "C" void std::exit (int); using std::exit;' \
-   'extern "C" void exit (int) throw ();' \
-   'extern "C" void exit (int);' \
-   'void exit (int);'
-do
-  cat > conftest.$ac_ext <<EOF
-#line 1624 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-$ac_declaration
-int main() {
-exit (42);
-; return 0; }
-EOF
-if { (eval echo configure:1632: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  :
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  continue
-fi
-rm -f conftest*
-  cat > conftest.$ac_ext <<EOF
-#line 1642 "configure"
-#include "confdefs.h"
-$ac_declaration
-int main() {
-exit (42);
-; return 0; }
-EOF
-if { (eval echo configure:1649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  break
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-fi
-rm -f conftest*
-done
-if test -n "$ac_declaration"; then
-  echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
-  echo '#endif'             >>confdefs.h
-fi
-
+
+    case "$build:$target" in
+      powerpc-apple-darwin8*:i?86-apple-darwin*)
+                                CFLAGS=$_SAVE_CFLAGS
+        CXXFLAGS=$_SAVE_CXXFLAGS
+        ;;
+    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:1670: checking for $ac_word" >&5
+echo "configure:1648: 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"
@@ -1696,17 +1674,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:1705: checking for $ac_word" >&5
+echo "configure:1683: 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"
@@ -1731,17 +1709,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:1740: checking for $ac_word" >&5
+echo "configure:1718: 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"
@@ -1766,17 +1744,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:1775: checking for $ac_word" >&5
+echo "configure:1753: 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"
@@ -1801,17 +1779,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:1810: checking for $ac_word" >&5
+echo "configure:1788: 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"
@@ -1836,17 +1814,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:1845: checking for $ac_word" >&5
+echo "configure:1823: 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"
@@ -1873,17 +1851,17 @@ test -n "$WINDRES" || WINDRES="echo"
 
 
 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:1882: checking for $ac_word" >&5
+echo "configure:1860: 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"
@@ -1905,33 +1883,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:1914: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:1892: 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 1925 "configure"
+#line 1903 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:1930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1908: \"$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
@@ -1947,31 +1925,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:1956: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1934: 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:1961: checking whether we are using GNU C++" >&5
+echo "configure:1939: 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:1970: \"$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:1948: \"$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
 
@@ -1980,17 +1958,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:1989: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:1967: 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
@@ -2011,74 +1989,23 @@ elif test $ac_cv_prog_cxx_g = yes; then
 else
   if test "$GXX" = yes; then
     CXXFLAGS="-O2"
   else
     CXXFLAGS=
   fi
 fi
 
-for ac_declaration in \
-   ''\
-   '#include <stdlib.h>' \
-   'extern "C" void std::exit (int) throw (); using std::exit;' \
-   'extern "C" void std::exit (int); using std::exit;' \
-   'extern "C" void exit (int) throw ();' \
-   'extern "C" void exit (int);' \
-   'void exit (int);'
-do
-  cat > conftest.$ac_ext <<EOF
-#line 2030 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-$ac_declaration
-int main() {
-exit (42);
-; return 0; }
-EOF
-if { (eval echo configure:2038: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  :
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  continue
-fi
-rm -f conftest*
-  cat > conftest.$ac_ext <<EOF
-#line 2048 "configure"
-#include "confdefs.h"
-$ac_declaration
-int main() {
-exit (42);
-; return 0; }
-EOF
-if { (eval echo configure:2055: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  break
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-fi
-rm -f conftest*
-done
-if test -n "$ac_declaration"; then
-  echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
-  echo '#endif'             >>confdefs.h
-fi
-
-
     if test "$CXX" = "cl" -a -z "$CC"; then
         CC=$CXX
     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:2077: 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"
@@ -2098,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:2107: 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
@@ -2149,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:2158: 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"
@@ -2181,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:2190: 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 2201 "configure"
+#line 2128 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:2206: \"$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
@@ -2223,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:2232: 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:2237: 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:2246: \"$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
 
@@ -2256,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:2265: 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
@@ -2289,72 +2216,72 @@ else
     CFLAGS="-O2"
   else
     CFLAGS=
   fi
 fi
 
     fi
     echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:2298: checking how to run the C preprocessor" >&5
+echo "configure:2225: 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 2313 "configure"
+#line 2240 "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:2319: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2246: \"$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 2330 "configure"
+#line 2257 "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:2336: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2263: \"$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 2347 "configure"
+#line 2274 "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:2353: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2280: \"$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*
@@ -2371,17 +2298,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:2380: checking for $ac_word" >&5
+echo "configure:2307: 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"
@@ -2403,17 +2330,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:2412: checking for $ac_word" >&5
+echo "configure:2339: 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.
   ;;
   ?:/*)			 
@@ -2444,17 +2371,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:2453: checking for $ac_word" >&5
+echo "configure:2380: 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.
   ;;
   ?:/*)			 
@@ -2485,17 +2412,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:2494: checking for $ac_word" >&5
+echo "configure:2421: 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.
   ;;
   ?:/*)			 
@@ -2526,17 +2453,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:2535: checking for $ac_word" >&5
+echo "configure:2462: 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.
   ;;
   ?:/*)			 
@@ -2567,17 +2494,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:2576: checking for $ac_word" >&5
+echo "configure:2503: 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.
   ;;
   ?:/*)			 
@@ -2622,46 +2549,52 @@ fi
 if test "$GXX" = "yes"; then
     GNU_CXX=1
 fi
 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
     GNU_AS=1
 fi
 rm -f a.out
 
+case "$build:$target" in
+    i?86-apple-darwin*:powerpc-apple-darwin*)
+                                cross_compiling=yes
+        ;;
+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:2638: checking for gcc -pipe support" >&5
+echo "configure:2571: 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 2653 "configure"
+#line 2586 "configure"
 #include "confdefs.h"
  #include <stdio.h> 
 int main() {
 printf("Hello World\n");
 ; return 0; }
 EOF
-if { (eval echo configure:2660: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2593: \"$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
@@ -2678,17 +2611,17 @@ rm -f conftest*
     rm -f dummy-hello.c dummy-hello.s dummy-hello.S dummy-hello a.out
     echo "$ac_t""$_res" 1>&6
 else
     echo "$ac_t""no" 1>&6
 fi
 
 if test "$GNU_CC"; then
     echo $ac_n "checking for visibility(hidden) attribute""... $ac_c" 1>&6
-echo "configure:2687: checking for visibility(hidden) attribute" >&5
+echo "configure:2620: 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
@@ -2702,17 +2635,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:2711: checking for visibility pragma support" >&5
+echo "configure:2644: 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;
@@ -2755,17 +2688,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:2764: checking for $ac_word" >&5
+echo "configure:2697: 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.
   ;;
   ?:/*)			 
@@ -2815,16 +2748,17 @@ ASFLAGS='$(CFLAGS)'
 if test -n "$CROSS_COMPILE"; then
     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
     OS_RELEASE=
     OS_TEST="${target_cpu}"
     case "${target_os}" in
         linux*)       OS_ARCH=Linux ;;
         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
         mingw*)       OS_ARCH=WINNT ;;
+        darwin*)      OS_ARCH=Darwin ;;
     esac
 else
     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
     OS_RELEASE=`uname -r`
     OS_TEST=`uname -m`
 fi
 
 if test "$OS_ARCH" = "IRIX64"; then
@@ -2869,43 +2803,51 @@ fi
 #
 
 #
 # The following hack allows one to build on a WIN95 machine (as if
 # s/he were cross-compiling on a WINNT host for a WIN95 target).
 # It also accomodates for MKS's uname.exe.  If you never intend
 # to do development on a WIN95 machine, you don't need this hack.
 #
-if test "$OS_ARCH" = "WIN95"; then
+case "$OS_ARCH" in
+WIN95)
     OS_ARCH=WINNT
     OS_TARGET=WIN95
-elif test "$OS_ARCH" = 'Windows_95'; then
+    ;;
+Windows_95)
     OS_ARCH=Windows_NT
     OS_TARGET=WIN95
-elif test "$OS_ARCH" = 'Windows_98'; then
+    ;;
+Windows_98)
     OS_ARCH=Windows_NT
     OS_TARGET=WIN95
-elif test "`echo $OS_ARCH | egrep -c '^(CYGWIN_9|CYGWIN_ME)' 2>/dev/null`" != 0; then
+    ;;
+CYGWIN_9*|CYGWIN_ME*)
     OS_ARCH='CYGWIN_NT-4.0'
     OS_TARGET=WIN95
-elif test "$OS_ARCH" = "OS_2"; then
+    ;;
+OS_2)
     OS_ARCH=OS2
     OS_TARGET=OS2
-fi
+    ;;
+esac
 
 #
 # On WIN32, we also define the variable CPU_ARCH.
 #
 
-if test "$OS_ARCH" = "WINNT"; then
+case "$OS_ARCH" in
+WINNT)
     CPU_ARCH=`uname -p`
     if test "$CPU_ARCH" = "I386"; then
         CPU_ARCH=x86
     fi
-elif test "$OS_ARCH" = "Windows_NT"; then
+    ;;
+Windows_NT)
 #
 # If uname -s returns "Windows_NT", we assume that we are using
 # the uname.exe in MKS toolkit.
 #
 # The -r option of MKS uname only returns the major version number.
 # So we need to use its -v option to get the minor version number.
 # Moreover, it doesn't have the -p option, so we need to use uname -m.
 #
@@ -2917,45 +2859,35 @@ elif test "$OS_ARCH" = "Windows_NT"; the
     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
     CPU_ARCH=`uname -m`
     #
     # MKS's uname -m returns "586" on a Pentium machine.
     #
     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
         CPU_ARCH=x86
     fi
-elif echo "$OS_ARCH" | grep -c CYGWIN_NT >/dev/null; then
+    ;;
+CYGWIN_NT*|MINGW*_NT*)
 #
 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
 # the uname.exe in the Cygwin tools.
+# If uname -s returns MINGW32_NT-5.1, we assume that we are using
+# the uname.exe in the MSYS tools.
 #
-    OS_RELEASE=`echo $OS_ARCH | sed 's|^CYGWIN_NT-||'`
+    OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
     OS_ARCH=WINNT
     CPU_ARCH=`uname -m`
     #
     # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
     #
     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
         CPU_ARCH=x86
     fi
-elif test "$OS_ARCH" = "CYGWIN32_NT"; then
-#
-# Prior to the Beta 20 release, Cygwin was called GNU-Win32.
-# If uname -s returns "CYGWIN32/NT", we assume that we are using
-# the uname.exe in the GNU-Win32 tools.
-#
-    OS_ARCH=WINNT
-    CPU_ARCH=`uname -m`
-    #
-    # GNU-Win32's uname -m returns "i686" on a Pentium Pro machine.
-    #
-    if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
-        CPU_ARCH=x86
-    fi
-fi
+    ;;
+esac
 
 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
     OS_TARGET=WIN95
     if test -n "$MOZ_DEBUG"; then
         USE_DEBUG_RTL=1
     fi
 fi
 if test -z "$OS_TARGET"; then
@@ -2966,17 +2898,20 @@ if test "$OS_TARGET" = "WIN95"; then
 fi
 if test "$OS_TARGET" = "WIN16"; then
     OS_RELEASE=
 fi
 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
 
 
 case "$host" in
-*-mingw*|*-cygwin*|*-msvc*|*-mks*)
+*-mingw*)
+    NSINSTALL=nsinstall
+    ;;
+*-cygwin*|*-msvc*|*-mks*)
     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
     if test `echo "${PATH}" | grep -c \;` = 0; then
         CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
     fi
     ;;
 *-beos*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
     ;;
@@ -3000,27 +2935,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:3009: checking for sys/atomic_op.h" >&5
+echo "configure:2944: 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 3014 "configure"
+#line 2949 "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:3019: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2954: \"$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
@@ -3167,36 +3102,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:3176: checking for gethostbyaddr in -lbind" >&5
+echo "configure:3111: 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 3184 "configure"
+#line 3119 "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:3195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3130: \"$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
@@ -3367,97 +3302,116 @@ EOF
 #define DARWIN 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define HAVE_BSD_FLOCK 1
 EOF
 
     CFLAGS="$CFLAGS -Wmost -fno-common"
-    if echo $OS_TEST | grep -c 86 2>/dev/null; then
-        cat >> confdefs.h <<\EOF
+    case "${target_cpu}" in
+        i*86*)
+            cat >> confdefs.h <<\EOF
 #define i386 1
 EOF
 
-        CPU_ARCH=i386
-    else
-        cat >> confdefs.h <<\EOF
+            CPU_ARCH=i386
+            PR_MD_ASFILES=os_Darwin_x86.s
+            ;;
+        *)
+            cat >> confdefs.h <<\EOF
 #define ppc 1
 EOF
 
-        CPU_ARCH=ppc
-    fi
+            CPU_ARCH=ppc
+            PR_MD_ASFILES=os_Darwin_ppc.s
+            ;;
+    esac
+    DSO_CFLAGS=-fPIC
     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
     # Use the standard preprocessor (cpp)
     CFLAGS="$CFLAGS -no-cpp-precomp"
-    MKSHLIB='$(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -o $@'
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     STRIP="$STRIP -x -S"
     DLL_SUFFIX=dylib
     USE_PTHREADS=1
     MDCPUCFG_H=_darwin.cfg
     PR_MD_CSRCS=darwin.c
-    if test "$CPU_ARCH" = "ppc"; then
-        PR_MD_ASFILES=os_Darwin_ppc.s
-    fi
 
     # Add Mac OS X support for loading CFM & CFBundle plugins
     if test -f /System/Library/Frameworks/Carbon.framework/Carbon; then
         cat >> confdefs.h <<\EOF
 #define XP_MACOSX 1
 EOF
 
         OS_TARGET=MacOSX
 
-                        
-        MACOS_VERSION_MAJOR=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 1`
-        MACOS_VERSION_MINOR=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 2`
-        MACOS_VERSION_MICRO=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 3`
-        if test -z "$MACOS_VERSION_MINOR"; then
-            MACOS_VERSION_MINOR=0
-        fi
-        if test -z "$MACOS_VERSION_MICRO"; then
-            MACOS_VERSION_MICRO=0
+        if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
+                        export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
+        elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
+                                                case "${target_cpu}" in
+                powerpc*)
+                                        export MACOSX_DEPLOYMENT_TARGET=10.1
+                    ;;
+                i*86*)
+                                        export MACOSX_DEPLOYMENT_TARGET=10.4
+                    ;;
+            esac
         fi
-        MACOS_DEPLOYMENT_TARGET=`printf "%02d%02d%02d" "$MACOS_VERSION_MAJOR" "$MACOS_VERSION_MINOR" "$MACOS_VERSION_MICRO"`
-        cat >> confdefs.h <<EOF
-#define MACOS_DEPLOYMENT_TARGET $MACOS_DEPLOYMENT_TARGET
-EOF
-
-    fi
-
-    # do the right thing for SDK support
-    if test "$NEXT_ROOT"; then
-                
-                                
-        
-        CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
-        GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
-        GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
-        
-        GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
-
-        if test "$GCC_VERSION_MAJOR" -lt "4" ; then
-            TARGET_ARCH_LIB="darwin"
-            TARGET_ARCH_INCLUDE="ppc-darwin"
-            SDK_C_INCLUDE="-isystem ${NEXT_ROOT}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${NEXT_ROOT}/usr/include -F${NEXT_ROOT}/System/Library/Frameworks"
-        else
-                                                                                    TARGET_ARCH_LIB=powerpc-apple-darwin`echo $NEXT_ROOT | $PERL -pe 's/MacOSX10\.(^\.*)//;if ($1) {$_=$1+4;} else {$_="'${target_os}'";s/(\d+)//;$_=$1;}'`
-            TARGET_ARCH_INCLUDE=$TARGET_ARCH_LIB
-            SDK_C_INCLUDE="-isystem ${NEXT_ROOT}/usr/lib/gcc/${TARGET_ARCH_LIB}/${GCC_VERSION_FULL}/include -isystem ${NEXT_ROOT}/usr/include -F${NEXT_ROOT}/System/Library/Frameworks"
+
+                        
+        if test "$MACOS_SDK_DIR"; then
+            
+            if test ! -d "$MACOS_SDK_DIR"; then
+                { echo "configure: error: SDK not found.  When using --with-macos-sdk, you must
+specify a valid SDK.  SDKs are installed when the optional cross-development
+tools are selected during the Xcode/Developer Tools installation." 1>&2; exit 1; }
+            fi
+
+            
+            CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
+            GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
+            GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
+            
+            GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
+            if test "$GCC_VERSION_MAJOR" -lt "4" ; then
+                SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
+                if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
+                    SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
+                fi
+
+                SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
+
+                CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
+
+                                CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
+
+                                                                                                                                                                                MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}"
+                LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
+                DSO_LDOPTS="${MACOS_SDK_LIBS} $DSO_LDOPTS"
+                export NEXT_ROOT=$MACOS_SDK_DIR
+
+                if test -n "$CROSS_COMPILE" ; then
+                                                                                HOST_CC="NEXT_ROOT= $HOST_CC"
+                    HOST_CXX="NEXT_ROOT= $HOST_CXX"
+                fi
+            else
+                                                CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
+
+                                CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
+
+                                                                                                                                if test "$GCC_VERSION_FULL" != "4.0.0" ; then
+                                                            LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
+                    DSO_LDOPTS="$DSO_LDOPTS -isysroot ${MACOS_SDK_DIR}"
+                else
+                                                            LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
+                    DSO_LDOPTS="$DSO_LDOPTS -Wl,-syslibroot,${MACOS_SDK_DIR}"
+                fi
+            fi
         fi
-
-        if test -d "${NEXT_ROOT}/Library/Frameworks" ; then
-            SDK_C_INCLUDE="$SDK_C_INCLUDE -F${NEXT_ROOT}/Library/Frameworks"
-        fi
-
-        CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
-
-                CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
-
-        OS_LIBS="-L${NEXT_ROOT}/usr/lib/gcc/${TARGET_ARCH_LIB} -L${NEXT_ROOT}/usr/lib/gcc/${TARGET_ARCH_LIB}/${GCC_VERSION_FULL} -L${NEXT_ROOT}/usr/lib $OS_LIBS"
     fi
     ;;
 
 *-dgux*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
@@ -3937,17 +3891,33 @@ EOF
 EOF
 
         PR_MD_ASFILES=os_Linux_x86.s
         ;;
     ia64)
         PR_MD_ASFILES=os_Linux_ia64.s
         ;;
     x86_64)
-        PR_MD_ASFILES=os_Linux_x86_64.s
+        if test -n "$USE_64"; then
+            PR_MD_ASFILES=os_Linux_x86_64.s
+        else
+            cat >> confdefs.h <<\EOF
+#define i386 1
+EOF
+
+            PR_MD_ASFILES=os_Linux_x86.s
+            CC="$CC -m32"
+            CXX="$CXX -m32"
+        fi
+        ;;
+    powerpc64)
+        if test -n "$USE_64"; then
+            CC="$CC -m64"
+            CXX="$CXX -m64"
+        fi
         ;;
     m68k)
         CFLAGS="$CFLAGS -m68020-60"
         CXXFLAGS="$CXXFLAGS -m68020-60"
         ;;
     esac    
     ;;
 
@@ -4417,27 +4387,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:4426: checking for machine/builtins.h" >&5
+echo "configure:4396: 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 4431 "configure"
+#line 4401 "configure"
 #include "confdefs.h"
 #include <machine/builtins.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4436: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4406: \"$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
@@ -4500,16 +4470,36 @@ EOF
 #define _PR_NEED_H_ERRNO 1
 EOF
 
     USE_NSPR_THREADS=1
     MDCPUCFG_H=_qnx.cfg
     PR_MD_CSRCS=qnx.c
     ;;
 
+*-riscos*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define RISCOS 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define _PR_NEED_H_ERRNO 1
+EOF
+
+    USE_PTHREADS=1
+    MDCPUCFG_H=_riscos.cfg
+    PR_MD_CSRCS=riscos.c
+    DLL_SUFFIX=a
+    LD="/home/riscos/env/ro-ar cr"
+    ;;
+
 *-*-sco*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define SCO 1
 EOF
@@ -4969,63 +4959,63 @@ if test -z "$SKIP_LIBRARY_CHECKS"; then
 
 
 
 case $target in
 *-darwin*)
     ;;
 *)
     echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:4978: checking for dlopen in -ldl" >&5
+echo "configure:4968: 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 4986 "configure"
+#line 4976 "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:4997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4987: \"$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:5014: checking for dlfcn.h" >&5
+echo "configure:5004: 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 5019 "configure"
+#line 5009 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5024: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5014: \"$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
@@ -5048,23 +5038,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:5057: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:5047: 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 5063 "configure"
+#line 5053 "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
@@ -5072,17 +5062,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 5081 "configure"
+#line 5071 "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
@@ -5096,22 +5086,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:5105: checking for $ac_func" >&5
+echo "configure:5095: 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 5110 "configure"
+#line 5100 "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();
@@ -5124,17 +5114,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:5133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5123: \"$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
@@ -5165,17 +5155,17 @@ if test "${enable_strip+set}" = set; the
 fi
 
 
 case "${target_os}" in
 hpux*)
 if test -z "$GNU_CC"; then
 
     echo $ac_n "checking for +Olit support""... $ac_c" 1>&6
-echo "configure:5174: checking for +Olit support" >&5
+echo "configure:5164: 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
@@ -5197,19 +5187,24 @@ echo "$ac_t""$ac_cv_hpux_usable_olit_opt
         CXXFLAGS="$CXXFLAGS +ESlit"
     fi
 fi
 ;;
 esac
 
 
 
-
+case "$target_os" in
+darwin*)
+    _HAVE_PTHREADS=1
+    ;;
+*)
+    
 echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:5208: checking for pthread_create in -lpthreads" >&5
+echo "configure:5203: 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);
         }
@@ -5221,17 +5216,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:5230: checking for pthread_create in -lpthread" >&5
+echo "configure:5225: 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);
         }
@@ -5243,17 +5238,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:5252: checking for pthread_create in -lc_r" >&5
+echo "configure:5247: 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);
         }
@@ -5265,17 +5260,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:5274: checking for pthread_create in -lc" >&5
+echo "configure:5269: 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);
         }
@@ -5283,32 +5278,34 @@ echo "
     }" > dummy.c ;
     echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS" 1>&5;
     ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS 2>&5;
     _res=$? ;
     rm -f dummy.c dummy${ac_exeext} ;
     if test "$_res" = "0"; then
         echo "$ac_t""yes" 1>&6
         _HAVE_PTHREADS=1
-            
+                
     else
         echo "$ac_t""no" 1>&6
         
     fi
 
+            
+    fi
+
         
     fi
 
     
     fi
 
-
-    fi
-
-                        
+    ;;
+esac
+
 # Check whether --with-pthreads or --without-pthreads was given.
 if test "${with_pthreads+set}" = set; then
   withval="$with_pthreads"
    if test "$withval" = "yes"; then
 	    if test -n "$_HAVE_PTHREADS"; then
 		    USE_PTHREADS=1 
 		    USE_USER_PTHREADS=
 		    USE_NSPR_THREADS=
@@ -5417,17 +5414,17 @@ EOF
     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:5426: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5423: 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
@@ -5440,17 +5437,17 @@ echo "configure:5426: 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:5449: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5446: 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
@@ -5700,19 +5697,21 @@ EOF
 
         if test "$OS_TEST" = "i86pc"; then
             if test -n "$USE_64"; then
                PR_MD_ASFILES=os_SunOS_x86_64.s
             else
                PR_MD_ASFILES=os_SunOS_x86.s
             fi
         else
-            PR_MD_ASFILES=os_SunOS.s
             if test -n "$USE_64"; then
-                PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS_sparcv9.s"
+                PR_MD_ASFILES=os_SunOS_sparcv9.s
+            fi
+            if test -n "$USE_NATIVE_THREADS"; then
+                PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS.s"
             fi
         fi
     fi
     ;;
 *-nto*)
     if test -n "$USE_PTHREADS"; then
         cat >> confdefs.h <<\EOF
 #define _PR_HAVE_GETHOST_R 1
@@ -5754,17 +5753,17 @@ fi
 
 if test -n "$USE_64"; then
     COMPILER_TAG=_64
 fi
 
 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
 
 case "$target_os" in
-mingw*|cygwin*|msvc*|mks*)
+cygwin*|msvc*|mks*)
     CC="\$(CYGWIN_WRAPPER) $CC"
     CXX="\$(CYGWIN_WRAPPER) $CXX"
     RC="\$(CYGWIN_WRAPPER) $RC"
     ;;
 esac
 
 
 
@@ -5854,16 +5853,19 @@ esac
 
 
 
 
 
 
 
 
+
+
+
 MAKEFILES="
 Makefile 
 config/Makefile
 config/autoconf.mk
 config/nsprincl.mk
 config/nsprincl.sh
 config/nspr-config
 lib/Makefile 
@@ -5969,44 +5971,25 @@ if test "x$srcdir" = x.; then
   ac_vpsub='/^[ 	]*VPATH[ 	]*=[^:]*$/d'
 fi
 
 trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
 
 # Transform confdefs.h into DEFS.
 # Protect against shell expansion while executing Makefile rules.
 # Protect against Makefile macro expansion.
-#
-# If the first sed substitution is executed (which looks for macros that
-# take arguments), then we branch to the quote section.  Otherwise,
-# look for a macro that doesn't take arguments.
-cat >confdef2opt.sed <<\_ACEOF
-t clear
-: clear
-s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	(][^ 	(]*([^)]*)\)[ 	]*\(.*\),-D\1=\2,g
-t quote
-s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	][^ 	]*\)[ 	]*\(.*\),-D\1=\2,g
-t quote
-d
-: quote
-s,[ 	`~#$^&*(){}\\|;'"<>?],\\&,g
-s,\[,\\&,g
-s,\],\\&,g
-s,\$,$$,g
-p
-_ACEOF
-# We use echo to avoid assuming a particular line-breaking character.
-# The extra dot is to prevent the shell from consuming trailing
-# line-breaks from the sub-command output.  A line-break within
-# single-quotes doesn't work because, if this script is created in a
-# platform that uses two characters for line-breaks (e.g., DOS), tr
-# would break.
-ac_LF_and_DOT=`echo; echo .`
-DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'`
-rm -f confdef2opt.sed
+cat > conftest.defs <<\EOF
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
+s%[ 	`~#$^&*(){}\\|;'"<>?]%\\&%g
+s%\[%\\&%g
+s%\]%\\&%g
+s%\$%$$%g
+EOF
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' ' | tr '\015' ' '`
+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
 cat > $CONFIG_STATUS <<EOF
@@ -6100,16 +6083,17 @@ 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%@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%@USE_CPLUS@%$USE_CPLUS%g
 s%@USE_IPV6@%$USE_IPV6%g
 s%@USE_N32@%$USE_N32%g
@@ -6139,17 +6123,17 @@ s%@DLL_SUFFIX@%$DLL_SUFFIX%g
 s%@ASM_SUFFIX@%$ASM_SUFFIX%g
 s%@MKSHLIB@%$MKSHLIB%g
 s%@DSO_CFLAGS@%$DSO_CFLAGS%g
 s%@DSO_LDOPTS@%$DSO_LDOPTS%g
 s%@OS_TARGET@%$OS_TARGET%g
 s%@OS_ARCH@%$OS_ARCH%g
 s%@OS_RELEASE@%$OS_RELEASE%g
 s%@OS_TEST@%$OS_TEST%g
-s%@MACOS_DEPLOYMENT_TARGET@%$MACOS_DEPLOYMENT_TARGET%g
+s%@MACOSX_DEPLOYMENT_TARGET@%$MACOSX_DEPLOYMENT_TARGET%g
 s%@DEFINES@%$DEFINES%g
 s%@AR_FLAGS@%$AR_FLAGS%g
 s%@ASFLAGS@%$ASFLAGS%g
 s%@FILTER@%$FILTER%g
 s%@IMPLIB@%$IMPLIB%g
 s%@OS_LIBS@%$OS_LIBS%g
 s%@RESOLVE_LINK_SYMBOLS@%$RESOLVE_LINK_SYMBOLS%g
 s%@AIX_LINK_OPTS@%$AIX_LINK_OPTS%g
@@ -6164,16 +6148,18 @@ s%@OPTIMIZER@%$OPTIMIZER%g
 s%@RC@%$RC%g
 s%@RCFLAGS@%$RCFLAGS%g
 s%@DLLFLAGS@%$DLLFLAGS%g
 s%@EXEFLAGS@%$EXEFLAGS%g
 s%@OS_DLLFLAGS@%$OS_DLLFLAGS%g
 s%@CYGWIN_WRAPPER@%$CYGWIN_WRAPPER%g
 s%@VISIBILITY_FLAGS@%$VISIBILITY_FLAGS%g
 s%@WRAP_SYSTEM_INCLUDES@%$WRAP_SYSTEM_INCLUDES%g
+s%@MACOS_SDK_DIR@%$MACOS_SDK_DIR%g
+s%@NEXT_ROOT@%$NEXT_ROOT%g
 
 CEOF
 EOF
 
 cat >> $CONFIG_STATUS <<\EOF
 
 # Split the substitutions into bite-sized pieces for seds with
 # small command number limits, like on Digital OSF/1 and HP-UX.
--- a/configure.in
+++ b/configure.in
@@ -14,16 +14,18 @@ dnl The Original Code is the Netscape Po
 dnl 
 dnl The Initial Developer of the Original Code is Netscape
 dnl Communications Corporation.  Portions created by Netscape are 
 dnl Copyright (C) 1998o-2000 Netscape Communications Corporation.  All
 dnl Rights Reserved.
 dnl 
 dnl Contributor(s):
 dnl     Christopher Seawood <cls@seawood.org>
+dnl     Howard Chu <hyc@symas.com>
+dnl     Mark Mentovai <mark@moxienet.com>
 dnl 
 dnl Alternatively, the contents of this file may be used under the
 dnl terms of the GNU General Public License Version 2 or later (the
 dnl "GPL"), in which case the provisions of the GPL are applicable 
 dnl instead of those above.  If you wish to allow use of your 
 dnl version of this file only under the terms of the GPL and not to
 dnl allow others to use your version of this file under the MPL,
 dnl indicate your decision by deleting the provisions above and
@@ -39,40 +41,42 @@ 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=6
-MOD_PATCH_VERSION=0
+MOD_PATCH_VERSION=1
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_64=
 USE_CPLUS=
 USE_IPV6=
 USE_MDUPDATE=
-MACOS_DEPLOYMENT_TARGET=
+_MACOSX_DEPLOYMENT_TARGET=
 _OPTIMIZE_FLAGS=-O
 _DEBUG_FLAGS=-g
 MOZ_DEBUG=1
 MOZ_OPTIMIZE=
 OBJDIR=.
 OBJDIR_NAME=.
 OBJDIR_SUFFIX=OBJ
 NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall'
 NOSUCHFILE=/no-such-file
 LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)'
 LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)'
 CYGWIN_WRAPPER=
+MACOS_SDK_DIR=
+NEXT_ROOT=
 
 dnl Link in libraries necessary to resolve all symbols for shared libs
 RESOLVE_LINK_SYMBOLS=
 
 dnl ========================================================
 dnl =
 dnl = Dont change the following lines.  Doing so breaks:
 dnl =
@@ -220,21 +224,28 @@ AC_ARG_ENABLE(64bit,
       fi ])
 
 AC_ARG_ENABLE(mdupdate,
     [  --enable-mdupdate       Enable use of certain compilers' mdupdate feature],
     [ if test "$enableval" = "yes"; then
 	    USE_MDUPDATE=1
       fi ])
 
+dnl ========================================================
+dnl = Mac OS X SDK support
+dnl ========================================================
+AC_ARG_WITH(macos-sdk,
+    [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
+    MACOS_SDK_DIR=$withval)
+
 AC_ARG_ENABLE(macos-target,
-             [  --enable-macos-target=VER (default=10.1)
-                          Set the minimum MacOS version needed at runtime],
-             [MACOS_DEPLOYMENT_TARGET_STR=$enableval],
-             [MACOS_DEPLOYMENT_TARGET_STR=10.1])
+             [  --enable-macos-target=VER
+                          Set the minimum MacOS version needed at runtime
+                          [10.1 for ppc, 10.4 for x86]],
+             [_MACOSX_DEPLOYMENT_TARGET=$enableval])
 
 dnl ========================================================
 dnl =
 dnl = Set the threading model
 dnl =
 dnl ========================================================
 case "$target" in
 
@@ -396,22 +407,47 @@ if test "$target" != "$host"; then
     AC_TRY_COMPILE([], [return(0);], 
         [ac_cv_prog_host_cc_works=1 AC_MSG_RESULT([yes])],
         AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.]) )
 
     CC=$_SAVE_CC
     CFLAGS=$_SAVE_CFLAGS
     LDFLAGS=$_SAVE_LDFLAGS
 
+    case "$build:$target" in 
+      powerpc-apple-darwin8*:i?86-apple-darwin*)
+        dnl The Darwin cross compiler doesn't necessarily point itself at a
+        dnl root that has libraries for the proper architecture, it defaults
+        dnl to the system root.  The libraries in the system root on current
+        dnl versions of PPC OS X 10.4 aren't fat, so these target compiler
+        dnl checks will fail.  Fake a working SDK in that case.
+        _SAVE_CFLAGS=$CFLAGS 
+        _SAVE_CXXFLAGS=$CXXLAGS
+        CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS"
+        CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS"
+        ;;        
+    esac            
+
     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
     unset ac_cv_prog_CC
     AC_PROG_CC
     AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", echo)
     unset ac_cv_prog_CXX
     AC_PROG_CXX
+
+    case "$build:$target" in
+      powerpc-apple-darwin8*:i?86-apple-darwin*)
+        dnl Revert the changes made above.  From this point on, the target
+        dnl compiler will never be used without applying the SDK to CFLAGS
+        dnl (see --with-macos-sdk below).
+        CFLAGS=$_SAVE_CFLAGS
+        CXXFLAGS=$_SAVE_CXXFLAGS
+        ;;
+    esac
+
     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", echo)
     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", echo)
     AC_CHECK_PROGS(AS, $AS "${target_alias}-as" "${target}-as", echo)
     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", echo)
     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo)
     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo)
 
 else
@@ -442,16 +478,25 @@ fi
 if test "$GXX" = "yes"; then
     GNU_CXX=1
 fi
 if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then
     GNU_AS=1
 fi
 rm -f a.out
 
+case "$build:$target" in
+    i?86-apple-darwin*:powerpc-apple-darwin*)
+        dnl cross_compiling will have erroneously been set to "no" in this
+        dnl case, because the x86 build host is able to run ppc code in a
+        dnl translated environment, making a cross compiler appear native.
+        cross_compiling=yes
+        ;;
+esac
+
 if test "$cross_compiling"  = "yes"; then
     CROSS_COMPILE=1
 else
     CROSS_COMPILE=
 fi
 
 dnl ========================================================
 dnl Check for gcc -pipe support
@@ -575,16 +620,17 @@ ASFLAGS='$(CFLAGS)'
 if test -n "$CROSS_COMPILE"; then
     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
     OS_RELEASE=
     OS_TEST="${target_cpu}"
     case "${target_os}" in
         linux*)       OS_ARCH=Linux ;;
         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
         mingw*)       OS_ARCH=WINNT ;;
+        darwin*)      OS_ARCH=Darwin ;;
     esac
 else
     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
     OS_RELEASE=`uname -r`
     OS_TEST=`uname -m`
 fi
 
 if test "$OS_ARCH" = "IRIX64"; then
@@ -629,43 +675,51 @@ fi
 #
 
 #
 # The following hack allows one to build on a WIN95 machine (as if
 # s/he were cross-compiling on a WINNT host for a WIN95 target).
 # It also accomodates for MKS's uname.exe.  If you never intend
 # to do development on a WIN95 machine, you don't need this hack.
 #
-if test "$OS_ARCH" = "WIN95"; then
+case "$OS_ARCH" in
+WIN95)
     OS_ARCH=WINNT
     OS_TARGET=WIN95
-elif test "$OS_ARCH" = 'Windows_95'; then
+    ;;
+Windows_95)
     OS_ARCH=Windows_NT
     OS_TARGET=WIN95
-elif test "$OS_ARCH" = 'Windows_98'; then
+    ;;
+Windows_98)
     OS_ARCH=Windows_NT
     OS_TARGET=WIN95
-elif test "`echo $OS_ARCH | egrep -c '^(CYGWIN_9|CYGWIN_ME)' 2>/dev/null`" != 0; then
+    ;;
+CYGWIN_9*|CYGWIN_ME*)
     OS_ARCH='CYGWIN_NT-4.0'
     OS_TARGET=WIN95
-elif test "$OS_ARCH" = "OS_2"; then
+    ;;
+OS_2)
     OS_ARCH=OS2
     OS_TARGET=OS2
-fi
+    ;;
+esac
 
 #
 # On WIN32, we also define the variable CPU_ARCH.
 #
 
-if test "$OS_ARCH" = "WINNT"; then
+case "$OS_ARCH" in
+WINNT)
     CPU_ARCH=`uname -p`
     if test "$CPU_ARCH" = "I386"; then
         CPU_ARCH=x86
     fi
-elif test "$OS_ARCH" = "Windows_NT"; then
+    ;;
+Windows_NT)
 #
 # If uname -s returns "Windows_NT", we assume that we are using
 # the uname.exe in MKS toolkit.
 #
 # The -r option of MKS uname only returns the major version number.
 # So we need to use its -v option to get the minor version number.
 # Moreover, it doesn't have the -p option, so we need to use uname -m.
 #
@@ -677,45 +731,35 @@ elif test "$OS_ARCH" = "Windows_NT"; the
     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
     CPU_ARCH=`uname -m`
     #
     # MKS's uname -m returns "586" on a Pentium machine.
     #
     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
         CPU_ARCH=x86
     fi
-elif echo "$OS_ARCH" | grep -c CYGWIN_NT >/dev/null; then
+    ;;
+CYGWIN_NT*|MINGW*_NT*)
 #
 # If uname -s returns "CYGWIN_NT-4.0", we assume that we are using
 # the uname.exe in the Cygwin tools.
+# If uname -s returns MINGW32_NT-5.1, we assume that we are using
+# the uname.exe in the MSYS tools.
 #
-    OS_RELEASE=`echo $OS_ARCH | sed 's|^CYGWIN_NT-||'`
+    OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
     OS_ARCH=WINNT
     CPU_ARCH=`uname -m`
     #
     # Cygwin's uname -m returns "i686" on a Pentium Pro machine.
     #
     if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
         CPU_ARCH=x86
     fi
-elif test "$OS_ARCH" = "CYGWIN32_NT"; then
-#
-# Prior to the Beta 20 release, Cygwin was called GNU-Win32.
-# If uname -s returns "CYGWIN32/NT", we assume that we are using
-# the uname.exe in the GNU-Win32 tools.
-#
-    OS_ARCH=WINNT
-    CPU_ARCH=`uname -m`
-    #
-    # GNU-Win32's uname -m returns "i686" on a Pentium Pro machine.
-    #
-    if echo "$CPU_ARCH" | grep -c 86 >/dev/null; then
-        CPU_ARCH=x86
-    fi
-fi
+    ;;
+esac
 
 if test -n "$MOZILLA_CLIENT" && test "$OS_ARCH" = "WINNT"; then
     OS_TARGET=WIN95
     if test -n "$MOZ_DEBUG"; then
         USE_DEBUG_RTL=1
     fi
 fi
 if test -z "$OS_TARGET"; then
@@ -730,17 +774,20 @@ fi
 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
 
 dnl ========================================================
 
 dnl ========================================================
 dnl Override of system specific host options
 dnl ========================================================
 case "$host" in
-*-mingw*|*-cygwin*|*-msvc*|*-mks*)
+*-mingw*)
+    NSINSTALL=nsinstall
+    ;;
+*-cygwin*|*-msvc*|*-mks*)
     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
     if test `echo "${PATH}" | grep -c \;` = 0; then
         CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
     fi
     ;;
 *-beos*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
     ;;
@@ -910,101 +957,145 @@ case "$target" in
 
     ;;
 
 *-darwin*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(DARWIN)
     AC_DEFINE(HAVE_BSD_FLOCK)
     CFLAGS="$CFLAGS -Wmost -fno-common"
-    if echo $OS_TEST | grep -c 86 2>/dev/null; then
-        AC_DEFINE(i386)
-        CPU_ARCH=i386
-    else
-        AC_DEFINE(ppc)
-        CPU_ARCH=ppc
-    fi
+    case "${target_cpu}" in
+        i*86*)
+            AC_DEFINE(i386)
+            CPU_ARCH=i386
+            PR_MD_ASFILES=os_Darwin_x86.s
+            ;;
+        *)
+            AC_DEFINE(ppc)
+            CPU_ARCH=ppc
+            PR_MD_ASFILES=os_Darwin_ppc.s
+            ;;
+    esac
+    DSO_CFLAGS=-fPIC
     DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names'
     # Use the standard preprocessor (cpp)
     CFLAGS="$CFLAGS -no-cpp-precomp"
-    MKSHLIB='$(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -o $@'
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     STRIP="$STRIP -x -S"
     DLL_SUFFIX=dylib
     USE_PTHREADS=1
     MDCPUCFG_H=_darwin.cfg
     PR_MD_CSRCS=darwin.c
-    if test "$CPU_ARCH" = "ppc"; then
-        PR_MD_ASFILES=os_Darwin_ppc.s
-    fi
 
     # Add Mac OS X support for loading CFM & CFBundle plugins
     if test -f /System/Library/Frameworks/Carbon.framework/Carbon; then
         AC_DEFINE(XP_MACOSX)
         OS_TARGET=MacOSX
 
-        dnl The C preprocessor can only handle integers in comparisons, so
-        dnl convert the version to the form AABBCC where AA=major release,
-        dnl BB=minor release, and CC=point/micro release.
-
-        MACOS_VERSION_MAJOR=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 1`
-        MACOS_VERSION_MINOR=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 2`
-        MACOS_VERSION_MICRO=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 3`
-        if test -z "$MACOS_VERSION_MINOR"; then
-            MACOS_VERSION_MINOR=0
-        fi
-        if test -z "$MACOS_VERSION_MICRO"; then
-            MACOS_VERSION_MICRO=0
-        fi
-        MACOS_DEPLOYMENT_TARGET=`printf "%02d%02d%02d" "$MACOS_VERSION_MAJOR" "$MACOS_VERSION_MINOR" "$MACOS_VERSION_MICRO"`
-        AC_DEFINE_UNQUOTED(MACOS_DEPLOYMENT_TARGET, $MACOS_DEPLOYMENT_TARGET)
-    fi
-
-    # do the right thing for SDK support
-    if test "$NEXT_ROOT"; then
-        dnl Synced to the MACOS_SDK_DIR block in Mozilla's top-level
-        dnl configure.in
-
-        dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0.
-        dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for
-        dnl the environment and includedir purposes (when using an SDK, below),
-        dnl but remember the full version number for the libdir (SDK).
-
-        changequote(,)
-        CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
-        GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
-        GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
-        changequote([,])
-        GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
-
-        if test "$GCC_VERSION_MAJOR" -lt "4" ; then
-            TARGET_ARCH_LIB="darwin"
-            TARGET_ARCH_INCLUDE="ppc-darwin"
-            SDK_C_INCLUDE="-isystem ${NEXT_ROOT}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${NEXT_ROOT}/usr/include -F${NEXT_ROOT}/System/Library/Frameworks"
-        else
-            dnl If gcc >= 4, use powerpc-apple-darwin#, where # is the version
-            dnl of the Darwin release corresponding to the target Mac OS X
-            dnl release.  For OS X >= 10.1.1, take the minor version number and
-            dnl add 4 to get the Darwin major version number.  If it can't be 
-            dnl determined, use current Darwin major version number and hope
-            dnl that there's a symlink.
-            TARGET_ARCH_LIB=powerpc-apple-darwin`echo $NEXT_ROOT | $PERL -pe 's/MacOSX10\.([^\.]*)//;if ($1) {$_=$1+4;} else {$_="'${target_os}'";s/(\d+)//;$_=$1;}'`
-            TARGET_ARCH_INCLUDE=$TARGET_ARCH_LIB
-            SDK_C_INCLUDE="-isystem ${NEXT_ROOT}/usr/lib/gcc/${TARGET_ARCH_LIB}/${GCC_VERSION_FULL}/include -isystem ${NEXT_ROOT}/usr/include -F${NEXT_ROOT}/System/Library/Frameworks"
+        if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
+            dnl Use the specified value
+            export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
+        elif test -z "$MACOSX_DEPLOYMENT_TARGET" ; then
+            dnl No value specified on the command line or in the environment,
+            dnl use the lesser of the library's minimum or the architecture's
+            dnl minimum.
+            case "${target_cpu}" in
+                powerpc*)
+                    dnl Architecture minimum 10.1
+                    export MACOSX_DEPLOYMENT_TARGET=10.1
+                    ;;
+                i*86*)
+                    dnl Architecture minimum 10.4
+                    export MACOSX_DEPLOYMENT_TARGET=10.4
+                    ;;
+            esac
         fi
 
-        if test -d "${NEXT_ROOT}/Library/Frameworks" ; then
-            SDK_C_INCLUDE="$SDK_C_INCLUDE -F${NEXT_ROOT}/Library/Frameworks"
-        fi
+        dnl MACOS_SDK_DIR will be set to the SDK location whenever one is
+        dnl in use.  NEXT_ROOT will be set and exported if it's needed for
+        dnl ld.
+
+        if test "$MACOS_SDK_DIR"; then
+            dnl Sync this section with the one in Mozilla's top level.
+
+            if test ! -d "$MACOS_SDK_DIR"; then
+                AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
+specify a valid SDK.  SDKs are installed when the optional cross-development
+tools are selected during the Xcode/Developer Tools installation.])
+            fi
+
+            changequote(,)
+            CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'`
+            GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
+            GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
+            changequote([,])
+            GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
+            if test "$GCC_VERSION_MAJOR" -lt "4" ; then
+                SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks"
+                if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
+                    SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks"
+                fi
+
+                SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}"
+
+                CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
+
+                dnl CPP needs to be set for AC_CHECK_HEADER.
+                CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
 
-        CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
+                dnl ld support for -syslibroot is compiler-agnostic, but only
+                dnl available on Tiger.  Although it's possible to switch on
+                dnl the build host's OS release to use ld -syslibroot when
+                dnl available, ld -syslibroot cause warnings as long as
+                dnl NEXT_ROOT is set.  NEXT_ROOT should be set because both
+                dnl both the compiler and linker use it.
+                dnl
+                dnl LDFLAGS is for the utilities built in config (now and
+                dnl nsinstall).  DSO_LDOPTS is used when linking shared
+                dnl libraries.
+                MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}"
+                LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS"
+                DSO_LDOPTS="${MACOS_SDK_LIBS} $DSO_LDOPTS"
+                export NEXT_ROOT=$MACOS_SDK_DIR
 
-        dnl CPP needs to be set for AC_CHECK_HEADER.
-        CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
+                if test -n "$CROSS_COMPILE" ; then
+                    dnl NEXT_ROOT will be in the environment, but it
+                    dnl shouldn't be set for the build host.  HOST_CXX is
+                    dnl presently unused.
+                    HOST_CC="NEXT_ROOT= $HOST_CC"
+                    HOST_CXX="NEXT_ROOT= $HOST_CXX"
+                fi
+            else
+                dnl gcc >= 4.0 uses different paths than above, but knows
+                dnl how to find them itself.
+                CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
+
+                dnl CPP needs to be set for AC_CHECK_HEADER.
+                CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
 
-        OS_LIBS="-L${NEXT_ROOT}/usr/lib/gcc/${TARGET_ARCH_LIB} -L${NEXT_ROOT}/usr/lib/gcc/${TARGET_ARCH_LIB}/${GCC_VERSION_FULL} -L${NEXT_ROOT}/usr/lib $OS_LIBS"
+                dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which
+                dnl has an ld that supports -syslibroot.  Don't set
+                dnl NEXT_ROOT because it will be ignored and cause
+                dnl warnings when -syslibroot is specified.
+                dnl
+                dnl Both LDFLAGS and DSO_LDOPTS are set here, see the
+                dnl gcc < 4.0 case for the explanation.
+                if test "$GCC_VERSION_FULL" != "4.0.0" ; then
+                    dnl gcc > 4.0.0 will pass -syslibroot to ld automatically
+                    dnl based on the -isysroot it receives.
+                    LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}"
+                    DSO_LDOPTS="$DSO_LDOPTS -isysroot ${MACOS_SDK_DIR}"
+                else
+                    dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs
+                    dnl to be explicit.
+                    LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
+                    DSO_LDOPTS="$DSO_LDOPTS -Wl,-syslibroot,${MACOS_SDK_DIR}"
+                fi
+            fi
+        fi
     fi
     ;;
 
 *-dgux*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
     AC_DEFINE(SVR4)
     AC_DEFINE(SYSV)
@@ -1320,17 +1411,30 @@ case "$target" in
     i*86)
         AC_DEFINE(i386)
         PR_MD_ASFILES=os_Linux_x86.s
         ;;
     ia64)
         PR_MD_ASFILES=os_Linux_ia64.s
         ;;
     x86_64)
-        PR_MD_ASFILES=os_Linux_x86_64.s
+        if test -n "$USE_64"; then
+            PR_MD_ASFILES=os_Linux_x86_64.s
+        else
+            AC_DEFINE(i386)
+            PR_MD_ASFILES=os_Linux_x86.s
+            CC="$CC -m32"
+            CXX="$CXX -m32"
+        fi
+        ;;
+    powerpc64)
+        if test -n "$USE_64"; then
+            CC="$CC -m64"
+            CXX="$CXX -m64"
+        fi
         ;;
     m68k)
         CFLAGS="$CFLAGS -m68020-60"
         CXXFLAGS="$CXXFLAGS -m68020-60"
         ;;
     esac    
     ;;
 
@@ -1674,16 +1778,27 @@ mips-sony-newsos*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(QNX)
     AC_DEFINE(_PR_NEED_H_ERRNO)
     USE_NSPR_THREADS=1
     MDCPUCFG_H=_qnx.cfg
     PR_MD_CSRCS=qnx.c
     ;;
 
+*-riscos*)
+    AC_DEFINE(XP_UNIX)
+    AC_DEFINE(RISCOS)
+    AC_DEFINE(_PR_NEED_H_ERRNO)
+    USE_PTHREADS=1
+    MDCPUCFG_H=_riscos.cfg
+    PR_MD_CSRCS=riscos.c
+    DLL_SUFFIX=a
+    LD="/home/riscos/env/ro-ar cr"
+    ;;
+
 *-*-sco*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(SCO)
     AC_DEFINE(sco)
     AC_DEFINE(SYSV)
     AC_DEFINE(_SVID3)
     AC_DEFINE(_PR_NEED_H_ERRNO)
     CC='cc -b elf -KPIC'
@@ -2152,29 +2267,36 @@ echo "
         AC_MSG_RESULT([yes])
         [$2]
     else
         AC_MSG_RESULT([no])
         [$3]
     fi
 ])
 
-MOZ_CHECK_PTHREADS(pthreads,
-    _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
-    MOZ_CHECK_PTHREADS(pthread,
-        _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
-        MOZ_CHECK_PTHREADS(c_r,
-            _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
-            MOZ_CHECK_PTHREADS(c,
-                _HAVE_PTHREADS=1
+case "$target_os" in
+darwin*)
+    _HAVE_PTHREADS=1
+    ;;
+*)
+    MOZ_CHECK_PTHREADS(pthreads,
+        _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
+        MOZ_CHECK_PTHREADS(pthread,
+            _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
+            MOZ_CHECK_PTHREADS(c_r,
+                _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
+                MOZ_CHECK_PTHREADS(c,
+                    _HAVE_PTHREADS=1
+                )
             )
         )
     )
-)
-                        
+    ;;
+esac
+
 AC_ARG_WITH(pthreads,
     [  --with-pthreads         Use system pthreads library as thread subsystem],
     [ if test "$withval" = "yes"; then
 	    if test -n "$_HAVE_PTHREADS"; then
 		    USE_PTHREADS=1 
 		    USE_USER_PTHREADS=
 		    USE_NSPR_THREADS=
 	    else
@@ -2208,27 +2330,29 @@ AC_ARG_ENABLE(nspr-threads,
 	    USE_PTHREADS=
 	    USE_USER_PTHREADS=
 	    USE_NSPR_THREADS=1
 	  fi])
 
 case "$target" in
 *-beos*)
     AC_ARG_WITH(bthreads,
-    [  --with-bthreads         Use system bthreads library as thread subsystem (BeOS only)],
+    [  --with-bthreads         Use system bthreads library as thread subsystem
+                          (BeOS only)],
     [	if test "$withval" = "yes"; then
     	    USE_BTHREADS=1
 	        USE_USER_PTHREADS=
 	        USE_PTHREADS=
 	    fi])
     ;;
 
 *-solaris*)
     AC_ARG_WITH(native-threads,
-    [  --with-native-threads   Use native system threads as thread subsystem (Solaris only)],
+    [  --with-native-threads   Use native system threads as thread subsystem
+                          (Solaris only)],
     [ if test "$withval" = "yes"; then
 	    USE_NATIVE_THREADS=1
 	    USE_USER_PTHREADS=
 	    USE_PTHREADS=
 	  fi])
     ;;
 esac
 
@@ -2457,19 +2581,21 @@ case "$target" in
         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
         if test "$OS_TEST" = "i86pc"; then
             if test -n "$USE_64"; then
                PR_MD_ASFILES=os_SunOS_x86_64.s
             else
                PR_MD_ASFILES=os_SunOS_x86.s
             fi
         else
-            PR_MD_ASFILES=os_SunOS.s
             if test -n "$USE_64"; then
-                PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS_sparcv9.s"
+                PR_MD_ASFILES=os_SunOS_sparcv9.s
+            fi
+            if test -n "$USE_NATIVE_THREADS"; then
+                PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS.s"
             fi
         fi
     fi
     ;;
 *-nto*)
     if test -n "$USE_PTHREADS"; then
         AC_DEFINE(_PR_HAVE_GETHOST_R)
         AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
@@ -2507,20 +2633,20 @@ fi
 
 if test -n "$USE_64"; then
     COMPILER_TAG=_64
 fi
 
 RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
 
 dnl ========================================================
-dnl Use cygwin wrapper for win32 builds
+dnl Use cygwin wrapper for win32 builds, except MSYS/MinGW
 dnl ========================================================
 case "$target_os" in
-mingw*|cygwin*|msvc*|mks*)
+cygwin*|msvc*|mks*)
     CC="\$(CYGWIN_WRAPPER) $CC"
     CXX="\$(CYGWIN_WRAPPER) $CXX"
     RC="\$(CYGWIN_WRAPPER) $RC"
     ;;
 esac
 
 dnl ========================================================
 dnl Substitution of found variables.
@@ -2531,16 +2657,17 @@ AC_SUBST(MOZILLA_CLIENT)
 AC_SUBST(CC)
 AC_SUBST(CXX)
 AC_SUBST(CFLAGS)
 AC_SUBST(CXXFLAGS)
 AC_SUBST(CPPFLAGS)
 AC_SUBST(HOST_CC)
 AC_SUBST(HOST_CFLAGS)
 AC_SUBST(LDFLAGS)
+AC_SUBST(HOST_LDFLAGS)
 AC_SUBST(GNU_CC)
 AC_SUBST(GCC_USE_GNU_LD)
 AC_SUBST(MSC_VER)
 AC_SUBST(CROSS_COMPILE)
 
 AC_SUBST(MOZ_OPTIMIZE)
 
 AC_SUBST(USE_CPLUS)
@@ -2577,17 +2704,17 @@ AC_SUBST(ASM_SUFFIX)
 AC_SUBST(MKSHLIB)
 AC_SUBST(DSO_CFLAGS)
 AC_SUBST(DSO_LDOPTS)
 
 AC_SUBST(OS_TARGET)
 AC_SUBST(OS_ARCH)
 AC_SUBST(OS_RELEASE)
 AC_SUBST(OS_TEST)
-AC_SUBST(MACOS_DEPLOYMENT_TARGET)
+AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
 
 AC_SUBST(DEFINES)
 AC_SUBST(DEFS)
 AC_SUBST(AR)
 AC_SUBST(AR_FLAGS)
 AC_SUBST(AS)
 AC_SUBST(ASFLAGS)
 AC_SUBST(LD)
@@ -2612,16 +2739,18 @@ AC_SUBST(OPTIMIZER)
 AC_SUBST(RC)
 AC_SUBST(RCFLAGS)
 AC_SUBST(DLLFLAGS)
 AC_SUBST(EXEFLAGS)
 AC_SUBST(OS_DLLFLAGS)
 AC_SUBST(CYGWIN_WRAPPER)
 AC_SUBST(VISIBILITY_FLAGS)
 AC_SUBST(WRAP_SYSTEM_INCLUDES)
+AC_SUBST(MACOS_SDK_DIR)
+AC_SUBST(NEXT_ROOT)
 
 dnl ========================================================
 dnl Generate output files.
 dnl ========================================================
 MAKEFILES="
 Makefile 
 config/Makefile
 config/autoconf.mk
--- a/pkg/linux/Makefile.in
+++ b/pkg/linux/Makefile.in
@@ -42,38 +42,68 @@
 #
 
 MOD_DEPTH = ../..
 topsrcdir   = @top_srcdir@
 srcdir	    = @srcdir@
 VPATH	    = @srcdir@
 
 NAME        = sun-nspr
-RELEASE     = 2
+RELEASE     = 1
 TOPDIR      = /usr/src/redhat
 VERSION     = `grep PR_VERSION $(dist_includedir)/prinit.h \
                   | sed -e 's/"$$//' -e 's/.*"//' -e 's/ .*//'`
 
 SPECFILE    = $(NAME).spec
 
 include $(MOD_DEPTH)/config/autoconf.mk
 
+# Force i386 for non 64 bit build
+ifneq ($(USE_64),1)
+	RPMTARGET = "--target=i386"
+	RPMLIBDIR = lib
+else
+	RPMLIBDIR = lib64
+endif
+
 publish:
 	$(MAKE) clean
 	mkdir -p SOURCES SRPMS RPMS BUILD
-	(cd $(MOD_DEPTH)/../../dist/$(RELEASE_OBJDIR_NAME)/lib && tar cphf - .) \
-	| (mkdir -p opt/sun/private/lib && cd opt/sun/private/lib && tar xvfBp -)
-	(cd $(MOD_DEPTH)/../../dist/$(RELEASE_OBJDIR_NAME)/include && tar cphf - .) \
+	(cd $(dist_libdir) && tar cphf - libnspr4.so libplds4.so libplc4.so) \
+	| (mkdir -p opt/sun/private/$(RPMLIBDIR) && cd opt/sun/private/$(RPMLIBDIR) && tar xvfBp -)
+	(cd $(dist_includedir) && tar cphf - .) \
 	| (mkdir -p opt/sun/private/include/nspr && cd opt/sun/private/include/nspr && tar xvfBp -)
+	(cd opt/sun/private/include/nspr && \
+		rm -rf md private obsolete/pralarm.h obsolete/probslet.h obsolete/prsem.h)
 	tar czvf SOURCES/$(NAME)-$(VERSION).tar.gz opt
 	echo "%define name $(NAME)" >$(SPECFILE)
 	echo "%define version $(VERSION)" >>$(SPECFILE)
 	echo "%define release $(RELEASE)" >>$(SPECFILE)
 	echo "%define buildroot `pwd`/$(NAME)-root" >>$(SPECFILE)
 	echo "%define _topdir `pwd`" >>$(SPECFILE)
+	echo "%define _unpackaged_files_terminate_build 0" >>$(SPECFILE)
 	cat $(srcdir)/$(NAME).spec >>$(SPECFILE)
-	rpm -ba $(SPECFILE)
+	echo "" >>$(SPECFILE)
+	echo "%files" >>$(SPECFILE)
+	echo "%defattr(-,root,root)" >>$(SPECFILE)
+	echo "%dir /opt" >>$(SPECFILE)
+	echo "%dir /opt/sun" >>$(SPECFILE)
+	echo "%dir /opt/sun/private" >>$(SPECFILE)
+	echo "%dir /opt/sun/private/$(RPMLIBDIR)" >>$(SPECFILE)
+	find opt \( -name "*.so" \) | sed -e "s-^-/-" >>$(SPECFILE)
+	echo "" >>$(SPECFILE)
+	echo "%files devel" >>$(SPECFILE)
+	echo "%defattr(-,root,root)" >>$(SPECFILE)
+	echo "%dir /opt" >>$(SPECFILE)
+	echo "%dir /opt/sun" >>$(SPECFILE)
+	echo "%dir /opt/sun/private" >>$(SPECFILE)
+	echo "%dir /opt/sun/private/include" >>$(SPECFILE)
+	echo "%dir /opt/sun/private/include/nspr" >>$(SPECFILE)
+	echo "%dir /opt/sun/private/include/nspr/obsolete" >>$(SPECFILE)
+	find opt -type f \( -name "*.h" \) \
+		| sed -e "s-^-/-" >>$(SPECFILE)
+	rpmbuild $(RPMTARGET) -bb $(SPECFILE)
 
 clean:
 	rm -rf $(TOPDIR)/BUILD/$(NAME)
 	rm -rf SOURCES SRPMS RPMS BUILD
 	rm -rf RPMS SRPMS opt
 	rm -f $(NAME)-$(VERSION).tar.gz
--- a/pkg/linux/sun-nspr.spec
+++ b/pkg/linux/sun-nspr.spec
@@ -74,81 +74,8 @@ Under "MPL/GPL" license.
 %install
 rm -rf $RPM_BUILD_ROOT
 mkdir $RPM_BUILD_ROOT
 cd $RPM_BUILD_ROOT
 tar xvzf $RPM_SOURCE_DIR/%{name}-%{version}.tar.gz
 
 %clean
 rm -rf $RPM_BUILD_ROOT
-
-%files
-%defattr(-,root,root)
-%dir /opt
-%dir /opt/sun
-%dir /opt/sun/private
-%dir /opt/sun/private/lib
-/opt/sun/private/lib/libnspr4.so
-/opt/sun/private/lib/libplc4.so
-/opt/sun/private/lib/libplds4.so
-
-%files devel
-%defattr(-,root,root)
-%dir /opt
-%dir /opt/sun
-%dir /opt/sun/private
-%dir /opt/sun/private/include
-%dir /opt/sun/private/include/nspr
-%dir /opt/sun/private/include/nspr/obsolete
-/opt/sun/private/include/nspr/prcpucfg.h
-/opt/sun/private/include/nspr/obsolete/protypes.h
-/opt/sun/private/include/nspr/nspr.h
-/opt/sun/private/include/nspr/pratom.h
-/opt/sun/private/include/nspr/prbit.h
-/opt/sun/private/include/nspr/prclist.h
-/opt/sun/private/include/nspr/prcmon.h
-/opt/sun/private/include/nspr/prcountr.h
-/opt/sun/private/include/nspr/prcvar.h
-/opt/sun/private/include/nspr/prdtoa.h
-/opt/sun/private/include/nspr/prenv.h
-/opt/sun/private/include/nspr/prerr.h
-/opt/sun/private/include/nspr/prerror.h
-/opt/sun/private/include/nspr/prinet.h
-/opt/sun/private/include/nspr/prinit.h
-/opt/sun/private/include/nspr/prinrval.h
-/opt/sun/private/include/nspr/prio.h
-/opt/sun/private/include/nspr/pripcsem.h
-/opt/sun/private/include/nspr/prlink.h
-/opt/sun/private/include/nspr/prlock.h
-/opt/sun/private/include/nspr/prlog.h
-/opt/sun/private/include/nspr/prlong.h
-/opt/sun/private/include/nspr/prmem.h
-/opt/sun/private/include/nspr/prmon.h
-/opt/sun/private/include/nspr/prmwait.h
-/opt/sun/private/include/nspr/prnetdb.h
-/opt/sun/private/include/nspr/prolock.h
-/opt/sun/private/include/nspr/prpdce.h
-/opt/sun/private/include/nspr/prprf.h
-/opt/sun/private/include/nspr/prproces.h
-/opt/sun/private/include/nspr/prrng.h
-/opt/sun/private/include/nspr/prrwlock.h
-/opt/sun/private/include/nspr/prshma.h
-/opt/sun/private/include/nspr/prshm.h
-/opt/sun/private/include/nspr/prsystem.h
-/opt/sun/private/include/nspr/prthread.h
-/opt/sun/private/include/nspr/prtime.h
-/opt/sun/private/include/nspr/prtpool.h
-/opt/sun/private/include/nspr/prtrace.h
-/opt/sun/private/include/nspr/prtypes.h
-/opt/sun/private/include/nspr/prvrsion.h
-/opt/sun/private/include/nspr/prwin16.h
-/opt/sun/private/include/nspr/plarenas.h
-/opt/sun/private/include/nspr/plarena.h
-/opt/sun/private/include/nspr/plhash.h
-/opt/sun/private/include/nspr/plbase64.h
-/opt/sun/private/include/nspr/plerror.h
-/opt/sun/private/include/nspr/plgetopt.h
-/opt/sun/private/include/nspr/plresolv.h
-/opt/sun/private/include/nspr/plstr.h
-
-%changelog
-* Sat Jan 18 2003 Kirk Erickson <kirk.erickson@sun.com>
-- http://bugzilla.mozilla.org/show_bug.cgi?id=189501 
--- a/pr/include/md/_darwin.cfg
+++ b/pr/include/md/_darwin.cfg
@@ -89,16 +89,17 @@
 
 #define PR_ALIGN_OF_SHORT   2
 #define PR_ALIGN_OF_INT     4
 #define PR_ALIGN_OF_LONG    4
 #define PR_ALIGN_OF_INT64   4
 #define PR_ALIGN_OF_FLOAT   4
 #define PR_ALIGN_OF_DOUBLE  4
 #define PR_ALIGN_OF_POINTER 4
+#define PR_ALIGN_OF_WORD    4
 
 #ifndef NO_NSPR_10_SUPPORT
 
 #define BYTES_PER_BYTE		PR_BYTES_PER_BYTE
 #define BYTES_PER_SHORT 	PR_BYTES_PER_SHORT
 #define BYTES_PER_INT 		PR_BYTES_PER_INT
 #define BYTES_PER_INT64		PR_BYTES_PER_INT64
 #define BYTES_PER_LONG		PR_BYTES_PER_LONG
--- a/pr/include/md/_darwin.h
+++ b/pr/include/md/_darwin.h
@@ -37,21 +37,25 @@
 
 #ifndef nspr_darwin_defs_h___
 #define nspr_darwin_defs_h___
 
 #include "prthread.h"
 
 #include <sys/syscall.h>
 
+#ifdef XP_MACOSX
+#include <AvailabilityMacros.h>
+#endif
+
 #define PR_LINKER_ARCH	"darwin"
 #define _PR_SI_SYSNAME  "DARWIN"
-#ifdef i386
+#ifdef __i386__
 #define _PR_SI_ARCHITECTURE "x86"
-#else
+#elif defined(__ppc__)
 #define _PR_SI_ARCHITECTURE "ppc"
 #endif
 #define PR_DLL_SUFFIX		".dylib"
 
 #define _PR_VMBASE              0x30000000
 #define _PR_STACK_VMBASE	0x50000000
 #define _MD_DEFAULT_STACK_SIZE	65536L
 #define _MD_MMAP_FLAGS          MAP_PRIVATE
@@ -72,27 +76,31 @@
  */
 #define _PR_HAVE_GETHOSTBYNAME2
 #define _PR_HAVE_GETADDRINFO
 /*
  * On Mac OS X 10.2, gethostbyaddr fails with h_errno=NO_RECOVERY
  * if you pass an IPv4-mapped IPv6 address to it.
  */
 #define _PR_GHBA_DISALLOW_V4MAPPED
+#ifdef XP_MACOSX
+#if !defined(MAC_OS_X_VERSION_10_3) || \
+    MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3
 /*
  * socket(AF_INET6) fails with EPROTONOSUPPORT on Mac OS X 10.1.
  * IPv6 under OS X 10.2 and below is not complete (see bug 222031).
  */
-#if MACOS_DEPLOYMENT_TARGET < 100300
 #define _PR_INET6_PROBE
-#endif
+#endif /* DT < 10.3 */
+#if defined(MAC_OS_X_VERSION_10_2) && \
+    MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2
 /* Mac OS X 10.2 has inet_ntop and inet_pton. */
-#if MACOS_DEPLOYMENT_TARGET >= 100200
 #define _PR_HAVE_INET_NTOP
-#endif
+#endif /* DT >= 10.2 */
+#endif /* XP_MACOSX */
 #define _PR_IPV6_V6ONLY_PROBE
 /* The IPV6_V6ONLY socket option is not defined on Mac OS X 10.1. */
 #ifndef IPV6_V6ONLY
 #define IPV6_V6ONLY 27
 #endif
 
 #if defined(__ppc__)
 #define _PR_HAVE_ATOMIC_OPS
@@ -100,17 +108,28 @@
 extern PRInt32 _PR_DarwinPPC_AtomicIncrement(PRInt32 *val);
 #define _MD_ATOMIC_INCREMENT(val)   _PR_DarwinPPC_AtomicIncrement(val)
 extern PRInt32 _PR_DarwinPPC_AtomicDecrement(PRInt32 *val);
 #define _MD_ATOMIC_DECREMENT(val)   _PR_DarwinPPC_AtomicDecrement(val)
 extern PRInt32 _PR_DarwinPPC_AtomicSet(PRInt32 *val, PRInt32 newval);
 #define _MD_ATOMIC_SET(val, newval) _PR_DarwinPPC_AtomicSet(val, newval)
 extern PRInt32 _PR_DarwinPPC_AtomicAdd(PRInt32 *ptr, PRInt32 val);
 #define _MD_ATOMIC_ADD(ptr, val)    _PR_DarwinPPC_AtomicAdd(ptr, val)
-#endif /* __ppc__ */
+#elif defined(__i386__)
+#define _PR_HAVE_ATOMIC_OPS
+#define _MD_INIT_ATOMIC()
+extern PRInt32 _PR_Darwin_x86_AtomicIncrement(PRInt32 *val);
+#define _MD_ATOMIC_INCREMENT(val)   _PR_Darwin_x86_AtomicIncrement(val)
+extern PRInt32 _PR_Darwin_x86_AtomicDecrement(PRInt32 *val);
+#define _MD_ATOMIC_DECREMENT(val)   _PR_Darwin_x86_AtomicDecrement(val)
+extern PRInt32 _PR_Darwin_x86_AtomicSet(PRInt32 *val, PRInt32 newval);
+#define _MD_ATOMIC_SET(val, newval) _PR_Darwin_x86_AtomicSet(val, newval)
+extern PRInt32 _PR_Darwin_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val);
+#define _MD_ATOMIC_ADD(ptr, val)    _PR_Darwin_x86_AtomicAdd(ptr, val)
+#endif /* __i386__ */
 
 #define USE_SETJMP
 
 #if !defined(_PR_PTHREADS)
 
 #include <setjmp.h>
 
 #define PR_CONTEXT_TYPE	jmp_buf
--- a/pr/include/md/_linux.cfg
+++ b/pr/include/md/_linux.cfg
@@ -43,17 +43,63 @@
 #endif
 
 #ifndef LINUX
 #define LINUX
 #endif
 
 #define PR_AF_INET6 10  /* same as AF_INET6 */
 
-#ifdef __powerpc__
+#ifdef __powerpc64__
+
+#undef  IS_LITTLE_ENDIAN
+#define IS_BIG_ENDIAN    1
+#define IS_64
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   8
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   8
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    64
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   6
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    8
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 8
+#define PR_ALIGN_OF_WORD    8
+
+#define PR_BYTES_PER_WORD_LOG2   3
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#elif defined(__powerpc__)
 
 #undef  IS_LITTLE_ENDIAN
 #define IS_BIG_ENDIAN    1
 
 #define PR_BYTES_PER_BYTE   1
 #define PR_BYTES_PER_SHORT  2
 #define PR_BYTES_PER_INT    4
 #define PR_BYTES_PER_INT64  8
--- a/pr/include/md/_linux.h
+++ b/pr/include/md/_linux.h
@@ -41,17 +41,19 @@
 #include "prthread.h"
 
 /*
  * Internal configuration macros
  */
 
 #define PR_LINKER_ARCH	"linux"
 #define _PR_SI_SYSNAME  "LINUX"
-#ifdef __powerpc__
+#ifdef __powerpc64__
+#define _PR_SI_ARCHITECTURE "ppc64"
+#elif defined(__powerpc__)
 #define _PR_SI_ARCHITECTURE "ppc"
 #elif defined(__alpha)
 #define _PR_SI_ARCHITECTURE "alpha"
 #elif defined(__ia64__)
 #define _PR_SI_ARCHITECTURE "ia64"
 #elif defined(__x86_64__)
 #define _PR_SI_ARCHITECTURE "x86-64"
 #elif defined(__mc68000__)
--- a/pr/include/md/_pth.h
+++ b/pr/include/md/_pth.h
@@ -141,17 +141,17 @@
 	memset(&(t), 0, sizeof(pthread_t))
 #define _PT_PTHREAD_THR_HANDLE_IS_INVALID(t) \
 	(!memcmp(&(t), &pt_zero_tid, sizeof(pthread_t)))
 #define _PT_PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
 #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \
 	|| defined(HPUX) || defined(LINUX) || defined(FREEBSD) \
 	|| defined(NETBSD) || defined(OPENBSD) || defined(BSDI) \
 	|| defined(VMS) || defined(NTO) || defined(DARWIN) \
-	|| defined(UNIXWARE)
+	|| defined(UNIXWARE) || defined(RISCOS)
 #define _PT_PTHREAD_INVALIDATE_THR_HANDLE(t)  (t) = 0
 #define _PT_PTHREAD_THR_HANDLE_IS_INVALID(t)  (t) == 0
 #define _PT_PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
 #else 
 #error "pthreads is not supported for this architecture"
 #endif
 
 #if defined(_PR_DCETHREADS)
@@ -254,17 +254,18 @@
  * pthread_attr_setschedparam does not allow 0; it allows 1-127.
  */
 #define PT_PRIO_MIN            1
 #define PT_PRIO_MAX            127
 #elif defined(OPENBSD)
 #define PT_PRIO_MIN            0
 #define PT_PRIO_MAX            31
 #elif defined(NETBSD) \
-	|| defined(BSDI) || defined(DARWIN) || defined(UNIXWARE) /* XXX */
+	|| defined(BSDI) || defined(DARWIN) || defined(UNIXWARE) \
+	|| defined(RISCOS) /* XXX */
 #define PT_PRIO_MIN            0
 #define PT_PRIO_MAX            126
 #else
 #error "pthreads is not supported for this architecture"
 #endif
 
 /*
  * The _PT_PTHREAD_YIELD function is called from a signal handler.
@@ -288,15 +289,15 @@ extern int (*_PT_aix_yield_fcn)();
     PR_BEGIN_MACRO               				\
 		struct timespec onemillisec = {0};		\
 		onemillisec.tv_nsec = 1000000L;			\
         nanosleep(&onemillisec,NULL);			\
     PR_END_MACRO
 #elif defined(HPUX) || defined(LINUX) || defined(SOLARIS) \
 	|| defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
 	|| defined(BSDI) || defined(NTO) || defined(DARWIN) \
-	|| defined(UNIXWARE)
+	|| defined(UNIXWARE) || defined(RISCOS)
 #define _PT_PTHREAD_YIELD()            	sched_yield()
 #else
 #error "Need to define _PT_PTHREAD_YIELD for this platform"
 #endif
 
 #endif /* nspr_pth_defs_h_ */
new file mode 100644
--- /dev/null
+++ b/pr/include/md/_riscos.cfg
@@ -0,0 +1,141 @@
+/* -*- 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) 1998-2000
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * 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 ***** */
+
+#ifndef nspr_cpucfg___
+#define nspr_cpucfg___
+
+#ifndef XP_UNIX
+#define XP_UNIX
+#endif
+
+#ifndef RISCOS
+#define RISCOS
+#endif
+
+#define IS_LITTLE_ENDIAN 1
+#undef  IS_BIG_ENDIAN
+#define HAVE_LONG_LONG
+#undef  HAVE_ALIGNED_DOUBLES
+#undef  HAVE_ALIGNED_LONGLONGS
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   4
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   4
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    32
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    32
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   5
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   5
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    4
+#define PR_ALIGN_OF_INT64   4
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  4
+#define PR_ALIGN_OF_POINTER 4
+#define PR_ALIGN_OF_WORD    4
+
+#define PR_BYTES_PER_WORD_LOG2   2
+#define PR_BYTES_PER_DWORD_LOG2  3
+#define PR_WORDS_PER_DWORD_LOG2  1
+
+#ifndef NO_NSPR_10_SUPPORT
+
+#define BYTES_PER_BYTE		PR_BYTES_PER_BYTE
+#define BYTES_PER_SHORT 	PR_BYTES_PER_SHORT
+#define BYTES_PER_INT 		PR_BYTES_PER_INT
+#define BYTES_PER_INT64		PR_BYTES_PER_INT64
+#define BYTES_PER_LONG		PR_BYTES_PER_LONG
+#define BYTES_PER_FLOAT		PR_BYTES_PER_FLOAT
+#define BYTES_PER_DOUBLE	PR_BYTES_PER_DOUBLE
+#define BYTES_PER_WORD		PR_BYTES_PER_WORD
+#define BYTES_PER_DWORD		PR_BYTES_PER_DWORD
+
+#define BITS_PER_BYTE		PR_BITS_PER_BYTE
+#define BITS_PER_SHORT		PR_BITS_PER_SHORT
+#define BITS_PER_INT		PR_BITS_PER_INT
+#define BITS_PER_INT64		PR_BITS_PER_INT64
+#define BITS_PER_LONG		PR_BITS_PER_LONG
+#define BITS_PER_FLOAT		PR_BITS_PER_FLOAT
+#define BITS_PER_DOUBLE		PR_BITS_PER_DOUBLE
+#define BITS_PER_WORD		PR_BITS_PER_WORD
+
+#define BITS_PER_BYTE_LOG2	PR_BITS_PER_BYTE_LOG2
+#define BITS_PER_SHORT_LOG2	PR_BITS_PER_SHORT_LOG2
+#define BITS_PER_INT_LOG2	PR_BITS_PER_INT_LOG2
+#define BITS_PER_INT64_LOG2	PR_BITS_PER_INT64_LOG2
+#define BITS_PER_LONG_LOG2	PR_BITS_PER_LONG_LOG2
+#define BITS_PER_FLOAT_LOG2	PR_BITS_PER_FLOAT_LOG2
+#define BITS_PER_DOUBLE_LOG2 	PR_BITS_PER_DOUBLE_LOG2
+#define BITS_PER_WORD_LOG2	PR_BITS_PER_WORD_LOG2
+
+#define ALIGN_OF_SHORT		PR_ALIGN_OF_SHORT
+#define ALIGN_OF_INT		PR_ALIGN_OF_INT
+#define ALIGN_OF_LONG		PR_ALIGN_OF_LONG
+#define ALIGN_OF_INT64		PR_ALIGN_OF_INT64
+#define ALIGN_OF_FLOAT		PR_ALIGN_OF_FLOAT
+#define ALIGN_OF_DOUBLE		PR_ALIGN_OF_DOUBLE
+#define ALIGN_OF_POINTER	PR_ALIGN_OF_POINTER
+#define ALIGN_OF_WORD		PR_ALIGN_OF_WORD
+
+#define BYTES_PER_WORD_LOG2	PR_BYTES_PER_WORD_LOG2
+#define BYTES_PER_DWORD_LOG2	PR_BYTES_PER_DWORD_LOG2
+#define WORDS_PER_DWORD_LOG2	PR_WORDS_PER_DWORD_LOG2
+
+#endif /* NO_NSPR_10_SUPPORT */
+
+#endif /* nspr_cpucfg___ */
new file mode 100644
--- /dev/null
+++ b/pr/include/md/_riscos.h
@@ -0,0 +1,209 @@
+/* -*- 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) 1998-2000
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Peter Naulls <peter@chocky.org>
+ *
+ * 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 ***** */
+
+#ifndef nspr_riscos_defs_h___
+#define nspr_riscos_defs_h___
+
+/*
+** Internal configuration macros
+*/
+#define PR_LINKER_ARCH		"riscos"
+#define _PR_SI_SYSNAME		"RISCOS"
+#define _PR_SI_ARCHITECTURE	"arm"
+#define PR_DLL_SUFFIX		".a"
+
+#define _PR_POLL_AVAILABLE
+#define _PR_USE_POLL
+#define _PR_HAVE_SOCKADDR_LEN
+#undef HAVE_BSD_FLOCK
+#define _PR_NO_LARGE_FILES
+#define _PR_STAT_HAS_ONLY_ST_ATIME
+#define _PR_HAVE_POSIX_SEMAPHORES
+
+#include <sys/select.h>
+#include <sys/poll.h>
+#include <kernel.h>
+
+
+#undef  HAVE_STACK_GROWING_UP
+#undef  HAVE_DLL
+#undef  USE_DLFCN
+#define NEED_STRFTIME_LOCK
+#define NEED_TIME_R
+#define PT_NO_SIGTIMEDWAIT
+
+#ifndef HAVE_STRERROR
+#define HAVE_STRERROR
+#endif
+
+#define USE_SETJMP
+
+#include <setjmp.h>
+
+#define _SETJMP			setjmp
+#define _LONGJMP		longjmp
+#define _PR_CONTEXT_TYPE	jmp_buf
+#define _PR_NUM_GCREGS		_JBLEN
+#define _MD_GET_SP(_t)		(_t)->md.context[7]
+
+#define CONTEXT(_th)		((_th)->md.context)
+
+
+/*
+** Initialize the thread context preparing it to execute _main.
+*/
+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)	\
+{							\
+    *status = PR_TRUE;					\
+    if(_SETJMP(CONTEXT(_thread))) (*_main)();		\
+    _MD_GET_SP(_thread) = (int) ((_sp) - 128);		\
+}
+
+#define _MD_SWITCH_CONTEXT(_thread)	\
+    if (!_SETJMP(CONTEXT(_thread))) {	\
+	(_thread)->md.errcode = errno;	\
+	_PR_Schedule();			\
+    }
+
+/*
+** Restore a thread context, saved by _MD_SWITCH_CONTEXT
+*/
+#define _MD_RESTORE_CONTEXT(_thread)	\
+{					\
+    errno = (_thread)->md.errcode;	\
+    _MD_SET_CURRENT_THREAD(_thread);	\
+    _LONGJMP(CONTEXT(_thread), 1);	\
+}
+
+/*
+** Machine-dependent (MD) data structures.
+*/
+struct _MDThread {
+    _PR_CONTEXT_TYPE context;
+    int id;
+    int errcode;
+};
+
+struct _MDThreadStack {
+    PRInt8 notused;
+};
+
+struct _MDLock {
+    PRInt8 notused;
+};
+
+struct _MDSemaphore {
+    PRInt8 notused;
+};
+
+struct _MDCVar {
+    PRInt8 notused;
+};
+
+struct _MDSegment {
+    PRInt8 notused;
+};
+
+/*
+** md-specific cpu structure field
+*/
+#define _PR_MD_MAX_OSFD		FD_SETSIZE
+
+struct _MDCPU_Unix {
+    PRCList ioQ;
+    PRUint32 ioq_timeout;
+    PRInt32 ioq_max_osfd;
+    PRInt32 ioq_osfd_cnt;
+#ifndef _PR_USE_POLL
+    fd_set fd_read_set, fd_write_set, fd_exception_set;
+    PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD], fd_exception_cnt[_PR_MD_MAX_OSFD];
+#else
+    struct pollfd *ioq_pollfds;
+    int ioq_pollfds_size;
+#endif
+};
+
+#define _PR_IOQ(_cpu)	/*	*/	((_cpu)->md.md_unix.ioQ)
+#define _PR_ADD_TO_IOQ(_pq, _cpu)	PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
+#define _PR_FD_READ_SET(_cpu)		((_cpu)->md.md_unix.fd_read_set)
+#define _PR_FD_READ_CNT(_cpu)		((_cpu)->md.md_unix.fd_read_cnt)
+#define _PR_FD_WRITE_SET(_cpu)		((_cpu)->md.md_unix.fd_write_set)
+#define _PR_FD_WRITE_CNT(_cpu)		((_cpu)->md.md_unix.fd_write_cnt)
+#define _PR_FD_EXCEPTION_SET(_cpu)	((_cpu)->md.md_unix.fd_exception_set)
+#define _PR_FD_EXCEPTION_CNT(_cpu)	((_cpu)->md.md_unix.fd_exception_cnt)
+#define _PR_IOQ_TIMEOUT(_cpu)		((_cpu)->md.md_unix.ioq_timeout)
+#define _PR_IOQ_MAX_OSFD(_cpu)		((_cpu)->md.md_unix.ioq_max_osfd)
+#define _PR_IOQ_OSFD_CNT(_cpu)		((_cpu)->md.md_unix.ioq_osfd_cnt)
+#define _PR_IOQ_POLLFDS(_cpu)		((_cpu)->md.md_unix.ioq_pollfds)
+#define _PR_IOQ_POLLFDS_SIZE(_cpu)	((_cpu)->md.md_unix.ioq_pollfds_size)
+
+#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)	32
+
+struct _MDCPU {
+	struct _MDCPU_Unix md_unix;
+};
+
+#define _MD_INIT_LOCKS()
+#define _MD_NEW_LOCK(lock)		PR_SUCCESS
+#define _MD_FREE_LOCK(lock)
+#define _MD_LOCK(lock)
+#define _MD_UNLOCK(lock)
+#define _MD_INIT_IO()
+#define _MD_IOQ_LOCK()
+#define _MD_IOQ_UNLOCK()
+
+#define _MD_GET_INTERVAL		_PR_UNIX_GetInterval
+#define _MD_INTERVAL_PER_SEC		_PR_UNIX_TicksPerSecond
+#define _MD_EARLY_INIT			_MD_EarlyInit
+#define _MD_FINAL_INIT			_PR_UnixInit
+#define _MD_INIT_RUNNING_CPU(cpu)	_MD_unix_init_running_cpu(cpu)
+#define _MD_INIT_THREAD			_MD_InitializeThread
+#define _MD_EXIT_THREAD(thread)
+#define	_MD_SUSPEND_THREAD(thread)
+#define	_MD_RESUME_THREAD(thread)
+#define _MD_CLEAN_THREAD(_thread)
+
+/*
+** We wrapped the select() call.  _MD_SELECT refers to the built-in,
+** unwrapped version.
+*/
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/select.h>
+#define _MD_SELECT		select
+
+#endif /* nspr_riscos_defs_h___ */
--- a/pr/include/md/_win95.h
+++ b/pr/include/md/_win95.h
@@ -67,16 +67,32 @@ struct addrinfo {
     int ai_socktype;
     int ai_protocol;
     size_t ai_addrlen;
     char *ai_canonname;
     struct sockaddr *ai_addr;
     struct addrinfo *ai_next;
 };
 #endif
+#define _PR_HAVE_MD_SOCKADDR_IN6
+/* isomorphic to struct in6_addr on Windows */
+struct _md_in6_addr {
+    union {
+        PRUint8  _S6_u8[16];
+        PRUint16 _S6_u16[8];
+    } _S6_un;
+};
+/* isomorphic to struct sockaddr_in6 on Windows */
+struct _md_sockaddr_in6 {
+    PRInt16 sin6_family;
+    PRUint16 sin6_port;
+    PRUint32 sin6_flowinfo;
+    struct _md_in6_addr sin6_addr;
+    PRUint32 sin6_scope_id;
+};
 #endif
 #define _PR_HAVE_THREADSAFE_GETHOST
 #define _PR_HAVE_ATOMIC_OPS
 #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY
 
 /* --- Common User-Thread/Native-Thread Definitions --------------------- */
 
 /* --- Globals --- */
--- a/pr/include/md/_winnt.h
+++ b/pr/include/md/_winnt.h
@@ -82,16 +82,32 @@ struct addrinfo {
     int ai_socktype;
     int ai_protocol;
     size_t ai_addrlen;
     char *ai_canonname;
     struct sockaddr *ai_addr;
     struct addrinfo *ai_next;
 };
 #endif
+#define _PR_HAVE_MD_SOCKADDR_IN6
+/* isomorphic to struct in6_addr on Windows */
+struct _md_in6_addr {
+    union {
+        PRUint8  _S6_u8[16];
+        PRUint16 _S6_u16[8];
+    } _S6_un;
+};
+/* isomorphic to struct sockaddr_in6 on Windows */
+struct _md_sockaddr_in6 {
+    PRInt16 sin6_family;
+    PRUint16 sin6_port;
+    PRUint32 sin6_flowinfo;
+    struct _md_in6_addr sin6_addr;
+    PRUint32 sin6_scope_id;
+};
 #endif
 #define _PR_HAVE_THREADSAFE_GETHOST
 #define _PR_HAVE_ATOMIC_OPS
 #define _PR_HAVE_ATOMIC_CAS
 #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY
 #define _PR_HAVE_PEEK_BUFFER
 #define _PR_PEEK_BUFFER_MAX (32 * 1024)
 #define _PR_FD_NEED_EMULATE_MSG_PEEK(fd) \
--- a/pr/include/md/prosdep.h
+++ b/pr/include/md/prosdep.h
@@ -133,16 +133,19 @@ PR_BEGIN_EXTERN_C
 #include "md/_qnx.h"
 
 #elif defined(VMS)
 #include "md/_openvms.h"
 
 #elif defined(NTO)
 #include "md/_nto.h"
 
+#elif defined(RISCOS)
+#include "md/_riscos.h"
+
 #else
 #error unknown Unix flavor
 
 #endif
 
 #include "md/_unixos.h"
 #include "md/_unix_errors.h"
 
--- a/pr/include/prinit.h
+++ b/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.6"
+#define PR_VERSION  "4.6.1"
 #define PR_VMAJOR   4
 #define PR_VMINOR   6
-#define PR_VPATCH   0
+#define PR_VPATCH   1
 #define PR_BETA     PR_FALSE
 
 /*
 ** 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/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1404,17 +1404,17 @@ extern PRUintn _PR_NetAddrSize(const PRN
         ? sizeof((_addr)->inet)					\
         : ((_addr)->raw.family == PR_AF_INET6	\
         ? sizeof(struct _md_sockaddr_in6)		\
         : sizeof((_addr)->local)))
 #else
 #define PR_NETADDR_SIZE(_addr) 					\
         ((_addr)->raw.family == PR_AF_INET		\
         ? sizeof((_addr)->inet)					\
-        : sizeof(struct _md_sockaddr_in6)
+        : sizeof(struct _md_sockaddr_in6))
 #endif /* defined(XP_UNIX) */
 
 #else
 
 #if defined(XP_UNIX) || defined(XP_OS2_EMX)
 #define PR_NETADDR_SIZE(_addr) 					\
         ((_addr)->raw.family == PR_AF_INET		\
         ? sizeof((_addr)->inet)					\
--- a/pr/include/prlink.h
+++ b/pr/include/prlink.h
@@ -120,39 +120,39 @@ NSPR_API(PRLibrary*) PR_LoadLibrary(cons
 **
 ** Right now PRLibSpec supports three types of library specification:
 ** a pathname, a Mac code fragment by name, and a Mac code fragment
 ** by index.
 */
 
 typedef enum PRLibSpecType {
     PR_LibSpec_Pathname,
-    PR_LibSpec_MacNamedFragment,
-    PR_LibSpec_MacIndexedFragment
+    PR_LibSpec_MacNamedFragment,   /* obsolete (for Mac OS Classic) */
+    PR_LibSpec_MacIndexedFragment  /* obsolete (for Mac OS Classic) */
 } PRLibSpecType;
 
 struct FSSpec; /* Mac OS FSSpec */
 
 typedef struct PRLibSpec {
     PRLibSpecType type;
     union {
         /* if type is PR_LibSpec_Pathname */
         const char *pathname;
 
         /* if type is PR_LibSpec_MacNamedFragment */
         struct {
             const struct FSSpec *fsspec;
             const char *name;
-        } mac_named_fragment;
+        } mac_named_fragment;      /* obsolete (for Mac OS Classic) */
 
         /* if type is PR_LibSpec_MacIndexedFragment */
         struct {
             const struct FSSpec *fsspec;
             PRUint32 index;
-        } mac_indexed_fragment;
+        } mac_indexed_fragment;    /* obsolete (for Mac OS Classic) */
     } value;
 } PRLibSpec;
 
 /*
 ** The following bit flags may be or'd together and passed
 ** as the 'flags' argument to PR_LoadLibraryWithFlags.
 ** Flags not supported by the underlying OS are ignored.
 */
--- a/pr/include/prthread.h
+++ b/pr/include/prthread.h
@@ -39,17 +39,17 @@
 #define prthread_h___
 
 /*
 ** API for NSPR threads. On some architectures (MAC and WIN16
 ** notably) pre-emptibility is not guaranteed. Hard priority scheduling
 ** is not guaranteed, so programming using priority based synchronization
 ** is a no-no.
 **
-** NSPR threads are scheduled based loosly on their client set priority.
+** NSPR threads are scheduled based loosely on their client set priority.
 ** In general, a thread of a higher priority has a statistically better
 ** chance of running relative to threads of lower priority. However,
 ** NSPR uses multiple strategies to provide execution vehicles for thread
 ** abstraction of various host platforms. As it turns out, there is little
 ** NSPR can do to affect the scheduling attributes of "GLOBAL" threads.
 ** However, a semblance of GLOBAL threads is used to implement "LOCAL"
 ** threads. An arbitrary number of such LOCAL threads can be assigned to
 ** a single GLOBAL thread.
--- a/pr/src/Makefile.in
+++ b/pr/src/Makefile.in
@@ -193,19 +193,19 @@ OS_LIBS		= -lsocket -lc
 endif
 
 ifeq ($(OS_ARCH),NEWS-OS)
 OS_LIBS		= -lsocket -lnsl -lgen -lresolv
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 ifdef NS_USE_GCC
-OS_LIBS		= -ladvapi32 -lwsock32
+OS_LIBS		= -ladvapi32 -lwsock32 -lwinmm
 else
-OS_LIBS		= advapi32.lib wsock32.lib
+OS_LIBS		= advapi32.lib wsock32.lib winmm.lib
 endif
 endif
 
 ifeq ($(OS_TARGET),MacOSX)
 OS_LIBS		= -framework CoreServices -framework CoreFoundation
 endif
 
 ifdef GC_LEAK_DETECTOR
--- a/pr/src/io/prprf.c
+++ b/pr/src/io/prprf.c
@@ -389,33 +389,33 @@ static int cvt_s(SprintfState *ss, const
 	}
     }
 
     /* and away we go */
     return fill2(ss, s ? s : "(null)", slen, width, flags);
 }
 
 /*
-** BiuldArgArray stands for Numbered Argument list Sprintf
+** BuildArgArray stands for Numbered Argument list Sprintf
 ** for example,  
 **	fmp = "%4$i, %2$d, %3s, %1d";
 ** the number must start from 1, and no gap among them
 */
 
 static struct NumArg* BuildArgArray( const char *fmt, va_list ap, int* rv, struct NumArg* nasArray )
 {
     int number = 0, cn = 0, i;
     const char* p;
     char  c;
     struct NumArg* nas;
     
 
     /*
     **	first pass:
-    **	detemine how many legal % I have got, then allocate space
+    **	determine how many legal % I have got, then allocate space
     */
 
     p = fmt;
     *rv = 0;
     i = 0;
     while( ( c = *p++ ) != 0 ){
 	if( c != '%' )
 	    continue;
--- a/pr/src/io/prscanf.c
+++ b/pr/src/io/prscanf.c
@@ -634,17 +634,17 @@ static int
 StringGetChar(void *stream)
 {
     char *cPtr = *((char **) stream);
 
     if (*cPtr == '\0') {
         return EOF;
     } else {
         *((char **) stream) = cPtr + 1;
-        return *cPtr;
+        return (unsigned char) *cPtr;
     }
 }
 
 static void
 StringUngetChar(void *stream, int ch)
 {
     char *cPtr = *((char **) stream);
 
--- a/pr/src/linking/Makefile.in
+++ b/pr/src/linking/Makefile.in
@@ -64,17 +64,17 @@ INCLUDES = -I$(dist_includedir) -I$(tops
 
 # For Dl_info and dladdr.
 ifeq ($(OS_TARGET),Linux)
 DEFINES    += -D_GNU_SOURCE
 endif
 
 # On Mac OS X use flat #includes.
 ifeq ($(OS_TARGET),MacOSX)
-INCLUDES    += -I$(NEXT_ROOT)/Developer/Headers/FlatCarbon
+INCLUDES    += -I$(MACOS_SDK_DIR)/Developer/Headers/FlatCarbon
 endif
 
 DEFINES += -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -35,38 +35,28 @@
 #include "primpl.h"
 
 #include <string.h>
 
 #ifdef XP_BEOS
 #include <image.h>
 #endif
 
-#if defined(XP_MAC) || defined(XP_MACOSX)
+#ifdef XP_MACOSX
 #include <CodeFragments.h>
 #include <TextUtils.h>
 #include <Types.h>
 #include <Aliases.h>
-
-#if TARGET_CARBON
 #include <CFURL.h>
 #include <CFBundle.h>
 #include <CFString.h>
 #include <CFDictionary.h>
 #include <CFData.h>
 #endif
 
-#if defined(XP_MACOSX)
-#define PStrFromCStr(src, dst) c2pstrcpy(dst, src)
-#else
-#include "macdll.h"
-#include "mdmac.h"
-#endif /* XP_MACOSX */
-#endif
-
 #ifdef XP_UNIX
 #ifdef USE_DLFCN
 #include <dlfcn.h>
 /* Define these on systems that don't have them. */
 #ifndef RTLD_NOW
 #define RTLD_NOW 0
 #endif
 #ifndef RTLD_LAZY
@@ -178,29 +168,22 @@ struct PRLibrary {
 #ifdef XP_PC
 #ifdef XP_OS2
     HMODULE                     dlh;
 #else
     HINSTANCE                   dlh;
 #endif
 #endif
 
-#if defined(XP_MAC) || defined(XP_MACOSX)
+#ifdef XP_MACOSX
     CFragConnectionID           connection;
-
-#if TARGET_CARBON
     CFBundleRef                 bundle;
-#endif
-
     Ptr                         main;
-
-#if defined(XP_MACOSX)
     CFMutableDictionaryRef      wrappers;
     const struct mach_header*   image;
-#endif /* XP_MACOSX */
 #endif
 
 #ifdef XP_UNIX
 #if defined(USE_HPSHL)
     shl_t                       dlh;
 #elif defined(USE_MACH_DYLD)
     NSModule                    dlh;
 #else
@@ -215,22 +198,16 @@ struct PRLibrary {
 };
 
 static PRLibrary *pr_loadmap;
 static PRLibrary *pr_exe_loadmap;
 static PRMonitor *pr_linker_lock;
 static char* _pr_currentLibPath = NULL;
 
 static PRLibrary *pr_LoadLibraryByPathname(const char *name, PRIntn flags);
-#ifdef XP_MAC
-static PRLibrary *pr_Mac_LoadNamedFragment(const FSSpec *fileSpec,
-    const char* fragmentName);
-static PRLibrary *pr_Mac_LoadIndexedFragment(const FSSpec *fileSpec,
-    PRUint32 fragIndex);
-#endif /* XP_MAC */
 
 /************************************************************************/
 
 #if !defined(USE_DLFCN) && !defined(HAVE_STRERROR)
 static char* errStrBuf = NULL;
 #define ERR_STR_BUF_LENGTH    20
 static char* errno_string(PRIntn oserr)
 {
@@ -257,19 +234,17 @@ static void DLLErrorInternal(PRIntn oser
     error = errno_string(oserr);
 #endif
     if (NULL != error)
         PR_SetErrorText(strlen(error), error);
 }  /* DLLErrorInternal */
 
 void _PR_InitLinker(void)
 {
-#if !defined(XP_MAC) && !defined(XP_BEOS)
-    PRLibrary *lm;
-#endif
+    PRLibrary *lm = NULL;
 #if defined(XP_UNIX)
     void *h;
 #endif
 
     if (!pr_linker_lock) {
         pr_linker_lock = PR_NewNamedMonitor("linker-lock");
     }
     PR_EnterMonitor(pr_linker_lock);
@@ -326,19 +301,20 @@ void _PR_InitLinker(void)
         lm->dlh = h;
         lm->staticTable = NULL;
     }
     pr_exe_loadmap = lm;
     pr_loadmap = lm;
 #endif /* HAVE_DLL */
 #endif /* XP_UNIX */
 
-#if !defined(XP_MAC) && !defined(XP_BEOS)
-    PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Loaded library %s (init)", lm?lm->name:"NULL"));
-#endif
+    if (lm) {
+        PR_LOG(_pr_linker_lm, PR_LOG_MIN,
+            ("Loaded library %s (init)", lm->name));
+    }
 
     PR_ExitMonitor(pr_linker_lock);
 }
 
 #if defined(WIN16)
 /*
  * _PR_ShutdownLinker unloads all dlls loaded by the application via
  * calls to PR_LoadLibrary
@@ -435,35 +411,16 @@ PR_GetLibraryPath(void)
 #ifdef XP_PC
     ev = getenv("LD_LIBRARY_PATH");
     if (!ev) {
     ev = ".;\\lib";
     }
     ev = strdup(ev);
 #endif
 
-#ifdef XP_MAC
-    {
-    char *p;
-    int len;
-
-    ev = getenv("LD_LIBRARY_PATH");
-    
-    if (!ev)
-        ev = "";
-    
-    len = strlen(ev) + 1;        /* +1 for the null */
-    p = (char*) malloc(len);
-    if (p) {
-        strcpy(p, ev);
-    }
-    ev = p;
-    }
-#endif
-
 #if defined(XP_UNIX) || defined(XP_BEOS)
 #if defined(USE_DLFCN) || defined(USE_MACH_DYLD) || defined(XP_BEOS)
     {
     char *p=NULL;
     int len;
 
 #ifdef XP_BEOS
     ev = getenv("LIBRARY_PATH");
@@ -527,23 +484,16 @@ PR_GetLibraryName(const char *path, cons
     } else {
         if (path) {
             fullname = PR_smprintf("%s\\%s", path, lib);
         } else {
             fullname = PR_smprintf("%s", lib);
         }
     }
 #endif /* XP_PC */
-#ifdef XP_MAC
-    if (path) {
-        fullname = PR_smprintf("%s%s", path, lib);
-    } else {
-        fullname = PR_smprintf("%s", lib);
-    }
-#endif
 #if defined(XP_UNIX) || defined(XP_BEOS)
     if (strstr(lib, PR_DLL_SUFFIX) == NULL)
     {
         if (path) {
             fullname = PR_smprintf("%s/lib%s%s", path, lib, PR_DLL_SUFFIX);
         } else {
             fullname = PR_smprintf("lib%s%s", lib, PR_DLL_SUFFIX);
         }
@@ -601,26 +551,16 @@ PR_IMPLEMENT(PRLibrary*)
 PR_LoadLibraryWithFlags(PRLibSpec libSpec, PRIntn flags)
 {
     if (flags == 0) {
         flags = _PR_DEFAULT_LD_FLAGS;
     }
     switch (libSpec.type) {
         case PR_LibSpec_Pathname:
             return pr_LoadLibraryByPathname(libSpec.value.pathname, flags);
-#ifdef XP_MAC
-        case PR_LibSpec_MacNamedFragment:
-            return pr_Mac_LoadNamedFragment(
-                libSpec.value.mac_named_fragment.fsspec,
-                libSpec.value.mac_named_fragment.name);
-        case PR_LibSpec_MacIndexedFragment:
-            return pr_Mac_LoadIndexedFragment(
-                libSpec.value.mac_indexed_fragment.fsspec,
-                libSpec.value.mac_indexed_fragment.index);
-#endif /* XP_MAC */
         default:
             PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
             return NULL;
     }
 }
             
 PR_IMPLEMENT(PRLibrary*) 
 PR_LoadLibrary(const char *name)
@@ -652,19 +592,18 @@ pr_LoadMachDyldModule(const char *name)
                 h = NULL;
             }
         }
     }
     return h;
 }
 #endif
 
-#if defined(XP_MAC) || defined(XP_MACOSX)
+#ifdef XP_MACOSX
 
-#ifdef XP_MACOSX
 static void* TV2FP(CFMutableDictionaryRef dict, const char* name, void *tvp)
 {
     static uint32 glue[6] = { 0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420 };
     uint32* newGlue = NULL;
 
     if (tvp != NULL) {
         CFStringRef nameRef = CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII);
         if (nameRef) {
@@ -688,161 +627,87 @@ static void* TV2FP(CFMutableDictionaryRe
                 newGlue = (uint32*) CFDataGetMutableBytePtr(glueData);
             }
             CFRelease(nameRef);
         }
     }
     
     return newGlue;
 }
-#endif
 
 /*
 ** macLibraryLoadProc is a function definition for a Mac shared library
 ** loading method. The "name" param is the same full or partial pathname
 ** that was passed to pr_LoadLibraryByPathName. The function must fill
 ** in the fields of "lm" which apply to its library type. Returns
 ** PR_SUCCESS if successful.
 */
 
 typedef PRStatus (*macLibraryLoadProc)(const char *name, PRLibrary *lm);
 
 static PRStatus
 pr_LoadViaCFM(const char *name, PRLibrary *lm)
 {
     OSErr err;
-    char cName[64];
     Str255 errName;
-    
-#if !defined(XP_MACOSX)
-    Str255 pName;
+    FSRef ref;
+    FSSpec fileSpec;
+    Boolean tempUnusedBool;
+
     /*
-     * Algorithm: The "name" passed in could be either a shared
-     * library name that we should look for in the normal library
-     * search paths, or a full path name to a specific library on
-     * disk.  Since the full path will always contain a ":"
-     * (shortest possible path is "Volume:File"), and since a
-     * library name can not contain a ":", we can test for the
-     * presence of a ":" to see which type of library we should load.
-     * or its a full UNIX path which we for now assume is Java
-     * enumerating all the paths (see below)
+     * Make an FSSpec from the path name and call GetDiskFragment.
      */
-    if (strchr(name, PR_PATH_SEPARATOR) == NULL) {
-        if (strchr(name, PR_DIRECTORY_SEPARATOR) == NULL) {
-            /*
-             * The name did not contain a ":", so it must be a
-             * library name.  Convert the name to a Pascal string
-             * and try to find the library.
-             */
-        } else {
-            /*
-             * name contained a "/" which means we need to suck off
-             * the last part of the path and pass that on the
-             * NSGetSharedLibrary. this may not be what we really
-             * want to do .. because Java could be iterating through
-             * the whole LD path, and we'll find it if it's anywhere
-             * on that path -- it appears that's what UNIX and the
-             * PC do too...so we'll emulate but it could be wrong.
-             */
-            name = strrchr(name, PR_DIRECTORY_SEPARATOR) + 1;
-        }
+
+    /* Use direct conversion of POSIX path to FSRef to FSSpec. */
+    err = FSPathMakeRef((const UInt8*)name, &ref, NULL);
+    if (err != noErr)
+        return PR_FAILURE;
+    err = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL,
+                           &fileSpec, NULL);
+    if (err != noErr)
+        return PR_FAILURE;
 
-        PStrFromCStr(name, pName);
+    /* Resolve an alias if this was one */
+    err = ResolveAliasFile(&fileSpec, true, &tempUnusedBool,
+                           &tempUnusedBool);
+    if (err != noErr)
+        return PR_FAILURE;
 
-        /*
-         * beard: NSGetSharedLibrary was so broken that I just decided to
-         * use GetSharedLibrary for now.  This will need to change for
-         * plugins, but those should go in the Extensions folder anyhow.
-         */
-        err = GetSharedLibrary(pName, kCompiledCFragArch, kReferenceCFrag,
-                               &lm->connection, &lm->main, errName);
-        if (err != noErr)
-            return PR_FAILURE;
-    }
-    else
-#endif
-    {
+    /* Finally, try to load the library */
+    err = GetDiskFragment(&fileSpec, 0, kCFragGoesToEOF, fileSpec.name,
+                          kLoadCFrag, &lm->connection, &lm->main, errName);
+
+    if (err == noErr && lm->connection) {
         /*
-         * The name did contain a ":", so it must be a full path name.
-         * Now we have to do a lot of work to convert the path name to
-         * an FSSpec (silly, since we were probably just called from the
-         * MacFE plug-in code that already knew the FSSpec and converted
-         * it to a full path just to pass to us).  Make an FSSpec from
-         * the full path and call GetDiskFragment.
+         * if we're a mach-o binary, need to wrap all CFM function
+         * pointers. need a hash-table of already seen function
+         * pointers, etc.
          */
-        FSSpec fileSpec;
-        Boolean tempUnusedBool;
-
-#if defined(XP_MACOSX)
-        {
-            /* Use direct conversion of POSIX path to FSRef to FSSpec. */
-            FSRef ref;
-            err = FSPathMakeRef((const UInt8*)name, &ref, NULL);
-            if (err == noErr)
-                err = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL,
-                                       &fileSpec, NULL);
-        }
-#else
-        PStrFromCStr(name, pName);
-        err = FSMakeFSSpec(0, 0, pName, &fileSpec);
-#endif
-        if (err != noErr)
-            return PR_FAILURE;
-
-        /* Resolve an alias if this was one */
-        err = ResolveAliasFile(&fileSpec, true, &tempUnusedBool,
-                               &tempUnusedBool);
-        if (err != noErr)
-            return PR_FAILURE;
-
-        /* Finally, try to load the library */
-        err = GetDiskFragment(&fileSpec, 0, kCFragGoesToEOF, fileSpec.name,
-                              kLoadCFrag, &lm->connection, &lm->main, errName);
-
-#if TARGET_CARBON
-        p2cstrcpy(cName, fileSpec.name);
-#else
-        memcpy(cName, fileSpec.name + 1, fileSpec.name[0]);
-        cName[fileSpec.name[0]] = '\0';
-#endif
-
-#ifdef XP_MACOSX
-        if (err == noErr && lm->connection) {
-            /*
-             * if we're a mach-o binary, need to wrap all CFM function
-             * pointers. need a hash-table of already seen function
-             * pointers, etc.
-             */
-            lm->wrappers = CFDictionaryCreateMutable(NULL, 16,
-                           &kCFTypeDictionaryKeyCallBacks,
-                           &kCFTypeDictionaryValueCallBacks);
-            if (lm->wrappers) {
-                lm->main = TV2FP(lm->wrappers, "main", lm->main);
-            } else
-                err = memFullErr;
-        }
-#endif
+        lm->wrappers = CFDictionaryCreateMutable(NULL, 16,
+                       &kCFTypeDictionaryKeyCallBacks,
+                       &kCFTypeDictionaryValueCallBacks);
+        if (lm->wrappers) {
+            lm->main = TV2FP(lm->wrappers, "main", lm->main);
+        } else
+            err = memFullErr;
     }
     return (err == noErr) ? PR_SUCCESS : PR_FAILURE;
 }
 
 /*
 ** Creates a CFBundleRef if the pathname refers to a Mac OS X bundle
 ** directory. The caller is responsible for calling CFRelease() to
 ** deallocate.
 */
 
-#if TARGET_CARBON
 static PRStatus
 pr_LoadCFBundle(const char *name, PRLibrary *lm)
 {
     CFURLRef bundleURL;
     CFBundleRef bundle = NULL;
-    
-#ifdef XP_MACOSX
     char pathBuf[PATH_MAX];
     const char *resolvedPath;
     CFStringRef pathRef;
 
     /* Takes care of relative paths and symlinks */
     resolvedPath = realpath(name, pathBuf);
     if (!resolvedPath)
         return PR_FAILURE;
@@ -852,61 +717,37 @@ pr_LoadCFBundle(const char *name, PRLibr
         bundleURL = CFURLCreateWithFileSystemPath(NULL, pathRef,
                                                   kCFURLPOSIXPathStyle, true);
         if (bundleURL) {
             bundle = CFBundleCreate(NULL, bundleURL);
             CFRelease(bundleURL);
         }
         CFRelease(pathRef);
     }
-#else
-    OSErr err;
-    Str255 pName;
-    FSSpec fsSpec;
-    FSRef fsRef;
-
-    if ((UInt32)(CFURLCreateFromFSRef) == kUnresolvedCFragSymbolAddress)
-        return PR_FAILURE;
-    PStrFromCStr(name, pName);
-    err = FSMakeFSSpec(0, 0, pName, &fsSpec);
-    if (err != noErr)
-        return PR_FAILURE;
-    err = FSpMakeFSRef(&fsSpec, &fsRef);
-    if (err != noErr)
-        return PR_FAILURE;
-    bundleURL = CFURLCreateFromFSRef(NULL, &fsRef);
-    if (bundleURL) {
-        bundle = CFBundleCreate(NULL, bundleURL);
-        CFRelease(bundleURL);
-    }
-#endif
 
     lm->bundle = bundle;
     return (bundle != NULL) ? PR_SUCCESS : PR_FAILURE;
 }
-#endif
 
-#ifdef XP_MACOSX
 static PRStatus
 pr_LoadViaDyld(const char *name, PRLibrary *lm)
 {
     lm->dlh = pr_LoadMachDyldModule(name);
     if (lm->dlh == NULL) {
         lm->image = NSAddImage(name, NSADDIMAGE_OPTION_RETURN_ON_ERROR
                                | NSADDIMAGE_OPTION_WITH_SEARCHING);
         /*
          * TODO: If NSAddImage fails, use NSLinkEditError to retrieve
          * error information.
          */
     }
     return (lm->dlh != NULL || lm->image != NULL) ? PR_SUCCESS : PR_FAILURE;
 }
-#endif
 
-#endif /* defined(XP_MAC) || defined(XP_MACOSX) */
+#endif /* XP_MACOSX */
 
 /*
 ** Dynamically load a library. Only load libraries once, so scan the load
 ** map first.
 */
 static PRLibrary*
 pr_LoadLibraryByPathname(const char *name, PRIntn flags)
 {
@@ -960,29 +801,23 @@ pr_LoadLibraryByPathname(const char *nam
     }
     lm->name = strdup(name);
     lm->dlh = h;
     lm->next = pr_loadmap;
     pr_loadmap = lm;
     }
 #endif /* WIN32 || WIN16 */
 
-#if defined(XP_MAC) || defined(XP_MACOSX)
+#ifdef XP_MACOSX
     {
     int     i;
     PRStatus status;
 
     static const macLibraryLoadProc loadProcs[] = {
-#if defined(XP_MACOSX)
         pr_LoadViaDyld, pr_LoadCFBundle, pr_LoadViaCFM
-#elif TARGET_CARBON
-        pr_LoadViaCFM, pr_LoadCFBundle
-#else
-        pr_LoadViaCFM
-#endif
     };
 
     for (i = 0; i < sizeof(loadProcs) / sizeof(loadProcs[0]); i++) {
         if ((status = loadProcs[i](name, lm)) == PR_SUCCESS)
             break;
     }
     if (status != PR_SUCCESS) {
         oserr = cfragNoLibraryErr;
@@ -1160,146 +995,16 @@ pr_LoadLibraryByPathname(const char *nam
     if (result == NULL) {
         PR_SetError(PR_LOAD_LIBRARY_ERROR, oserr);
         DLLErrorInternal(oserr);  /* sets error text */
     }
     PR_ExitMonitor(pr_linker_lock);
     return result;
 }
 
-
-#ifdef XP_MAC
-
-static PRLibrary*
-pr_Mac_LoadNamedFragment(const FSSpec *fileSpec, const char* fragmentName)
-{
-	PRLibrary*					newLib = NULL;
-	PRLibrary* 					result;
-	FSSpec							resolvedSpec = *fileSpec;
-	CFragConnectionID		connectionID = 0;
-	Boolean							isFolder, wasAlias;
-	OSErr								err = noErr;
-	
-	if (!_pr_initialized) _PR_ImplicitInitialization();
-
-	/* See if library is already loaded */
-	PR_EnterMonitor(pr_linker_lock);
-  
-	result = pr_UnlockedFindLibrary(fragmentName);
-	if (result != NULL) goto unlock;
-
-	newLib = PR_NEWZAP(PRLibrary);
-	if (newLib == NULL) goto unlock;
-	newLib->staticTable = NULL;
-
-
-	/* Resolve an alias if this was one */
-	err = ResolveAliasFile(&resolvedSpec, true, &isFolder, &wasAlias);
-	if (err != noErr)
-		goto unlock;
-
-  if (isFolder)
-  {
-  	err = fnfErr;
-  	goto unlock;
-  }
-    
-	/* Finally, try to load the library */
-	err = NSLoadNamedFragment(&resolvedSpec, fragmentName, &connectionID);
-	if (err != noErr)
-		goto unlock;
-
-  newLib->name = strdup(fragmentName);
-  newLib->connection = connectionID;
-  newLib->next = pr_loadmap;
-  pr_loadmap = newLib;
-
-  result = newLib;    /* success */
-  PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Loaded library %s (load lib)", newLib->name));
-
-unlock:
-	if (result == NULL) {
-		if (newLib != NULL)
-			PR_DELETE(newLib);
-		PR_SetError(PR_LOAD_LIBRARY_ERROR, _MD_ERRNO());
-		DLLErrorInternal(_MD_ERRNO());  /* sets error text */
-	}
-	PR_ExitMonitor(pr_linker_lock);
-	return result;
-}
-
-
-static PRLibrary*
-pr_Mac_LoadIndexedFragment(const FSSpec *fileSpec, PRUint32 fragIndex)
-{
-	PRLibrary*					newLib = NULL;
-	PRLibrary* 					result;
-	FSSpec							resolvedSpec = *fileSpec;
-	char*								fragmentName = NULL;
-	UInt32              fragOffset, fragLength;                
-	CFragConnectionID		connectionID = 0;
-	Boolean							isFolder, wasAlias;
-	OSErr								err = noErr;
-
-	if (!_pr_initialized) _PR_ImplicitInitialization();
-
-	/* See if library is already loaded */
-	PR_EnterMonitor(pr_linker_lock);
-
-	/* Resolve an alias if this was one */
-	err = ResolveAliasFile(&resolvedSpec, true, &isFolder, &wasAlias);
-	if (err != noErr)
-		goto unlock;
-
-  if (isFolder)
-  {
-  	err = fnfErr;
-  	goto unlock;
-  }
-    err = GetIndexedFragmentOffsets(&resolvedSpec, fragIndex, &fragOffset, &fragLength, &fragmentName);
-  if (err != noErr) goto unlock;
-  
-	result = pr_UnlockedFindLibrary(fragmentName);
-	free(fragmentName);
-	fragmentName = NULL;
-	if (result != NULL) goto unlock;
-
-	newLib = PR_NEWZAP(PRLibrary);
-	if (newLib == NULL) goto unlock;
-	newLib->staticTable = NULL;
-    
-	/* Finally, try to load the library */
-	err = NSLoadIndexedFragment(&resolvedSpec, fragIndex, &fragmentName, &connectionID);
-	if (err != noErr) {
-		PR_DELETE(newLib);
-		goto unlock;
-	}
-
-  newLib->name = fragmentName;			/* was malloced in NSLoadIndexedFragment */
-  newLib->connection = connectionID;
-  newLib->next = pr_loadmap;
-  pr_loadmap = newLib;
-
-  result = newLib;    /* success */
-  PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Loaded library %s (load lib)", newLib->name));
-
-unlock:
-	if (result == NULL) {
-		if (newLib != NULL)
-			PR_DELETE(newLib);
-		PR_SetError(PR_LOAD_LIBRARY_ERROR, _MD_ERRNO());
-		DLLErrorInternal(_MD_ERRNO());  /* sets error text */
-	}
-	PR_ExitMonitor(pr_linker_lock);
-	return result;
-}
-
-
-#endif
-
 /*
 ** Unload a shared library which was loaded via PR_LoadLibrary
 */
 PR_IMPLEMENT(PRStatus) 
 PR_UnloadLibrary(PRLibrary *lib)
 {
     int result = 0;
     PRStatus status = PR_SUCCESS;
@@ -1339,30 +1044,26 @@ PR_UnloadLibrary(PRLibrary *lib)
 #endif /* XP_UNIX */
 #ifdef XP_PC
     if (lib->dlh) {
         FreeLibrary((HINSTANCE)(lib->dlh));
         lib->dlh = (HINSTANCE)NULL;
     }
 #endif  /* XP_PC */
 
-#if defined(XP_MAC) || defined(XP_MACOSX)
+#ifdef XP_MACOSX
     /* Close the connection */
     if (lib->connection)
         CloseConnection(&(lib->connection));
-#if TARGET_CARBON
     if (lib->bundle)
         CFRelease(lib->bundle);
-#endif
-#if defined(XP_MACOSX)
     if (lib->wrappers)
         CFRelease(lib->wrappers);
     /* No way to unload an image (lib->image) */
 #endif
-#endif
 
     /* unlink from library search list */
     if (pr_loadmap == lib)
         pr_loadmap = pr_loadmap->next;
     else if (pr_loadmap != NULL) {
         PRLibrary* prev = pr_loadmap;
         PRLibrary* next = pr_loadmap->next;
         while (next != NULL) {
@@ -1442,69 +1143,56 @@ pr_FindSymbolInLib(PRLibrary *lm, const 
     }
 #endif
 #endif  /* XP_OS2 */
 
 #if defined(WIN32) || defined(WIN16)
     f = GetProcAddress(lm->dlh, name);
 #endif  /* WIN32 || WIN16 */
 
-#if defined(XP_MAC) || defined(XP_MACOSX)
-#if defined(NEED_LEADING_UNDERSCORE)
+#ifdef XP_MACOSX
+/* add this offset to skip the leading underscore in name */
 #define SYM_OFFSET 1
-#else
-#define SYM_OFFSET 0
-#endif
-#if TARGET_CARBON
     if (lm->bundle) {
         CFStringRef nameRef = CFStringCreateWithCString(NULL, name + SYM_OFFSET, kCFStringEncodingASCII);
         if (nameRef) {
             f = CFBundleGetFunctionPointerForName(lm->bundle, nameRef);
             CFRelease(nameRef);
         }
     }
-#endif
     if (lm->connection) {
         Ptr                 symAddr;
         CFragSymbolClass    symClass;
         Str255              pName;
         
         PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Looking up symbol: %s", name + SYM_OFFSET));
         
-        PStrFromCStr(name + SYM_OFFSET, pName);
+        c2pstrcpy(pName, name + SYM_OFFSET);
         
-#if defined(XP_MACOSX)
         f = (FindSymbol(lm->connection, pName, &symAddr, &symClass) == noErr) ? symAddr : NULL;
-#else
-        f = (NSFindSymbol(lm->connection, pName, &symAddr, &symClass) == noErr) ? symAddr : NULL;
-#endif
         
-#if defined(XP_MACOSX)
         /* callers expect mach-o function pointers, so must wrap tvectors with glue. */
         if (f && symClass == kTVectorCFragSymbol) {
             f = TV2FP(lm->wrappers, name + SYM_OFFSET, f);
         }
-#endif
         
         if (f == NULL && strcmp(name + SYM_OFFSET, "main") == 0) f = lm->main;
     }
-#if defined(XP_MACOSX)
     if (lm->image) {
         NSSymbol symbol;
         symbol = NSLookupSymbolInImage(lm->image, name,
                  NSLOOKUPSYMBOLINIMAGE_OPTION_BIND
                  | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
         if (symbol != NULL)
             f = NSAddressOfSymbol(symbol);
         else
             f = NULL;
     }
-#endif
 #undef SYM_OFFSET
-#endif /* XP_MAC */
+#endif /* XP_MACOSX */
 
 #ifdef XP_BEOS
     if( B_NO_ERROR != get_image_symbol( (image_id)lm->dlh, name, B_SYMBOL_TYPE_TEXT, &f ) ) {
         f = NULL;
     }
 #endif
 
 #ifdef XP_UNIX
@@ -1665,21 +1353,17 @@ PR_LoadStaticLibrary(const char *name, c
     }
 
     /* Add library to list...Mark it static */
     lm = PR_NEWZAP(PRLibrary);
     if (lm == NULL) goto unlock;
 
     lm->name = strdup(name);
     lm->refCount    = 1;
-#if defined(XP_MAC)
-    lm->connection  = pr_exe_loadmap ? pr_exe_loadmap->connection : 0;
-#else
     lm->dlh         = pr_exe_loadmap ? pr_exe_loadmap->dlh : 0;
-#endif
     lm->staticTable = slt;
     lm->next        = pr_loadmap;
     pr_loadmap      = lm;
 
     result = lm;    /* success */
     PR_ASSERT(lm->refCount == 1);
   unlock:
     PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Loaded library %s (static lib)", lm->name));
--- a/pr/src/malloc/prmem.c
+++ b/pr/src/malloc/prmem.c
@@ -110,16 +110,18 @@ void
 
 /*
 ** pr_FindSymbolInProg
 **
 ** Find the specified data symbol in the program and return
 ** its address.
 */
 
+#ifdef HAVE_DLL
+
 #ifdef USE_DLFCN
 
 #include <dlfcn.h>
 
 static void *
 pr_FindSymbolInProg(const char *name)
 {
     void *h;
@@ -158,16 +160,27 @@ pr_FindSymbolInProg(const char *name)
 }
 
 #else
 
 #error "The zone allocator is not supported on this platform"
 
 #endif
 
+#else /* !defined(HAVE_DLL) */
+
+static void *
+pr_FindSymbolInProg(const char *name)
+{
+    /* can't be implemented */
+    return NULL;
+}
+
+#endif /* HAVE_DLL */
+
 void
 _PR_InitZones(void)
 {
     int i, j;
     char *envp;
     PRBool *sym;
 
     if ((sym = (PRBool *)pr_FindSymbolInProg("nspr_use_zone_allocator")) != NULL) {
new file mode 100644
--- /dev/null
+++ b/pr/src/md/unix/os_Darwin_x86.s
@@ -0,0 +1,105 @@
+# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+#
+# 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 Netscape are
+# Copyright (C) 2003 Netscape Communications Corporation.  All
+# Rights Reserved.
+#
+# Contributor(s):
+#   Josh Aas <josh@mozilla.com>
+#
+# Alternatively, the contents of this file may be used under the
+# terms of the GNU General Public License Version 2 or later (the
+# "GPL"), in which case the provisions of the GPL are applicable
+# instead of those above.  If you wish to allow use of your
+# version of this file only under the terms of the GPL and not to
+# allow others to use your version of this file under the MPL,
+# indicate your decision by deleting the provisions above and
+# replace them with the notice and other provisions required by
+# the GPL.  If you do not delete the provisions above, a recipient
+# may use your version of this file under either the MPL or the
+# GPL.
+#
+
+#
+# Based on os_Linux_x86.s
+#
+
+#
+# PRInt32 __PR_Darwin_x86_AtomicIncrement(PRInt32 *val);
+#
+# Atomically increment the integer pointed to by 'val' and return
+# the result of the increment.
+#
+    .text
+    .globl __PR_Darwin_x86_AtomicIncrement
+    .align 4
+__PR_Darwin_x86_AtomicIncrement:
+    movl 4(%esp), %ecx
+    movl $1, %eax
+    lock
+    xaddl %eax, (%ecx)
+    incl %eax
+    ret
+
+#
+# PRInt32 __PR_Darwin_x86_AtomicDecrement(PRInt32 *val);
+#
+# Atomically decrement the integer pointed to by 'val' and return
+# the result of the decrement.
+#
+    .text
+    .globl __PR_Darwin_x86_AtomicDecrement
+    .align 4
+__PR_Darwin_x86_AtomicDecrement:
+    movl 4(%esp), %ecx
+    movl $-1, %eax
+    lock
+    xaddl %eax, (%ecx)
+    decl %eax
+    ret
+
+#
+# PRInt32 __PR_Darwin_x86_AtomicSet(PRInt32 *val, PRInt32 newval);
+#
+# Atomically set the integer pointed to by 'val' to the new
+# value 'newval' and return the old value.
+#
+    .text
+    .globl __PR_Darwin_x86_AtomicSet
+    .align 4
+__PR_Darwin_x86_AtomicSet:
+    movl 4(%esp), %ecx
+    movl 8(%esp), %eax
+    xchgl %eax, (%ecx)
+    ret
+
+#
+# PRInt32 __PR_Darwin_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val);
+#
+# Atomically add 'val' to the integer pointed to by 'ptr'
+# and return the result of the addition.
+#
+    .text
+    .globl __PR_Darwin_x86_AtomicAdd
+    .align 4
+__PR_Darwin_x86_AtomicAdd:
+    movl 4(%esp), %ecx
+    movl 8(%esp), %eax
+    movl %eax, %edx
+    lock
+    xaddl %eax, (%ecx)
+    addl %edx, %eax
+    ret
new file mode 100644
--- /dev/null
+++ b/pr/src/md/unix/riscos.c
@@ -0,0 +1,120 @@
+/* -*- 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) 1998-2000
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Peter Naulls <peter@chocky.org>
+ *
+ * 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 ***** */
+
+#include "primpl.h"
+
+void _MD_EarlyInit(void)
+{
+}
+
+PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
+{
+#ifndef _PR_PTHREADS
+    if (isCurrent) {
+	(void) setjmp(CONTEXT(t));
+    }
+    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
+    return (PRWord *) CONTEXT(t);
+#else
+	*np = 0;
+	return NULL;
+#endif
+}
+
+#ifdef _PR_PTHREADS
+
+void _MD_CleanupBeforeExit(void)
+{
+}
+
+#else /* ! _PR_PTHREADS */
+
+void
+_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
+{
+    return;
+}
+
+PRStatus
+_MD_InitializeThread(PRThread *thread)
+{
+	/*
+	 * set the pointers to the stack-pointer and frame-pointer words in the
+	 * context structure; this is for debugging use.
+	 */
+	thread->md.sp = _MD_GET_SP_PTR(thread);
+	thread->md.fp = _MD_GET_FP_PTR(thread);
+	return PR_SUCCESS;
+}
+
+PRStatus
+_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
+{
+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
+    _PR_MD_SWITCH_CONTEXT(thread);
+    return PR_SUCCESS;
+}
+
+PRStatus
+_MD_WAKEUP_WAITER(PRThread *thread)
+{
+    if (thread) {
+	PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
+    }
+    return PR_SUCCESS;
+}
+
+/* These functions should not be called for RISC OS */
+void
+_MD_YIELD(void)
+{
+    PR_NOT_REACHED("_MD_YIELD should not be called for RISC OS.");
+}
+
+PRStatus
+_MD_CREATE_THREAD(
+    PRThread *thread,
+    void (*start) (void *),
+    PRThreadPriority priority,
+    PRThreadScope scope,
+    PRThreadState state,
+    PRUint32 stackSize)
+{
+    PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for RISC OS.");
+	return PR_FAILURE;
+}
+#endif /* ! _PR_PTHREADS */
--- a/pr/src/md/unix/unix.c
+++ b/pr/src/md/unix/unix.c
@@ -70,17 +70,17 @@
 #elif defined(IRIX) || defined(HPUX) || defined(OSF1) || defined(SOLARIS) \
     || defined(AIX4_1) || defined(LINUX) || defined(SONY) \
     || defined(BSDI) || defined(SCO) || defined(NEC) || defined(SNI) \
     || defined(SUNOS4) || defined(NCR) || defined(DARWIN) \
     || defined(NEXTSTEP) || defined(QNX)
 #define _PRSockLen_t int
 #elif (defined(AIX) && !defined(AIX4_1)) || defined(FREEBSD) \
     || defined(NETBSD) || defined(OPENBSD) || defined(UNIXWARE) \
-    || defined(DGUX) || defined(VMS) || defined(NTO)
+    || defined(DGUX) || defined(VMS) || defined(NTO) || defined(RISCOS)
 #define _PRSockLen_t size_t
 #else
 #error "Cannot determine architecture"
 #endif
 
 /*
 ** Global lock variable used to bracket calls into rusty libraries that
 ** aren't thread safe (like libc, libX, etc).
--- a/pr/src/md/unix/uxrng.c
+++ b/pr/src/md/unix/uxrng.c
@@ -293,17 +293,17 @@ GetHighResClock(void *buf, size_t maxbyt
 #elif defined(NEC)
 
 static size_t
 GetHighResClock(void *buf, size_t maxbytes)
 {
     return 0;
 }
 #elif defined(SCO) || defined(UNIXWARE) || defined(BSDI) || defined(NTO) \
-    || defined(QNX) || defined(DARWIN)
+    || defined(QNX) || defined(DARWIN) || defined(RISCOS)
 #include <sys/times.h>
 
 static size_t
 GetHighResClock(void *buf, size_t maxbytes)
 {
     int ticks;
     struct tms buffer;
 
--- a/pr/src/md/windows/ntinrval.c
+++ b/pr/src/md/windows/ntinrval.c
@@ -37,88 +37,24 @@
 
 /*
  * NT interval timers
  *
  */
 
 #include "primpl.h"
 
-#if defined(WIN16)
-#include <win/compobj.h>
-#define QueryPerformanceFrequency(x)   FALSE
-#define QueryPerformanceCounter(x)     FALSE
-#endif
-
-static PRIntn _nt_bitShift = 0;
-static PRInt32 _nt_ticksPerSec = -1;
-
 void
 _PR_MD_INTERVAL_INIT()
 {
-    LARGE_INTEGER count;
-
-    if (QueryPerformanceFrequency(&count)) {
-        /*
-         * HighPart is signed (LONG).  Assert that its sign bit is 0
-         * because we will be right shifting it.  LowPart is unsigned
-         * (DWORD).
-         */
-        PR_ASSERT(count.HighPart >= 0);
-        while(count.HighPart) {
-            count.LowPart = (count.HighPart << 31) + (count.LowPart >> 1);
-            count.HighPart >>= 1;
-            _nt_bitShift++;
-        }
-        while(count.LowPart > PR_INTERVAL_MAX) {
-            count.LowPart >>= 1;
-            _nt_bitShift++;
-        }
-
-        /*
-         * We can't use the performance counter if after
-         * normalization we are left with fewer than 32 bits.
-         */
-        if (_nt_bitShift <= 32) {
-            _nt_ticksPerSec = count.LowPart;
-            PR_ASSERT(_nt_ticksPerSec > PR_INTERVAL_MIN);
-            return;
-        }
-    }
-    _nt_ticksPerSec = -1;
 }
 
 PRIntervalTime 
 _PR_MD_GET_INTERVAL()
 {
-    LARGE_INTEGER count;
-
-   /* Sadly; nspr requires the interval to range from 1000 ticks per second
-    * to only 100000 ticks per second; QueryPerformanceCounter is too high
-    * resolution...
-    */
-    if (_nt_ticksPerSec != -1) {
-        (void)QueryPerformanceCounter(&count);
-        PR_ASSERT(_nt_bitShift <= 32);
-        if (_nt_bitShift == 32) {
-            return (PRUint32)count.HighPart;
-        } else {
-            return (PRUint32)((count.HighPart << (32 - _nt_bitShift))
-                    + (count.LowPart >> _nt_bitShift));
-        }
-    } else
-#if defined(__MINGW32__)
-        return time();
-#elif defined(WIN16)
-        return clock();        /* milliseconds since application start */
-#else
-        return GetTickCount();  /* milliseconds since system start */
-#endif
+    return timeGetTime();  /* milliseconds since system start */
 }
 
 PRIntervalTime 
 _PR_MD_INTERVAL_PER_SEC()
 {
-    if (_nt_ticksPerSec != -1)
-        return _nt_ticksPerSec;
-    else
-        return 1000;
+    return 1000;
 }
--- a/pr/src/md/windows/ntio.c
+++ b/pr/src/md/windows/ntio.c
@@ -15,16 +15,17 @@
  * 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) 1998-2000
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
+ *   Masayuki Nakano <masayuki@d-toybox.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
@@ -103,16 +104,18 @@ static DWORD dirAccessTable[] = {
  * This constant is used by _PR_FileTimeToPRTime().
  */
 #ifdef __GNUC__
 static const PRTime _pr_filetime_offset = 116444736000000000LL;
 #else
 static const PRTime _pr_filetime_offset = 116444736000000000i64;
 #endif
 
+static PRBool IsPrevCharSlash(const char *str, const char *current);
+
 #define _NEED_351_FILE_LOCKING_HACK
 #ifdef _NEED_351_FILE_LOCKING_HACK
 #define _PR_LOCAL_FILE 1
 #define _PR_REMOTE_FILE 2
 PRBool IsFileLocalInit();
 PRInt32 IsFileLocal(HANDLE hFile);
 #endif /* _NEED_351_FILE_LOCKING_HACK */
 
@@ -2764,17 +2767,17 @@ PRStatus
         return PR_FAILURE;
     }
     strcpy(filename, name);
 
     /*
      * If 'name' ends in a slash or backslash, do not append
      * another backslash.
      */
-    if (filename[len - 1] == '/' || filename[len - 1] == '\\') {
+    if (IsPrevCharSlash(filename, filename + len)) {
         len--;
     }
     strcpy(&filename[len], "\\*.*");
     FlipSlashes( filename, strlen(filename) );
 
     d->d_hdl = FindFirstFile( filename, &(d->d_entry) );
     if ( d->d_hdl == INVALID_HANDLE_VALUE ) {
 		_PR_MD_MAP_OPENDIR_ERROR(GetLastError());
@@ -2902,33 +2905,44 @@ PRInt32
          * can be handled by _stat() on NT but not on Win95.
          *
          * We remove the backslash or slash at the end and
          * try again.
          */
 
         int len = strlen(fn);
         if (len > 0 && len <= _MAX_PATH
-                && (fn[len - 1] == '\\' || fn[len - 1] == '/')) {
+                && IsPrevCharSlash(fn, fn + len)) {
             char newfn[_MAX_PATH + 1];
 
             strcpy(newfn, fn);
             newfn[len - 1] = '\0';
             rv = _stat(newfn, (struct _stat *)info);
         }
     }
 
     if (-1 == rv) {
         _PR_MD_MAP_STAT_ERROR(errno);
     }
     return rv;
 }
 
 #define _PR_IS_SLASH(ch) ((ch) == '/' || (ch) == '\\')
 
+static PRBool
+IsPrevCharSlash(const char *str, const char *current)
+{
+    const char *prev;
+
+    if (str >= current)
+        return PR_FALSE;
+    prev = _mbsdec(str, current);
+    return (prev == current - 1) && _PR_IS_SLASH(*prev);
+}
+
 /*
  * IsRootDirectory --
  *
  * Return PR_TRUE if the pathname 'fn' is a valid root directory,
  * else return PR_FALSE.  The char buffer pointed to by 'fn' must
  * be writable.  During the execution of this function, the contents
  * of the buffer pointed to by 'fn' may be modified, but on return
  * the original contents will be restored.  'buflen' is the size of
@@ -2965,31 +2979,31 @@ IsRootDirectory(char *fn, size_t buflen)
         /* The 'server' part should have at least one character. */
         p = &fn[2];
         if (*p == '\0' || _PR_IS_SLASH(*p)) {
             return PR_FALSE;
         }
 
         /* look for the next slash */
         do {
-            p++;
+            p = _mbsinc(p);
         } while (*p != '\0' && !_PR_IS_SLASH(*p));
         if (*p == '\0') {
             return PR_FALSE;
         }
 
         /* The 'share' part should have at least one character. */
         p++;
         if (*p == '\0' || _PR_IS_SLASH(*p)) {
             return PR_FALSE;
         }
 
         /* look for the final slash */
         do {
-            p++;
+            p = _mbsinc(p);
         } while (*p != '\0' && !_PR_IS_SLASH(*p));
         if (_PR_IS_SLASH(*p) && p[1] != '\0') {
             return PR_FALSE;
         }
         if (*p == '\0') {
             /*
              * GetDriveType() doesn't work correctly if the
              * path is of the form \\server\share, so we add
@@ -3069,17 +3083,17 @@ PRInt32
             info->size = 0;
             /*
              * These timestamps don't make sense for root directories.
              */
             info->modifyTime = 0;
             info->creationTime = 0;
             return 0;
         }
-        if (!_PR_IS_SLASH(pathbuf[len - 1])) {
+        if (!IsPrevCharSlash(pathbuf, pathbuf + len)) {
             _PR_MD_MAP_OPENDIR_ERROR(GetLastError());
             return -1;
         } else {
             pathbuf[len - 1] = '\0';
             hFindFile = FindFirstFile(pathbuf, &findFileData);
             if (INVALID_HANDLE_VALUE == hFindFile) {
                 _PR_MD_MAP_OPENDIR_ERROR(GetLastError());
                 return -1;
--- a/pr/src/md/windows/w95io.c
+++ b/pr/src/md/windows/w95io.c
@@ -15,16 +15,17 @@
  * 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) 1998-2000
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
+ *   Masayuki Nakano <masayuki@d-toybox.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
@@ -79,16 +80,18 @@ static const PRTime _pr_filetime_offset 
 #else
 static const PRTime _pr_filetime_offset = 116444736000000000i64;
 #endif
 
 #ifdef MOZ_UNICODE
 static void InitUnicodeSupport(void);
 #endif
 
+static PRBool IsPrevCharSlash(const char *str, const char *current);
+
 void
 _PR_MD_INIT_IO()
 {
     WORD WSAVersion = 0x0101;
     WSADATA WSAData;
     int err;
 
     err = WSAStartup( WSAVersion, &WSAData );
@@ -511,17 +514,17 @@ PRStatus
         return PR_FAILURE;
     }
     strcpy(filename, name);
 
     /*
      * If 'name' ends in a slash or backslash, do not append
      * another backslash.
      */
-    if (filename[len - 1] == '/' || filename[len - 1] == '\\') {
+    if (IsPrevCharSlash(filename, filename + len)) {
         len--;
     }
     strcpy(&filename[len], "\\*.*");
     FlipSlashes( filename, strlen(filename) );
 
     d->d_hdl = FindFirstFile( filename, &(d->d_entry) );
     if ( d->d_hdl == INVALID_HANDLE_VALUE ) {
 		_PR_MD_MAP_OPENDIR_ERROR(GetLastError());
@@ -649,33 +652,44 @@ PRInt32
          * can be handled by _stat() on NT but not on Win95.
          *
          * We remove the backslash or slash at the end and
          * try again.
          */
 
         int len = strlen(fn);
         if (len > 0 && len <= _MAX_PATH
-                && (fn[len - 1] == '\\' || fn[len - 1] == '/')) {
+                && IsPrevCharSlash(fn, fn + len)) {
             char newfn[_MAX_PATH + 1];
 
             strcpy(newfn, fn);
             newfn[len - 1] = '\0';
             rv = _stat(newfn, (struct _stat *)info);
         }
     }
 
     if (-1 == rv) {
         _PR_MD_MAP_STAT_ERROR(errno);
     }
     return rv;
 }
 
 #define _PR_IS_SLASH(ch) ((ch) == '/' || (ch) == '\\')
 
+static PRBool
+IsPrevCharSlash(const char *str, const char *current)
+{
+    const char *prev;
+
+    if (str >= current)
+        return PR_FALSE;
+    prev = _mbsdec(str, current);
+    return (prev == current - 1) && _PR_IS_SLASH(*prev);
+}
+
 /*
  * IsRootDirectory --
  *
  * Return PR_TRUE if the pathname 'fn' is a valid root directory,
  * else return PR_FALSE.  The char buffer pointed to by 'fn' must
  * be writable.  During the execution of this function, the contents
  * of the buffer pointed to by 'fn' may be modified, but on return
  * the original contents will be restored.  'buflen' is the size of
@@ -712,31 +726,31 @@ IsRootDirectory(char *fn, size_t buflen)
         /* The 'server' part should have at least one character. */
         p = &fn[2];
         if (*p == '\0' || _PR_IS_SLASH(*p)) {
             return PR_FALSE;
         }
 
         /* look for the next slash */
         do {
-            p++;
+            p = _mbsinc(p);
         } while (*p != '\0' && !_PR_IS_SLASH(*p));
         if (*p == '\0') {
             return PR_FALSE;
         }
 
         /* The 'share' part should have at least one character. */
         p++;
         if (*p == '\0' || _PR_IS_SLASH(*p)) {
             return PR_FALSE;
         }
 
         /* look for the final slash */
         do {
-            p++;
+            p = _mbsinc(p);
         } while (*p != '\0' && !_PR_IS_SLASH(*p));
         if (_PR_IS_SLASH(*p) && p[1] != '\0') {
             return PR_FALSE;
         }
         if (*p == '\0') {
             /*
              * GetDriveType() doesn't work correctly if the
              * path is of the form \\server\share, so we add
@@ -816,17 +830,17 @@ PRInt32
             info->size = 0;
             /*
              * These timestamps don't make sense for root directories.
              */
             info->modifyTime = 0;
             info->creationTime = 0;
             return 0;
         }
-        if (!_PR_IS_SLASH(pathbuf[len - 1])) {
+        if (!IsPrevCharSlash(pathbuf, pathbuf + len)) {
             _PR_MD_MAP_OPENDIR_ERROR(GetLastError());
             return -1;
         } else {
             pathbuf[len - 1] = '\0';
             hFindFile = FindFirstFile(pathbuf, &findFileData);
             if (INVALID_HANDLE_VALUE == hFindFile) {
                 _PR_MD_MAP_OPENDIR_ERROR(GetLastError());
                 return -1;
--- a/pr/src/misc/prdtoa.c
+++ b/pr/src/misc/prdtoa.c
@@ -323,20 +323,21 @@ static double private_mem[PRIVATE_mem], 
 #else /* ifndef Bad_float_h */
 #include "float.h"
 /*
  * MacOS 10.2 defines the macro FLT_ROUNDS to an internal function
  * which does not exist on 10.1.  We can safely #define it to 1 here
  * to allow 10.2 builds to run on 10.1, since we can't use fesetround()
  * (which does not exist on 10.1 either).
  */
-#if defined(MACOS_DEPLOYMENT_TARGET) && (MACOS_DEPLOYMENT_TARGET < 100200)
+#if defined(XP_MACOSX) && (!defined(MAC_OS_X_VERSION_10_2) || \
+    MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2)
 #undef FLT_ROUNDS
 #define FLT_ROUNDS 1
-#endif
+#endif /* DT < 10.2 */
 #endif /* Bad_float_h */
 
 #ifndef __MATH_H__
 #include "math.h"
 #endif
 
 #ifdef __cplusplus
 extern "C" {
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -183,18 +183,18 @@ const PRIPv6Addr _pr_in6addr_loopback = 
 static PRLock *_pr_query_ifs_lock = NULL;
 static PRBool _pr_have_inet_if = PR_FALSE;
 static PRBool _pr_have_inet6_if = PR_FALSE;
 
 #undef DEBUG_QUERY_IFS
 
 #if defined(AIX) \
     || (defined(DARWIN) && (!defined(HAVE_GETIFADDRS) \
-        || (defined(MACOS_DEPLOYMENT_TARGET) \
-        && MACOS_DEPLOYMENT_TARGET < 100200)))
+        || (defined(XP_MACOSX) && (!defined(MAC_OS_X_VERSION_10_2) || \
+        MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2))))
 
 /*
  * Use SIOCGIFCONF ioctl on platforms that don't have routing
  * sockets.  Warning: whether SIOCGIFCONF ioctl returns AF_INET6
  * network interfaces is not portable.
  *
  * The _pr_QueryNetIfs() function is derived from the code in
  * src/lib/libc/net/getifaddrs.c in BSD Unix and the code in
--- a/pr/src/misc/prsystem.c
+++ b/pr/src/misc/prsystem.c
@@ -250,16 +250,18 @@ PR_IMPLEMENT(PRInt32) PR_GetNumberOfProc
 #elif defined(HPUX)
     numCpus = mpctl( MPC_GETNUMSPUS, 0, 0 );
     if ( numCpus < 1 )  {
         numCpus = -1; /* set to -1 for return value on error */
         _PR_MD_MAP_DEFAULT_ERROR( _MD_ERRNO() );
     }
 #elif defined(IRIX)
     numCpus = sysconf( _SC_NPROC_ONLN );
+#elif defined(RISCOS)
+    numCpus = 1;
 #elif defined(XP_UNIX)
     numCpus = sysconf( _SC_NPROCESSORS_ONLN );
 #else
 #error "An implementation is required"
 #endif
     return(numCpus);
 } /* end PR_GetNumberOfProcessors() */
 
@@ -271,87 +273,85 @@ PR_IMPLEMENT(PRInt32) PR_GetNumberOfProc
 **     bytes is the returned value.
 **   for each platform's "if defined" section
 **     declare your local variable
 **     do your thing, assign to bytes.
 ** 
 */
 PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
 {
-    PRUint64 bytes = LL_ZERO;
+    PRUint64 bytes = 0;
 
 #if defined(LINUX) || defined(SOLARIS)
 
     long pageSize = sysconf(_SC_PAGESIZE);
     long pageCount = sysconf(_SC_PHYS_PAGES);
-    LL_I2L(bytes, pageSize * pageCount);
+    bytes = (PRUint64) pageSize * pageCount;
 
 #elif defined(HPUX)
 
     struct pst_static info;
     int result = pstat_getstatic(&info, sizeof(info), 1, 0);
     if (result == 1)
-        LL_I2L(bytes, info.physical_memory * info.page_size);
+        bytes = (PRUint64) info.physical_memory * info.page_size;
 
 #elif defined(DARWIN)
 
     struct host_basic_info hInfo;
     mach_msg_type_number_t count;
 
     int result = host_info(mach_host_self(),
                            HOST_BASIC_INFO,
                            (host_info_t) &hInfo,
                            &count);
     if (result == KERN_SUCCESS)
-        LL_I2L(bytes, hInfo.memory_size);
+        bytes = hInfo.memory_size;
 
 #elif defined(WIN32)
 
     /* Try to use the newer GlobalMemoryStatusEx API for Windows 2000+. */
     GlobalMemoryStatusExFn globalMemory = (GlobalMemoryStatusExFn) NULL;
     HMODULE module = GetModuleHandle("kernel32.dll");
 
     if (module) {
         globalMemory = (GlobalMemoryStatusExFn)GetProcAddress(module, "GlobalMemoryStatusEx");
 
         if (globalMemory) {
             PR_MEMORYSTATUSEX memStat;
             memStat.dwLength = sizeof(memStat);
 
             if (globalMemory(&memStat))
-                LL_UI2L(bytes, memStat.ullTotalPhys);
+                bytes = memStat.ullTotalPhys;
         }
     }
 
-    if (LL_EQ(bytes, LL_ZERO)) {
+    if (!bytes) {
         /* Fall back to the older API. */
         MEMORYSTATUS memStat;
         memset(&memStat, 0, sizeof(memStat));
         GlobalMemoryStatus(&memStat);
-        LL_I2L(bytes, memStat.dwTotalPhys);
+        bytes = memStat.dwTotalPhys;
     }
 
 #elif defined(OS2)
 
     ULONG ulPhysMem;
     DosQuerySysInfo(QSV_TOTPHYSMEM,
                     QSV_TOTPHYSMEM,
                     &ulPhysMem,
                     sizeof(ulPhysMem));
-    LL_I2L(bytes, ulPhysMem);
+    bytes = ulPhysMem;
 
 #elif defined(AIX)
 
     if (odm_initialize() == 0) {
         int how_many;
         struct CuAt *obj = getattr("sys0", "realmem", 0, &how_many);
         if (obj != NULL) {
-            PRUint64 kbytes;
-            LL_I2L(kbytes, atoi(obj->value));
-            LL_MUL(bytes, kbytes, 1024);
+            bytes = (PRUint64) atoi(obj->value) * 1024;
             free(obj);
         }
         odm_terminate();
     }
 
 #else
 
     PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -194,37 +194,26 @@ static ssize_t (*pt_aix_sendfile_fptr)()
 #define TCP_CORK 3
 #endif
 #endif
 
 #ifdef _PR_IPV6_V6ONLY_PROBE
 static PRBool _pr_ipv6_v6only_on_by_default;
 #endif
 
-#if defined(SOLARIS)
-#define _PRSockOptVal_t char *
-#elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(HPUX) \
-    || defined(LINUX) || defined(FREEBSD) || defined(BSDI) || defined(VMS) \
-    || defined(NTO) || defined(OPENBSD) || defined(DARWIN) \
-    || defined(UNIXWARE) || defined(NETBSD)
-#define _PRSockOptVal_t void *
-#else
-#error "Cannot determine architecture"
-#endif
-
 #if (defined(HPUX) && !defined(HPUX10_30) && !defined(HPUX11))
 #define _PRSelectFdSetArg_t int *
 #elif defined(AIX4_1)
 #define _PRSelectFdSetArg_t void *
 #elif defined(IRIX) || (defined(AIX) && !defined(AIX4_1)) \
     || defined(OSF1) || defined(SOLARIS) \
     || defined(HPUX10_30) || defined(HPUX11) || defined(LINUX) \
     || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
     || defined(BSDI) || defined(VMS) || defined(NTO) || defined(DARWIN) \
-    || defined(UNIXWARE)
+    || defined(UNIXWARE) || defined(RISCOS)
 #define _PRSelectFdSetArg_t fd_set *
 #else
 #error "Cannot determine architecture"
 #endif
 
 static PRFileDesc *pt_SetMethods(
     PRIntn osfd, PRDescType type, PRBool isAcceptedSocket, PRBool imported);
 
@@ -3238,17 +3227,17 @@ static PRIOMethods _pr_socketpollfd_meth
     (PRReservedFN)_PR_InvalidInt, 
     (PRReservedFN)_PR_InvalidInt, 
     (PRReservedFN)_PR_InvalidInt
 };
 
 #if defined(HPUX) || defined(OSF1) || defined(SOLARIS) || defined (IRIX) \
     || defined(AIX) || defined(LINUX) || defined(FREEBSD) || defined(NETBSD) \
     || defined(OPENBSD) || defined(BSDI) || defined(VMS) || defined(NTO) \
-    || defined(DARWIN) || defined(UNIXWARE)
+    || defined(DARWIN) || defined(UNIXWARE) || defined(RISCOS)
 #define _PR_FCNTL_FLAGS O_NONBLOCK
 #else
 #error "Can't determine architecture"
 #endif
 
 /*
  * Put a Unix file descriptor in non-blocking mode.
  */
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -243,21 +243,21 @@ static void *_pt_root(void *arg)
     if (NULL == thred->next)
         pt_book.last = thred->prev;
     else
         thred->next->prev = thred->prev;
     PR_Unlock(pt_book.ml);
 
     /*
     * Here we set the pthread's backpointer to the PRThread to NULL.
-    * Otherwise the desctructor would get called eagerly as the thread
+    * Otherwise the destructor would get called eagerly as the thread
     * returns to the pthread runtime. The joining thread would them be
     * the proud possessor of a dangling reference. However, this is the
     * last chance to delete the object if the thread is detached, so
-    * just let the destuctor do the work.
+    * just let the destructor do the work.
     */
     if (PR_FALSE == detached)
     {
         rv = pthread_setspecific(pt_book.key, NULL);
         PR_ASSERT(0 == rv);
     }
 
     return NULL;
@@ -1228,17 +1228,18 @@ static void suspend_signal_handler(PRInt
 	/*
 	 * now, block current thread
 	 */
 #if defined(PT_NO_SIGTIMEDWAIT)
 	pthread_cond_signal(&me->suspendResumeCV);
 	while (me->suspend & PT_THREAD_SUSPENDED)
 	{
 #if !defined(FREEBSD) && !defined(NETBSD) && !defined(OPENBSD) \
-    && !defined(BSDI) && !defined(VMS) && !defined(UNIXWARE) && !defined(DARWIN)  /*XXX*/
+    && !defined(BSDI) && !defined(VMS) && !defined(UNIXWARE) \
+    && !defined(DARWIN) && !defined(RISCOS) /*XXX*/
         PRIntn rv;
 	    sigwait(&sigwait_set, &rv);
 #endif
 	}
 	me->suspend |= PT_THREAD_RESUMED;
 	pthread_cond_signal(&me->suspendResumeCV);
 #else /* defined(PT_NO_SIGTIMEDWAIT) */
 	while (me->suspend & PT_THREAD_SUSPENDED)
--- a/pr/tests/server_test.c
+++ b/pr/tests/server_test.c
@@ -225,19 +225,19 @@ WorkerThreadFunc(void *_listenSock)
                                   PR_SYSTEM_THREAD,
                                   WorkerThreadFunc,
                                   listenSock,
                                   PR_PRIORITY_NORMAL,
                                   ServerScope,
                                   PR_UNJOINABLE_THREAD,
                                   THREAD_STACKSIZE);
 
-                if (!WorkerThread)
+                if (!WorkerThread) {
                     if (debug_mode) printf("Error creating client thread %d\n", workerThreads);
-                else {
+                } else {
                     PR_AtomicIncrement(&workerThreads);
                     if (debug_mode) DPRINTF("\tServer creates worker (%d)\n", workerThreads);
                 }
             }
             PR_Unlock(workerThreadsLock);
         }
  
         bytesToRead -= bytesRead;
@@ -254,21 +254,22 @@ WorkerThreadFunc(void *_listenSock)
             if (debug_mode) DPRINTF("\tServer received %d bytes\n", bytesRead);
         }
 
         bytesWritten = PR_Send(newSock,
                                sendBuf, 
                                bytesToWrite, 
                                0, 
                                PR_INTERVAL_NO_TIMEOUT);
-        if (bytesWritten != _server_data)
+        if (bytesWritten != _server_data) {
             if (debug_mode) printf("\tError sending data to client (%d, %d)\n", 
                 bytesWritten, PR_GetOSError());
-        else
+        } else {
             if (debug_mode) DPRINTF("\tServer sent %d bytes\n", bytesWritten);
+        }	
 
         PR_Close(newSock);
         PR_AtomicDecrement(&workerThreadsBusy);
     }
 }
 
 PRFileDesc *
 ServerSetup(void)
--- a/pr/tests/servr_kk.c
+++ b/pr/tests/servr_kk.c
@@ -191,19 +191,19 @@ WorkerThreadFunc(void *_listenSock)
                                   PR_SYSTEM_THREAD,
                                   WorkerThreadFunc,
                                   listenSock,
                                   PR_PRIORITY_NORMAL,
                                   ServerScope,
                                   PR_UNJOINABLE_THREAD,
                                   THREAD_STACKSIZE);
 
-                if (!WorkerThread)
+                if (!WorkerThread) {
                     if (debug_mode) printf("Error creating client thread %d\n", workerThreads);
-                else {
+                } else {
                     PR_AtomicIncrement(&workerThreads);
                     if (debug_mode) DPRINTF("\tServer creates worker (%d)\n", workerThreads);
                 }
             }
             PR_Unlock(workerThreadsLock);
         }
  
         bytesToRead -= bytesRead;
@@ -220,21 +220,22 @@ WorkerThreadFunc(void *_listenSock)
             if (debug_mode) DPRINTF("\tServer received %d bytes\n", bytesRead);
         }
 
         bytesWritten = PR_Send(newSock,
                                sendBuf, 
                                bytesToWrite, 
                                0, 
                                PR_INTERVAL_NO_TIMEOUT);
-        if (bytesWritten != _server_data)
+        if (bytesWritten != _server_data) {
             if (debug_mode) printf("\tError sending data to client (%d, %d)\n", 
                 bytesWritten, PR_GetOSError());
-        else
+        } else {
             if (debug_mode) DPRINTF("\tServer sent %d bytes\n", bytesWritten);
+        }
 
         PR_Close(newSock);
         PR_AtomicDecrement(&workerThreadsBusy);
     }
 }
 
 PRFileDesc *
 ServerSetup(void)
--- a/pr/tests/servr_ku.c
+++ b/pr/tests/servr_ku.c
@@ -192,19 +192,19 @@ WorkerThreadFunc(void *_listenSock)
                                   PR_SYSTEM_THREAD,
                                   WorkerThreadFunc,
                                   listenSock,
                                   PR_PRIORITY_NORMAL,
                                   ServerScope,
                                   PR_UNJOINABLE_THREAD,
                                   THREAD_STACKSIZE);
 
-                if (!WorkerThread)
+                if (!WorkerThread) {
                     if (debug_mode) printf("Error creating client thread %d\n", workerThreads);
-                else {
+                } else {
                     PR_AtomicIncrement(&workerThreads);
                     if (debug_mode) DPRINTF("\tServer creates worker (%d)\n", workerThreads);
                 }
             }
             PR_Unlock(workerThreadsLock);
         }
  
         bytesToRead -= bytesRead;
@@ -221,21 +221,22 @@ WorkerThreadFunc(void *_listenSock)
             if (debug_mode) DPRINTF("\tServer received %d bytes\n", bytesRead);
         }
 
         bytesWritten = PR_Send(newSock,
                                sendBuf, 
                                bytesToWrite, 
                                0, 
                                PR_INTERVAL_NO_TIMEOUT);
-        if (bytesWritten != _server_data)
+        if (bytesWritten != _server_data) {
             if (debug_mode) printf("\tError sending data to client (%d, %d)\n", 
                 bytesWritten, PR_GetOSError());
-        else
+        } else {
             if (debug_mode) DPRINTF("\tServer sent %d bytes\n", bytesWritten);
+        }
 
         PR_Close(newSock);
         PR_AtomicDecrement(&workerThreadsBusy);
     }
 }
 
 PRFileDesc *
 ServerSetup(void)
--- a/pr/tests/servr_uk.c
+++ b/pr/tests/servr_uk.c
@@ -194,19 +194,19 @@ WorkerThreadFunc(void *_listenSock)
                                   PR_SYSTEM_THREAD,
                                   WorkerThreadFunc,
                                   listenSock,
                                   PR_PRIORITY_NORMAL,
                                   ServerScope,
                                   PR_UNJOINABLE_THREAD,
                                   THREAD_STACKSIZE);
 
-                if (!WorkerThread)
+                if (!WorkerThread) {
                     if (debug_mode) printf("Error creating client thread %d\n", workerThreads);
-                else {
+                } else {
                     PR_AtomicIncrement(&workerThreads);
                     if (debug_mode) DPRINTF("\tServer creates worker (%d)\n", workerThreads);
                 }
             }
             PR_Unlock(workerThreadsLock);
         }
  
         bytesToRead -= bytesRead;
@@ -223,21 +223,22 @@ WorkerThreadFunc(void *_listenSock)
             if (debug_mode) DPRINTF("\tServer received %d bytes\n", bytesRead);
         }
 
         bytesWritten = PR_Send(newSock,
                                sendBuf, 
                                bytesToWrite, 
                                0, 
                                PR_INTERVAL_NO_TIMEOUT);
-        if (bytesWritten != _server_data)
+        if (bytesWritten != _server_data) {
             if (debug_mode) printf("\tError sending data to client (%d, %d)\n", 
                 bytesWritten, PR_GetOSError());
-        else
+        } else {
             if (debug_mode) DPRINTF("\tServer sent %d bytes\n", bytesWritten);
+        }
 
         PR_Close(newSock);
         PR_AtomicDecrement(&workerThreadsBusy);
     }
 }
 
 PRFileDesc *
 ServerSetup(void)
--- a/pr/tests/servr_uu.c
+++ b/pr/tests/servr_uu.c
@@ -192,19 +192,19 @@ WorkerThreadFunc(void *_listenSock)
                                   PR_SYSTEM_THREAD,
                                   WorkerThreadFunc,
                                   listenSock,
                                   PR_PRIORITY_NORMAL,
                                   ServerScope,
                                   PR_UNJOINABLE_THREAD,
                                   THREAD_STACKSIZE);
 
-                if (!WorkerThread)
+                if (!WorkerThread) {
                     if (debug_mode) printf("Error creating client thread %d\n", workerThreads);
-                else {
+                } else {
                     PR_AtomicIncrement(&workerThreads);
                     if (debug_mode) DPRINTF("\tServer creates worker (%d)\n", workerThreads);
                 }
             }
             PR_Unlock(workerThreadsLock);
         }
  
         bytesToRead -= bytesRead;
@@ -221,21 +221,22 @@ WorkerThreadFunc(void *_listenSock)
             if (debug_mode) DPRINTF("\tServer received %d bytes\n", bytesRead);
         }
 
         bytesWritten = PR_Send(newSock,
                                sendBuf, 
                                bytesToWrite, 
                                0, 
                                PR_INTERVAL_NO_TIMEOUT);
-        if (bytesWritten != _server_data)
+        if (bytesWritten != _server_data) {
             if (debug_mode) printf("\tError sending data to client (%d, %d)\n", 
                 bytesWritten, PR_GetOSError());
-        else
+        } else {
             if (debug_mode) DPRINTF("\tServer sent %d bytes\n", bytesWritten);
+        } 
 
         PR_Close(newSock);
         PR_AtomicDecrement(&workerThreadsBusy);
     }
 }
 
 PRFileDesc *
 ServerSetup(void)
--- a/pr/tests/vercheck.c
+++ b/pr/tests/vercheck.c
@@ -47,24 +47,24 @@
  */
 
 #include "prinit.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 
 /*
- * This release (4.6) is backward compatible with the
- * 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, and 4.5.x releases.  It, of course,
- * is compatible with itself.
+ * This release (4.6.1) is backward compatible with the
+ * 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, 4.5.x, and 4.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", PR_VERSION
+    "4.5", "4.5.1", "4.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.