fixup commit for branch 'SVG_0_9_6_BRANCH' SVG_0_9_6_BRANCH
authorcvs2hg
Sat, 03 Nov 2001 05:57:08 +0000
branchSVG_0_9_6_BRANCH
changeset 2116 4502f93348bd6f508fcaf3150ce17957bc2f9abc
parent 2016 8e47a5d8f3f35f33f951a82ac610cf81cc6e3243
push idunknown
push userunknown
push dateunknown
fixup commit for branch 'SVG_0_9_6_BRANCH'
build/autoconf/config.guess
build/autoconf/config.sub
config/autoconf.mk.in
config/nsinstall.c
config/nspr-config.in
config/prdepend.h
configure
configure.in
lib/libc/include/plstr.h
lib/libc/src/Makefile.in
lib/libc/src/strtok.c
lib/tests/string.c
macbuild/NSPR20PPC.mcp
pr/include/gencfg.c
pr/include/md/Makefile.in
pr/include/md/_darwin.cfg
pr/include/md/_darwin.h
pr/include/md/_macos.h
pr/include/md/_nto.h
pr/include/md/_pth.h
pr/include/md/_unixos.h
pr/include/md/prosdep.h
pr/include/obsolete/protypes.h
pr/include/private/primpl.h
pr/src/Makefile.in
pr/src/linking/prlink.c
pr/src/md/beos/beos_errors.c
pr/src/md/mac/macio.c
pr/src/md/mac/macrng.c
pr/src/md/mac/macsockotpt.c
pr/src/md/mac/macthr.c
pr/src/md/mac/mdcriticalregion.c
pr/src/md/mac/mdcriticalregion.h
pr/src/md/mac/mdmac.c
pr/src/md/os2/os2cv.c
pr/src/md/prosdep.c
pr/src/md/unix/unix.c
pr/src/md/unix/unix_errors.c
pr/src/md/unix/uxproces.c
pr/src/md/unix/uxrng.c
pr/src/misc/prnetdb.c
pr/src/misc/prsystem.c
pr/src/misc/prtime.c
pr/src/pthreads/ptio.c
pr/src/pthreads/ptsynch.c
pr/tests/Makefile.in
pr/tests/dll/Makefile.in
--- a/build/autoconf/config.guess
+++ b/build/autoconf/config.guess
@@ -1,14 +1,14 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
 #   Free Software Foundation, Inc.
 
-timestamp='2001-03-30'
+timestamp='2001-10-05'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,18 +19,19 @@ timestamp='2001-03-30'
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 
-# Written by Per Bothner <bothner@cygnus.com>.
-# Please send patches to <config-patches@gnu.org>.
+# Originally written by Per Bothner <bothner@cygnus.com>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
 #
 # This script attempts to guess a canonical system name similar to
 # config.sub.  If it succeeds, it prints the system name on stdout, and
 # exits with 0.  Otherwise, it exits with 1.
 #
 # The plan is that this can be called by configure scripts if you
 # don't specify an explicit build system type.
 
@@ -47,17 +48,17 @@ Operation modes:
   -v, --version      print version number, then exit
 
 Report bugs and patches to <config-patches@gnu.org>."
 
 version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 
 help="
 Try \`$me --help' for more information."
 
@@ -90,71 +91,73 @@ fi
 
 dummy=dummy-$$
 trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
 
 # CC_FOR_BUILD -- compiler used by this script.
 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
 # use `HOST_CC' if defined, but it is deprecated.
 
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,)    echo "int dummy(){}" > $dummy.c
+set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int dummy(){}" > $dummy.c ;
 	for c in cc gcc c89 ; do
-	  ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1
+	  ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
 	  if test $? = 0 ; then
-	     CC_FOR_BUILD="$c"; break
-	  fi
-	done
-	rm -f $dummy.c $dummy.o $dummy.rel
+	     CC_FOR_BUILD="$c"; break ;
+	  fi ;
+	done ;
+	rm -f $dummy.c $dummy.o $dummy.rel ;
 	if test x"$CC_FOR_BUILD" = x ; then
-	  CC_FOR_BUILD=no_compiler_found
+	  CC_FOR_BUILD=no_compiler_found ;
 	fi
 	;;
  ,,*)   CC_FOR_BUILD=$CC ;;
  ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
-esac
+esac'
 
 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 8/24/94.)
+# (ghazi@noc.rutgers.edu 1994-08-24)
 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
 	PATH=$PATH:/.attbin ; export PATH
 fi
 
 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
 UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:NetBSD:*:*)
-	# Netbsd (nbsd) targets should (where applicable) match one or
+	# NetBSD (nbsd) targets should (where applicable) match one or
 	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
 	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
 	# switched to ELF, *-*-netbsd* would select the old
 	# object file format.  This provides both forward
 	# compatibility and a consistent mechanism for selecting the
 	# object file format.
 	# Determine the machine/vendor (is the vendor relevant).
 	case "${UNAME_MACHINE}" in
 	    amiga) machine=m68k-unknown ;;
 	    arm32) machine=arm-unknown ;;
 	    atari*) machine=m68k-atari ;;
 	    sun3*) machine=m68k-sun ;;
 	    mac68k) machine=m68k-apple ;;
 	    macppc) machine=powerpc-apple ;;
 	    hp3[0-9][05]) machine=m68k-hp ;;
 	    ibmrt|romp-ibm) machine=romp-ibm ;;
+	    sparc*) machine=`uname -p`-unknown ;;
 	    *) machine=${UNAME_MACHINE}-unknown ;;
 	esac
 	# The Operating System including object format, if it has switched
 	# to ELF recently, or will in the future.
 	case "${UNAME_MACHINE}" in
 	    i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
+		eval $set_cc_for_build
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
 			| grep __ELF__ >/dev/null
 		then
 		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
 		    # Return netbsd for either.  FIX?
 		    os=netbsd
 		else
 		    os=netbsdelf
@@ -166,16 +169,55 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:$
 	esac
 	# The OS release
 	release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
 	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
 	# contains redundant information, the shorter form:
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
 	echo "${machine}-${os}${release}"
 	exit 0 ;;
+    amiga:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    arc:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    hp300:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mac68k:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    macppc:OpenBSD:*:*)
+	echo powerpc-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvme68k:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvme88k:OpenBSD:*:*)
+	echo m88k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvmeppc:OpenBSD:*:*)
+	echo powerpc-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    pmax:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    sgi:OpenBSD:*:*)
+	echo mipseb-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    sun3:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    wgrisc:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:OpenBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
     alpha:OSF1:*:*)
 	if test $UNAME_RELEASE = "V4.0"; then
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
 	fi
 	# A Vn.n version is a released version.
 	# A Tn.n version is a released field test version.
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
@@ -199,16 +241,17 @@ main:
 	mov \$0,\$17
 	not \$1,\$18
 	jsr \$26,printf
 	ldgp \$29,0(\$26)
 	mov 0,\$16
 	jsr \$26,exit
 	.end main
 EOF
+	eval $set_cc_for_build
 	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
 	if test "$?" = 0 ; then
 		case `./$dummy` in
 			0-0)
 				UNAME_MACHINE="alpha"
 				;;
 			1-0)
 				UNAME_MACHINE="alphaev5"
@@ -220,16 +263,19 @@ EOF
 				UNAME_MACHINE="alphapca56"
 				;;
 			2-303)
 				UNAME_MACHINE="alphaev6"
 				;;
 			2-307)
 				UNAME_MACHINE="alphaev67"
 				;;
+			2-1307)
+				UNAME_MACHINE="alphaev68"
+				;;
 		esac
 	fi
 	rm -f $dummy.s $dummy
 	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
 	exit 0 ;;
     Alpha\ *:Windows_NT*:*)
 	# How do we know it's Interix rather than the generic POSIX subsystem?
 	# Should we change UNAME_MACHINE based on the output of uname instead
@@ -237,40 +283,19 @@ EOF
 	echo alpha-pc-interix
 	exit 0 ;;
     21064:Windows_NT:50:3)
 	echo alpha-dec-winnt3.5
 	exit 0 ;;
     Amiga*:UNIX_System_V:4.0:*)
 	echo m68k-unknown-sysv4
 	exit 0;;
-    amiga:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
     *:[Aa]miga[Oo][Ss]:*:*)
 	echo ${UNAME_MACHINE}-unknown-amigaos
 	exit 0 ;;
-    arc64:OpenBSD:*:*)
-	echo mips64el-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    arc:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    hkmips:OpenBSD:*:*)
-	echo mips-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    pmax:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    sgi:OpenBSD:*:*)
-	echo mips-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    wgrisc:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
     *:OS/390:*:*)
 	echo i370-ibm-openedition
 	exit 0 ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
 	exit 0;;
     SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
 	echo hppa1.1-hitachi-hiuxmpp
@@ -323,19 +348,16 @@ EOF
 	    sun4)
 		echo sparc-sun-sunos${UNAME_RELEASE}
 		;;
 	esac
 	exit 0 ;;
     aushp:SunOS:*:*)
 	echo sparc-auspex-sunos${UNAME_RELEASE}
 	exit 0 ;;
-    atari*:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
     # The situation for MiNT is a little confusing.  The machine name
     # can be virtually everything (everything which is not
     # "atarist" or "atariste" at least should have a processor
     # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
     # to the lowercase version "mint" (or "freemint").  Finally
     # the system name "TOS" denotes a system which is actually not
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
@@ -352,44 +374,33 @@ EOF
         echo m68k-milan-mint${UNAME_RELEASE}
         exit 0 ;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
         echo m68k-hades-mint${UNAME_RELEASE}
         exit 0 ;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
         echo m68k-unknown-mint${UNAME_RELEASE}
         exit 0 ;;
-    sun3*:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    mac68k:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    mvme68k:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    mvme88k:OpenBSD:*:*)
-	echo m88k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
     powerpc:machten:*:*)
 	echo powerpc-apple-machten${UNAME_RELEASE}
 	exit 0 ;;
     RISC*:Mach:*:*)
 	echo mips-dec-mach_bsd4.3
 	exit 0 ;;
     RISC*:ULTRIX:*:*)
 	echo mips-dec-ultrix${UNAME_RELEASE}
 	exit 0 ;;
     VAX*:ULTRIX*:*:*)
 	echo vax-dec-ultrix${UNAME_RELEASE}
 	exit 0 ;;
     2020:CLIX:*:* | 2430:CLIX:*:*)
 	echo clipper-intergraph-clix${UNAME_RELEASE}
 	exit 0 ;;
     mips:*:*:UMIPS | mips:*:*:RISCos)
+	eval $set_cc_for_build
 	sed 's/^	//' << EOF >$dummy.c
 #ifdef __cplusplus
 #include <stdio.h>  /* for printf() prototype */
 	int main (int argc, char *argv[]) {
 #else
 	int main (argc, argv) int argc; char *argv[]; {
 #endif
 	#if defined (host_mips) && defined (MIPSEB)
@@ -407,16 +418,19 @@ EOF
 	}
 EOF
 	$CC_FOR_BUILD $dummy.c -o $dummy \
 	  && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
 	  && rm -f $dummy.c $dummy && exit 0
 	rm -f $dummy.c $dummy
 	echo mips-mips-riscos${UNAME_RELEASE}
 	exit 0 ;;
+    Motorola:PowerMAX_OS:*:*)
+	echo powerpc-motorola-powermax
+	exit 0 ;;
     Night_Hawk:Power_UNIX:*:*)
 	echo powerpc-harris-powerunix
 	exit 0 ;;
     m88k:CX/UX:7*:*)
 	echo m88k-harris-cxux7
 	exit 0 ;;
     m88k:*:4*:R4*)
 	echo m88k-motorola-sysv4
@@ -454,29 +468,30 @@ EOF
 	echo m68k-tektronix-bsd
 	exit 0 ;;
     *:IRIX*:*:*)
 	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
 	exit 0 ;;
     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
 	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
 	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
-    i?86:AIX:*:*)
+    i*86:AIX:*:*)
 	echo i386-ibm-aix
 	exit 0 ;;
     ia64:AIX:*:*)
 	if [ -x /usr/bin/oslevel ] ; then
 		IBM_REV=`/usr/bin/oslevel`
 	else
 		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
 	fi
 	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
 	exit 0 ;;
     *:AIX:2:3)
 	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+		eval $set_cc_for_build
 		sed 's/^		//' << EOF >$dummy.c
 		#include <sys/systemcfg.h>
 
 		main()
 			{
 			if (!__power_pc())
 				exit(1);
 			puts("powerpc-ibm-aix3.2.5");
@@ -528,34 +543,33 @@ EOF
 	echo m68k-hp-bsd4.4
 	exit 0 ;;
     9000/[34678]??:HP-UX:*:*)
 	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
 	case "${UNAME_MACHINE}" in
 	    9000/31? )            HP_ARCH=m68000 ;;
 	    9000/[34]?? )         HP_ARCH=m68k ;;
 	    9000/[678][0-9][0-9])
-              case "${HPUX_REV}" in
-                11.[0-9][0-9])
-                  if [ -x /usr/bin/getconf ]; then
-                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+		if [ -x /usr/bin/getconf ]; then
+		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
                     sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
                     case "${sc_cpu_version}" in
                       523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
                       528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
                       532)                      # CPU_PA_RISC2_0
                         case "${sc_kernel_bits}" in
                           32) HP_ARCH="hppa2.0n" ;;
                           64) HP_ARCH="hppa2.0w" ;;
+			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
                         esac ;;
                     esac
-                  fi ;;
-              esac
-              if [ "${HP_ARCH}" = "" ]; then
-              sed 's/^              //' << EOF >$dummy.c
+		fi
+		if [ "${HP_ARCH}" = "" ]; then
+		    eval $set_cc_for_build
+		    sed 's/^              //' << EOF >$dummy.c
 
               #define _HPUX_SOURCE
               #include <stdlib.h>
               #include <unistd.h>
 
               int main ()
               {
               #if defined(_SC_KERNEL_BITS)
@@ -578,28 +592,29 @@ EOF
               #else  /* !defined(_SC_KERNEL_BITS) */
               	    puts ("hppa2.0"); break;
               #endif
               	default: puts ("hppa1.0"); break;
               	}
                   exit (0);
               }
 EOF
-	(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
-	if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
-	rm -f $dummy.c $dummy
-	fi ;;
+		    (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy`
+		    if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
+		    rm -f $dummy.c $dummy
+		fi ;;
 	esac
 	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
 	exit 0 ;;
     ia64:HP-UX:*:*)
 	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
 	echo ia64-hp-hpux${HPUX_REV}
 	exit 0 ;;
     3050*:HI-UX:*:*)
+	eval $set_cc_for_build
 	sed 's/^	//' << EOF >$dummy.c
 	#include <unistd.h>
 	int
 	main ()
 	{
 	  long cpu = sysconf (_SC_CPU_VERSION);
 	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
 	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
@@ -625,38 +640,35 @@ EOF
 	echo unknown-hitachi-hiuxwe2
 	exit 0 ;;
     9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
 	echo hppa1.1-hp-bsd
 	exit 0 ;;
     9000/8??:4.3bsd:*:*)
 	echo hppa1.0-hp-bsd
 	exit 0 ;;
-    *9??*:MPE/iX:*:*)
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
 	echo hppa1.0-hp-mpeix
 	exit 0 ;;
     hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
 	echo hppa1.1-hp-osf
 	exit 0 ;;
     hp8??:OSF1:*:*)
 	echo hppa1.0-hp-osf
 	exit 0 ;;
-    i?86:OSF1:*:*)
+    i*86:OSF1:*:*)
 	if [ -x /usr/sbin/sysversion ] ; then
 	    echo ${UNAME_MACHINE}-unknown-osf1mk
 	else
 	    echo ${UNAME_MACHINE}-unknown-osf1
 	fi
 	exit 0 ;;
     parisc*:Lites*:*:*)
 	echo hppa1.1-hp-lites
 	exit 0 ;;
-    hppa*:OpenBSD:*:*)
-	echo hppa-unknown-openbsd
-	exit 0 ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
 	echo c1-convex-bsd
         exit 0 ;;
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
 	if getsysinfo -f scalar_acc
 	then echo c32-convex-bsd
 	else echo c2-convex-bsd
 	fi
@@ -669,22 +681,23 @@ EOF
         exit 0 ;;
     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
 	echo c4-convex-bsd
         exit 0 ;;
     CRAY*X-MP:*:*:*)
 	echo xmp-cray-unicos
         exit 0 ;;
     CRAY*Y-MP:*:*:*)
-	echo ymp-cray-unicos${UNAME_RELEASE}
+	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     CRAY*[A-Z]90:*:*:*)
 	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
 	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+	      -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     CRAY*TS:*:*:*)
 	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     CRAY*T3D:*:*:*)
 	echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     CRAY*T3E:*:*:*)
@@ -697,45 +710,43 @@ EOF
 	echo cray2-cray-unicos
         exit 0 ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
 	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
         FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
         FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
         echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
         exit 0 ;;
-    hp300:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
 	exit 0 ;;
     sparc*:BSD/OS:*:*)
 	echo sparc-unknown-bsdi${UNAME_RELEASE}
 	exit 0 ;;
     *:BSD/OS:*:*)
 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit 0 ;;
     *:FreeBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit 0 ;;
-    *:OpenBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-	exit 0 ;;
     i*:CYGWIN*:*)
 	echo ${UNAME_MACHINE}-pc-cygwin
 	exit 0 ;;
     i*:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit 0 ;;
 #### MozillaHack 
 # Netscape's hacked uname
     xx:WINNT:* | xx:WIN95:*)
 	echo i586-pc-msvc
 	exit 0 ;;
+# MKS Toolkit
+    [34567]86:Windows_NT:*)
+	echo i386-pc-mksnt
+	exit 0 ;;
 ###  End MozillaHack
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
 	exit 0 ;;
     i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
 	# How do we know it's Interix rather than the generic POSIX subsystem?
 	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
 	# UNAME_MACHINE based on the output of uname instead of i386?
@@ -761,107 +772,39 @@ EOF
 	exit 0 ;;
     ia64:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux
 	exit 0 ;;
     m68*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
     mips:Linux:*:*)
-	cat >$dummy.c <<EOF
-#ifdef __cplusplus
-#include <stdio.h>  /* for printf() prototype */
-int main (int argc, char *argv[]) {
-#else
-int main (argc, argv) int argc; char *argv[]; {
-#endif
-#ifdef __MIPSEB__
-  printf ("%s-unknown-linux-gnu\n", argv[1]);
-#endif
-#ifdef __MIPSEL__
-  printf ("%sel-unknown-linux-gnu\n", argv[1]);
-#endif
-  return 0;
-}
-EOF
-	$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
-	rm -f $dummy.c $dummy
+	case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in
+	  big)    echo mips-unknown-linux-gnu && exit 0 ;;
+	  little) echo mipsel-unknown-linux-gnu && exit 0 ;;
+	esac
 	;;
     ppc:Linux:*:*)
-	# Determine Lib Version
-	cat >$dummy.c <<EOF
-#include <features.h>
-#if defined(__GLIBC__)
-extern char __libc_version[];
-extern char __libc_release[];
-#endif
-main(argc, argv)
-     int argc;
-     char *argv[];
-{
-#if defined(__GLIBC__)
-  printf("%s %s\n", __libc_version, __libc_release);
-#else
-  printf("unknown\n");
-#endif
-  return 0;
-}
-EOF
-	LIBC=""
-	$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
-	if test "$?" = 0 ; then
-		./$dummy | grep 1\.99 > /dev/null
-		if test "$?" = 0 ; then LIBC="libc1" ; fi
-	fi
-	rm -f $dummy.c $dummy
-	echo powerpc-unknown-linux-gnu${LIBC}
+	echo powerpc-unknown-linux-gnu
+	exit 0 ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-gnu
 	exit 0 ;;
     alpha:Linux:*:*)
-	cat <<EOF >$dummy.s
-	  .data
-	  \$Lformat:
-		.byte 37,100,45,37,120,10,0	# "%d-%x\n"
-	   .text
-		.globl main
-		.align 4
-		.ent main
-	    main:
-		.frame \$30,16,\$26,0
-		ldgp \$29,0(\$27)
-		.prologue 1
-		.long 0x47e03d80 # implver \$0
-		lda \$2,-1
-		.long 0x47e20c21 # amask \$2,\$1
-		lda \$16,\$Lformat
-		mov \$0,\$17
-		not \$1,\$18
-		jsr \$26,printf
-		ldgp \$29,0(\$26)
-		mov 0,\$16
-		jsr \$26,exit
-		.end main
-EOF
-	LIBC=""
-	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
-	if test "$?" = 0 ; then
-		case `./$dummy` in
-		0-0)	UNAME_MACHINE="alpha" ;;
-		1-0)	UNAME_MACHINE="alphaev5" ;;
-		1-1)    UNAME_MACHINE="alphaev56" ;;
-		1-101)	UNAME_MACHINE="alphapca56" ;;
-		2-303)	UNAME_MACHINE="alphaev6" ;;
-		2-307)	UNAME_MACHINE="alphaev67" ;;
-		esac
-		objdump --private-headers $dummy | \
-		  grep ld.so.1 > /dev/null
-		if test "$?" = 0 ; then
-			LIBC="libc1"
-		fi
-	fi
-	rm -f $dummy.s $dummy
+	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+	  EV5)   UNAME_MACHINE=alphaev5 ;;
+	  EV56)  UNAME_MACHINE=alphaev56 ;;
+	  PCA56) UNAME_MACHINE=alphapca56 ;;
+	  PCA57) UNAME_MACHINE=alphapca56 ;;
+	  EV6)   UNAME_MACHINE=alphaev6 ;;
+	  EV67)  UNAME_MACHINE=alphaev67 ;;
+	  EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+	objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
 	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
 	exit 0 ;;
     parisc:Linux:*:* | hppa:Linux:*:*)
 	# Look for CPU level
 	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
 	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
 	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
 	  *)    echo hppa-unknown-linux-gnu ;;
@@ -877,113 +820,103 @@ EOF
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
     x86_64:Linux:*:*)
 	echo x86_64-unknown-linux-gnu
 	exit 0 ;;
-    i?86:Linux:*:*)
+    i*86:Linux:*:*)
 	# The BFD linker knows what the default object file format is, so
 	# first see if it will tell us. cd to the root directory to prevent
 	# problems with other programs or directories called `ld' in the path.
-	ld_supported_emulations=`cd /; ld --help 2>&1 \
-			 | sed -ne '/supported emulations:/!d
+	ld_supported_targets=`cd /; ld --help 2>&1 \
+			 | sed -ne '/supported targets:/!d
 				    s/[ 	][ 	]*/ /g
-				    s/.*supported emulations: *//
+				    s/.*supported targets: *//
 				    s/ .*//
 				    p'`
-        case "$ld_supported_emulations" in
-	  i?86linux)
-		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
-		exit 0
-		;;
-	  elf_i?86)
+        case "$ld_supported_targets" in
+	  elf32-i386)
 		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
 		;;
-	  i?86coff)
+	  a.out-i386-linux)
+		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+		exit 0 ;;		
+	  coff-i386)
 		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
-		exit 0
-		;;
-	esac
-	# Either a pre-BFD a.out linker (linux-gnuoldld)
-	# or one that does not give us useful --help.
-	# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
-	# If ld does not provide *any* "supported emulations:"
-	# that means it is gnuoldld.
-	test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
-	case "${UNAME_MACHINE}" in
-	i?86)
-	  VENDOR=pc;
-	  ;;
-	*)
-	  VENDOR=unknown;
-	  ;;
+		exit 0 ;;
+	  "")
+		# Either a pre-BFD a.out linker (linux-gnuoldld) or
+		# one that does not give us useful --help.
+		echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+		exit 0 ;;
 	esac
 	# Determine whether the default compiler is a.out or elf
+	eval $set_cc_for_build
 	cat >$dummy.c <<EOF
 #include <features.h>
 #ifdef __cplusplus
 #include <stdio.h>  /* for printf() prototype */
 	int main (int argc, char *argv[]) {
 #else
 	int main (argc, argv) int argc; char *argv[]; {
 #endif
 #ifdef __ELF__
 # ifdef __GLIBC__
 #  if __GLIBC__ >= 2
-    printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
+    printf ("%s-pc-linux-gnu\n", argv[1]);
 #  else
-    printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+    printf ("%s-pc-linux-gnulibc1\n", argv[1]);
 #  endif
 # else
-   printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+   printf ("%s-pc-linux-gnulibc1\n", argv[1]);
 # endif
 #else
-  printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
+  printf ("%s-pc-linux-gnuaout\n", argv[1]);
 #endif
   return 0;
 }
 EOF
 	$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
 	rm -f $dummy.c $dummy
 	test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
 	;;
-# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
-# are messed up and put the nodename in both sysname and nodename.
-    i?86:DYNIX/ptx:4*:*)
+    i*86:DYNIX/ptx:4*:*)
+	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+	# earlier versions are messed up and put the nodename in both
+	# sysname and nodename.
 	echo i386-sequent-sysv4
 	exit 0 ;;
-    i?86:UNIX_SV:4.2MP:2.*)
+    i*86:UNIX_SV:4.2MP:2.*)
         # Unixware is an offshoot of SVR4, but it has its own version
         # number series starting with 2...
         # I am not positive that other SVR4 systems won't match this,
 	# I just have to hope.  -- rms.
         # Use sysv4.2uw... so that sysv4* matches it.
 	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
 	exit 0 ;;
-    i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
 	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
 	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
 		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
 	else
 		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
 	fi
 	exit 0 ;;
-    i?86:*:5:7*)
-        # Fixed at (any) Pentium or better
-        UNAME_MACHINE=i586
-        if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
-	    echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
-	else
-	    echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
-	fi
+    i*86:*:5:[78]*)
+	case `/bin/uname -X | grep "^Machine"` in
+	    *486*)	     UNAME_MACHINE=i486 ;;
+	    *Pentium)	     UNAME_MACHINE=i586 ;;
+	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+	esac
+	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
 	exit 0 ;;
-    i?86:*:3.2:*)
+    i*86:*:3.2:*)
 	if test -f /usr/options/cb.name; then
 		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
 		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
 	elif /bin/uname -X 2>/dev/null >/dev/null ; then
 		UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
 		(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
 		(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
 			&& UNAME_MACHINE=i586
@@ -991,17 +924,17 @@ EOF
 			&& UNAME_MACHINE=i686
 		(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
 			&& UNAME_MACHINE=i686
 		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
 	else
 		echo ${UNAME_MACHINE}-pc-sysv32
 	fi
 	exit 0 ;;
-    i?86:*DOS:*:*)
+    i*86:*DOS:*:*)
 	echo ${UNAME_MACHINE}-pc-msdosdjgpp
 	exit 0 ;;
     pc:*:*:*)
 	# Left here for compatibility:
         # uname -m prints for DJGPP always 'pc', but it prints nothing about
         # the processor, so we play safe by assuming i386.
 	echo i386-pc-msdosdjgpp
         exit 0 ;;
@@ -1019,34 +952,34 @@ EOF
 	fi
 	exit 0 ;;
     mini*:CTIX:SYS*5:*)
 	# "miniframe"
 	echo m68010-convergent-sysv
 	exit 0 ;;
     M68*:*:R3V[567]*:*)
 	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
-    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0)
 	OS_REL=''
 	test -r /etc/.relid \
 	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
 	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
 	  && echo i486-ncr-sysv4.3${OS_REL} && exit 0
 	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
 	  && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
         /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
           && echo i486-ncr-sysv4 && exit 0 ;;
     m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
 	echo m68k-unknown-lynxos${UNAME_RELEASE}
 	exit 0 ;;
     mc68030:UNIX_System_V:4.*:*)
 	echo m68k-atari-sysv4
 	exit 0 ;;
-    i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:* | i?86:LynxOS:4.0*:*)
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
 	echo i386-unknown-lynxos${UNAME_RELEASE}
 	exit 0 ;;
     TSUNAMI:LynxOS:2.*:*)
 	echo sparc-unknown-lynxos${UNAME_RELEASE}
 	exit 0 ;;
     rs6000:LynxOS:2.*:*)
 	echo rs6000-unknown-lynxos${UNAME_RELEASE}
 	exit 0 ;;
@@ -1065,18 +998,18 @@ EOF
     *:SINIX-*:*:*)
 	if uname -p 2>/dev/null >/dev/null ; then
 		UNAME_MACHINE=`(uname -p) 2>/dev/null`
 		echo ${UNAME_MACHINE}-sni-sysv4
 	else
 		echo ns32k-sni-sysv
 	fi
 	exit 0 ;;
-    PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                           # says <Richard.M.Bartel@ccMail.Census.GOV>
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
         echo i586-unisys-sysv4
         exit 0 ;;
 #### MozillaHack 
     *:*OpenVMS*:*:*)
         case "${UNAME_SYSTEM}" in
             POSIX_for_OpenVMS_AXP) echo alpha-dec-openvmsposix ;;
             POSIX_for_OpenVMS_VAX) echo vax-dec-openvmsposix ;;
             OpenVMS) echo alpha-dec-openvms ;;
@@ -1088,16 +1021,20 @@ EOF
 	# From Gerald Hewes <hewes@openmarket.com>.
 	# How about differentiating between stratus architectures? -djm
 	echo hppa1.1-stratus-sysv4
 	exit 0 ;;
     *:*:*:FTX*)
 	# From seanf@swdc.stratus.com.
 	echo i860-stratus-sysv4
 	exit 0 ;;
+    *:VOS:*:*)
+	# From Paul.Green@stratus.com.
+	echo hppa1.1-stratus-vos
+	exit 0 ;;
     mc68*:A/UX:*:*)
 	echo m68k-apple-aux${UNAME_RELEASE}
 	exit 0 ;;
     news*:NEWS-OS:6*:*)
 	echo mips-sony-newsos6
 	exit 0 ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
 	if [ -d /usr/nec ]; then
@@ -1157,17 +1094,17 @@ EOF
 	# operating systems.
 	if test "$cputype" = "386"; then
 	    UNAME_MACHINE=i386
 	else
 	    UNAME_MACHINE="$cputype"
 	fi
 	echo ${UNAME_MACHINE}-unknown-plan9
 	exit 0 ;;
-    i?86:OS/2:*:*)
+    i*86:OS/2:*:*)
 	# If we were able to find `uname', then EMX Unix compatibility
 	# is probably installed.
 	# echo ${UNAME_MACHINE}-pc-os2-emx
 #### MozillaHack 
  	if test "$VACPP" = "yes"; then
 		echo "i386-pc-os2_vacpp"
 	else
 		echo "i386-pc-os2_emx"
@@ -1187,21 +1124,28 @@ EOF
 	echo pdp10-xkl-tops20
 	exit 0 ;;
     *:TOPS-20:*:*)
 	echo pdp10-unknown-tops20
 	exit 0 ;;
     *:ITS:*:*)
 	echo pdp10-unknown-its
 	exit 0 ;;
+    i*86:XTS-300:*:STOP)
+	echo ${UNAME_MACHINE}-unknown-stop
+	exit 0 ;;
+    i*86:atheos:*:*)
+	echo ${UNAME_MACHINE}-unknown-atheos
+	exit 0 ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
 
+eval $set_cc_for_build
 cat >$dummy.c <<EOF
 #ifdef _SEQUENT_
 # include <sys/types.h>
 # include <sys/utsname.h>
 #endif
 main ()
 {
 #if defined (sony)
--- a/build/autoconf/config.sub
+++ b/build/autoconf/config.sub
@@ -1,14 +1,14 @@
 #! /bin/sh
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
 #   Free Software Foundation, Inc.
 
-timestamp='2001-03-30'
+timestamp='2001-10-05'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
 # can handle that machine.  It does not imply ALL GNU software can.
 #
 # This file is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
@@ -24,17 +24,18 @@ timestamp='2001-03-30'
 # Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 
-# Please send patches to <config-patches@gnu.org>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
 # If it is invalid, we print an error message on stderr and exit with code 1.
 # Otherwise, we print the canonical config type on stdout and succeed.
 
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
@@ -112,17 +113,17 @@ case $# in
  *) echo "$me: too many arguments$help" >&2
     exit 1;;
 esac
 
 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*)
+  nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
   *)
     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
     if [ $basic_machine != $1 ]
     then os=`echo $1 | sed 's/.*-/-/'`
     else os=; fi
@@ -152,16 +153,24 @@ case $os in
 		basic_machine=$1
 		;;
 	-scout)
 		;;
 	-wrs)
 		os=-vxworks
 		basic_machine=$1
 		;;
+	-chorusos*)
+		os=-chorusos
+		basic_machine=$1
+		;;
+ 	-chorusrdb)
+ 		os=-chorusrdb
+		basic_machine=$1
+ 		;;
 	-hiux*)
 		os=-hiuxwe2
 		;;
 	-sco5)
 		os=-sco3.2v5
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco4)
@@ -210,81 +219,106 @@ case $os in
 		os=-mint
 		;;
 esac
 
 # Decode aliases for certain CPU-COMPANY combinations.
 case $basic_machine in
 	# Recognize the basic CPU types without company name.
 	# Some are omitted here because they have special meanings below.
-	tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
-	        | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
-		| pyramid | mn10200 | mn10300 | tron | a29k \
-		| 580 | i960 | h8300 \
-		| x86 | ppcbe | mipsbe | mipsle | shbe | shle \
-		| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
-		| hppa64 \
-		| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
-		| alphaev6[78] \
-		| we32k | ns16k | clipper | i370 | sh | sh[34] \
-		| powerpc | powerpcle \
-		| 1750a | dsp16xx | pdp10 | pdp11 \
-		| mips16 | mips64 | mipsel | mips64el \
-		| mips64orion | mips64orionel | mipstx39 | mipstx39el \
-		| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
-		| mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \
-		| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
-		| thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \
-		| pj | pjl | h8500)
+	1750a | 580 \
+	| a29k \
+	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+	| c4x | clipper \
+	| d10v | d30v | dsp16xx \
+	| fr30 \
+	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| i370 | i860 | i960 | ia64 \
+	| m32r | m68000 | m68k | m88k | mcore \
+	| mips16 | mips64 | mips64el | mips64orion | mips64orionel \
+	| mips64vr4100 | mips64vr4100el | mips64vr4300 \
+	| mips64vr4300el | mips64vr5000 | mips64vr5000el \
+	| mipsbe | mipseb | mips*el | mipsle | mipstx39 | mipstx39el \
+	| mipsisa32 \
+	| mn10200 | mn10300 \
+	| ns16k | ns32k \
+	| openrisc \
+	| pdp10 | pdp11 | pj | pjl \
+	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| pyramid \
+	| s390 | s390x \
+	| sh | sh[34] | sh[34]eb | shbe | shle \
+	| sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \
+	| stormy16 | strongarm \
+	| tahoe | thumb | tic80 | tron \
+	| v850 \
+	| we32k \
+	| x86 | xscale \
+	| z8k)
 		basic_machine=$basic_machine-unknown
 		;;
 	m6811 | m68hc11 | m6812 | m68hc12)
 		# Motorola 68HC11/12.
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
-	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65)
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
 		;;
 
 	# We use `pc' rather than `unknown'
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
-	i[234567]86 | x86_64)
+	i*86 | x86_64)
 	  basic_machine=$basic_machine-pc
 	  ;;
 	# Object if more than one company name word.
 	*-*-*)
 		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
 		exit 1
 		;;
 	# Recognize the basic CPU types with company name.
-	# FIXME: clean up the formatting here.
-	vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
-	      | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
-	      | arm-*  | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
-	      | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
-	      | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
-	      | xmp-* | ymp-* \
-	      | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
-	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
-	      | hppa2.0n-* | hppa64-* \
-	      | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
-	      | alphaev6[78]-* \
-	      | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
-	      | clipper-* | orion-* \
-	      | sparclite-* | pdp10-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
-	      | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
-	      | mips64el-* | mips64orion-* | mips64orionel-* \
-	      | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
-	      | mipstx39-* | mipstx39el-* | mcore-* \
-	      | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \
-	      | [cjt]90-* \
-	      | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
-	      | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \
-	      | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*)
+	580-* \
+	| a29k-* \
+	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+	| alphapca5[67]-* | arc-* \
+	| arm-*  | armbe-* | armle-* | armv*-* \
+	| avr-* \
+	| bs2000-* \
+	| c[123]* | c30-* | [cjt]90-* | c54x-* \
+	| clipper-* | cray2-* | cydra-* \
+	| d10v-* | d30v-* \
+	| elxsi-* \
+	| f30[01]-* | f700-* | fr30-* | fx80-* \
+	| h8300-* | h8500-* \
+	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| i*86-* | i860-* | i960-* | ia64-* \
+	| m32r-* \
+	| m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \
+	| m88110-* | m88k-* | mcore-* \
+	| mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
+	| mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
+	| mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \
+	| mipsle-* | mips*el-* | mipstx39-* | mipstx39el-* \
+	| none-* | np1-* | ns16k-* | ns32k-* \
+	| orion-* \
+	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| pyramid-* \
+	| romp-* | rs6000-* \
+	| s390-* | s390x-* \
+	| sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \
+	| sparc-* | sparc64-* | sparc86x-* | sparclite-* \
+	| sparcv9-* | sparcv9b-* | stormy16-* | strongarm-* | sv1-* \
+	| t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
+	| v850-* | vax-* \
+	| we32k-* \
+	| x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \
+	| ymp-* \
+	| z8k-*)
 		;;
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
 	386bsd)
 		basic_machine=i386-unknown
 		os=-bsd
 		;;
 	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
@@ -501,29 +535,29 @@ case $basic_machine in
 	hppro)
 		basic_machine=hppa1.1-hp
 		os=-proelf
 		;;
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
 		;;
 # I'm not sure what "Sysv32" means.  Should this be sysv3.2?
-	i[34567]86v32)
+	i*86v32)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv32
 		;;
-	i[34567]86v4*)
+	i*86v4*)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv4
 		;;
-	i[34567]86v)
+	i*86v)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv
 		;;
-	i[34567]86sol2)
+	i*86sol2)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-solaris2
 		;;
 	i386mach)
 		basic_machine=i386-mach
 		os=-mach
 		;;
 	i386-vsta | vsta)
@@ -559,16 +593,20 @@ case $basic_machine in
 		basic_machine=i386-pc
 		os=-mingw32
 		;;
 #### MozillaHack 
 	i386-msvc | msvc)
 		basic_machine=i386-pc
 		os=-msvc
 		;;
+	i386-mksnt)
+		basic_machine=i386-pc
+		os=-mksnt
+		;;
 #### End MozillaHack 
 	miniframe)
 		basic_machine=m68000-convergent
 		;;
 	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
 		basic_machine=m68k-atari
 		os=-mint
 		;;
@@ -693,26 +731,26 @@ case $basic_machine in
 		basic_machine=sparc-tti
 		;;
 	pbb)
 		basic_machine=m68k-tti
 		;;
         pc532 | pc532-*)
 		basic_machine=ns32k-pc532
 		;;
-	pentium | p5 | k5 | k6 | nexgen)
+	pentium | p5 | k5 | k6 | nexgen | viac3)
 		basic_machine=i586-pc
 		;;
 	pentiumpro | p6 | 6x86 | athlon)
 		basic_machine=i686-pc
 		;;
 	pentiumii | pentium2)
 		basic_machine=i686-pc
 		;;
-	pentium-* | p5-* | k5-* | k6-* | nexgen-*)
+	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
 		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	pentiumpro-* | p6-* | 6x86-* | athlon-*)
 		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	pentiumii-* | pentium2-*)
 		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
@@ -726,16 +764,26 @@ case $basic_machine in
 	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	ppcle | powerpclittle | ppc-le | powerpc-little)
 		basic_machine=powerpcle-unknown
 	        ;;
 	ppcle-* | powerpclittle-*)
 		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
+	ppc64)	basic_machine=powerpc64-unknown
+	        ;;
+	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+		basic_machine=powerpc64le-unknown
+	        ;;
+	ppc64le-* | powerpc64little-*)
+		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
 	ps2)
 		basic_machine=i386-ibm
 		;;
 	pw32)
 		basic_machine=i586-unknown
 		os=-pw32
 		;;
 	rom68k)
@@ -754,17 +802,17 @@ case $basic_machine in
 		;;
 	sequent)
 		basic_machine=i386-sequent
 		;;
 	sh)
 		basic_machine=sh-hitachi
 		os=-hms
 		;;
-	sparclite-wrs)
+	sparclite-wrs | simso-wrs)
 		basic_machine=sparclite-wrs
 		os=-vxworks
 		;;
 	sps7)
 		basic_machine=m68k-bull
 		os=-sysv2
 		;;
 	spur)
@@ -880,16 +928,20 @@ case $basic_machine in
 	w65*)
 		basic_machine=w65-wdc
 		os=-none
 		;;
 	w89k-*)
 		basic_machine=hppa1.1-winbond
 		os=-proelf
 		;;
+	windows32)
+		basic_machine=i386-pc
+		os=-windows32-msvcrt
+		;;
 	xmp)
 		basic_machine=xmp-cray
 		os=-unicos
 		;;
         xps | xps100)
 		basic_machine=xps100-honeywell
 		;;
 	z8k-*-coff)
@@ -933,20 +985,20 @@ case $basic_machine in
 		basic_machine=pdp10-unknown
 		;;
 	pdp11)
 		basic_machine=pdp11-dec
 		;;
 	we32k)
 		basic_machine=we32k-att
 		;;
-	sh3 | sh4)
+	sh3 | sh4 | sh3eb | sh4eb)
 		basic_machine=sh-unknown
 		;;
-	sparc | sparcv9)
+	sparc | sparcv9 | sparcv9b)
 		basic_machine=sparc-sun
 		;;
         cydra)
 		basic_machine=cydra-cydrome
 		;;
 	orion)
 		basic_machine=orion-highlevel
 		;;
@@ -1023,27 +1075,29 @@ case $os in
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 	      | -aos* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
 	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+	      | -chorusos* | -chorusrdb* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
 	      | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
-	      | -msvc* \
+	      | -msvc* | -mksnt* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
-	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*)
+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+	      | -os2* | -vos*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
 		case $basic_machine in
-		    x86-* | i[34567]86-*)
+		    x86-* | i*86-*)
 			;;
 		    *)
 			os=-nto$os
 			;;
 		esac
 		;;
 	-nto*)
 		os=-nto-qnx
@@ -1352,16 +1406,19 @@ case $basic_machine in
 				vendor=hitachi
 				;;
 			-mpw* | -macos*)
 				vendor=apple
 				;;
 			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
 				vendor=atari
 				;;
+			-vos*)
+				vendor=stratus
+				;;
 		esac
 		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
 		;;
 esac
 
 echo $basic_machine$os
 exit 0
 
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -3,23 +3,23 @@
 INCLUDED_AUTOCONF_MK = 1
 USE_AUTOCONF	= 1
 @SHELL_OVERRIDE@
 MOZILLA_CLIENT	= @MOZILLA_CLIENT@
 
 prefix		= @prefix@
 exec_prefix	= @exec_prefix@
 bindir		= @bindir@
-includedir	= @includedir@/nspr
+includedir	= @includedir@
 libdir		= @libdir@
 datadir		= @datadir@
 
 dist_prefix	= @dist_prefix@
 dist_bindir	= @dist_bindir@
-dist_includedir = @dist_includedir@/nspr
+dist_includedir = @dist_includedir@
 dist_libdir	= @dist_libdir@
 
 DIST		= $(dist_prefix)
 
 RELEASE_OBJDIR_NAME = @RELEASE_OBJDIR_NAME@
 OBJDIR_NAME	= @OBJDIR_NAME@
 OBJDIR		= @OBJDIR@
 OBJ_SUFFIX	= @OBJ_SUFFIX@
--- a/config/nsinstall.c
+++ b/config/nsinstall.c
@@ -62,17 +62,17 @@
 #if defined(BEOS)
 #undef HAVE_FCHMOD
 #endif
 
 /*
  * Does getcwd() take NULL as the first argument and malloc
  * the result buffer?
  */
-#if !defined(RHAPSODY) && !defined(NEXTSTEP) && !defined(VMS)
+#if !defined(DARWIN) && !defined(NEXTSTEP) && !defined(VMS)
 #define GETCWD_CAN_MALLOC
 #endif
 
 #ifdef NEXTSTEP
 #include <bsd/libc.h>
 
 /*
 ** balazs.pataki@sztaki.hu: The getcwd is broken in NEXTSTEP (returns 0),
--- a/config/nspr-config.in
+++ b/config/nspr-config.in
@@ -102,15 +102,15 @@ if test "$echo_libs" = "yes"; then
       if test -n "$lib_plc"; then
 	libdirs="$libdirs -lplc${major_version}"
       fi
       if test -n "$lib_nspr"; then
 	libdirs="$libdirs -lnspr${major_version}"
       fi
       os_ldflags="@LDFLAGS@"
       for i in $os_ldflags ; do
-	if echo $i | grep ^-L >/dev/null; then
+	if echo $i | grep \^-L >/dev/null; then
 	  libdirs="$libdirs $i"
         fi
       done
       echo $libdirs @OS_LIBS@
 fi      
 
--- a/config/prdepend.h
+++ b/config/prdepend.h
@@ -34,8 +34,9 @@
 
 /*
  * A dummy header file that is a dependency for all the object files.
  * Used to force a full recompilation of NSPR in Mozilla's Tinderbox
  * depend builds.  See comments in rules.mk.
  */
 
 #error "Do not include this header file."
+
--- a/configure
+++ b/configure
@@ -13,17 +13,17 @@ ac_default_prefix=/usr/local
 # Any additions from configure.in:
 ac_help="$ac_help
   --with-dist-prefix=DIST_PREFIX
                           place build files in DIST_PREFIX [dist]"
 ac_help="$ac_help
   --with-dist-bindir=DIR  build execuatables in DIR [DIST_PREFIX/bin]"
 ac_help="$ac_help
   --with-dist-includedir=DIR
-                          build include files in DIR [DIST_PREFIX/include]"
+                          build include files in DIR [DIST_PREFIX/include/nspr]"
 ac_help="$ac_help
   --with-dist-libdir=DIR  build library files in DIR [DIST_PREFIX/lib]"
 ac_help="$ac_help
   --with-mozilla          Compile NSPR with Mozilla support"
 ac_help="$ac_help
   --enable-optimize(=val) Enable code optimizations (val, ie. -O2) "
 ac_help="$ac_help
   --disable-debug         Do not compile in debugging symbols"
@@ -722,28 +722,34 @@ case "$target" in
             _WIN32_MSVC=1
         fi
         rm -f dummy dummy.o dummy.obj dummy.exe dummy.c
     fi
     ;;
 *-msvc*)
     _WIN32_MSVC=1
     ;;
+*-mksnt*)
+    _WIN32_MSVC=1
+    ;;
 esac
 
 if test -n "$_WIN32_MSVC"; then
     SKIP_PATH_CHECKS=1
     SKIP_COMPILER_CHECKS=1
     SKIP_LIBRARY_CHECKS=1
 fi
 
 dist_prefix='${MOD_DEPTH}/dist'
 dist_bindir='${dist_prefix}/bin'
-dist_includedir='${dist_prefix}/include'
+dist_includedir='${dist_prefix}/include/nspr'
 dist_libdir='${dist_prefix}/lib'
+if test "${includedir}" = '${prefix}/include'; then
+    includedir='${prefix}/include/nspr'
+fi
 
 # Check whether --with-dist-prefix or --without-dist-prefix was given.
 if test "${with_dist_prefix+set}" = set; then
   withval="$with_dist_prefix"
   dist_prefix=$withval
 fi
 
 
@@ -949,17 +955,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:958: checking for $ac_word" >&5
+echo "configure:964: 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.
   ;;
   ?:/*)			 
@@ -1014,24 +1020,24 @@ 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:1023: checking for $host compiler" >&5
+echo "configure:1029: checking for $host compiler" >&5
     if test -z "$HOST_CC"; then
 	    for ac_prog in 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:1030: checking for $ac_word" >&5
+echo "configure:1036: 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"
@@ -1068,26 +1074,26 @@ test -n "$HOST_CC" || HOST_CC=""""
 	    HOST_LDFLAGS="$LDFLAGS"
     fi
 
     CC="$HOST_CC"
     CFLAGS="$HOST_CFLAGS"
     LDFLAGS="$HOST_LDFLAGS"
 
     echo $ac_n "checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1077: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
+echo "configure:1083: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
     cat > conftest.$ac_ext <<EOF
-#line 1079 "configure"
+#line 1085 "configure"
 #include "confdefs.h"
 
 int main() {
 return(0);
 ; return 0; }
 EOF
-if { (eval echo configure:1086: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1092: \"$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
@@ -1098,17 +1104,17 @@ rm -f conftest*
     LDFLAGS=$_SAVE_LDFLAGS
 
     if test -z "$CC"; then
 	    for ac_prog in "${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:1107: checking for $ac_word" >&5
+echo "configure:1113: 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"
@@ -1133,17 +1139,17 @@ test -n "$CC" && break
 done
 test -n "$CC" || CC="echo"
 
     fi
     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:1142: checking for $ac_word" >&5
+echo "configure:1148: 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"
@@ -1163,17 +1169,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:1172: checking for $ac_word" >&5
+echo "configure:1178: 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
@@ -1214,17 +1220,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:1223: checking for $ac_word" >&5
+echo "configure:1229: 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"
@@ -1246,33 +1252,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:1255: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1261: 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 1266 "configure"
+#line 1272 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1277: \"$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
@@ -1288,31 +1294,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:1297: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1303: 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:1302: checking whether we are using GNU C" >&5
+echo "configure:1308: 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:1311: \"$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:1317: \"$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
 
@@ -1321,17 +1327,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:1330: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1336: 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
@@ -1358,17 +1364,17 @@ else
 fi
 
     if test -z "$CXX"; then
 	    for ac_prog in "${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:1367: checking for $ac_word" >&5
+echo "configure:1373: 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"
@@ -1395,17 +1401,17 @@ test -n "$CXX" || CXX="echo"
 
     fi
     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:1404: checking for $ac_word" >&5
+echo "configure:1410: 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"
@@ -1427,33 +1433,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:1436: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:1442: 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 1447 "configure"
+#line 1453 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:1452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1458: \"$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
@@ -1469,31 +1475,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:1478: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1484: 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:1483: checking whether we are using GNU C++" >&5
+echo "configure:1489: 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:1492: \"$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:1498: \"$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
 
@@ -1502,17 +1508,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:1511: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:1517: 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
@@ -1539,17 +1545,17 @@ else
 fi
 
     if test -z "$RANLIB"; then
 	    for ac_prog in "${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:1548: checking for $ac_word" >&5
+echo "configure:1554: 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"
@@ -1576,17 +1582,17 @@ test -n "$RANLIB" || RANLIB="echo"
 
     fi
     if test -z "$AR"; then
 	    for ac_prog in "${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:1585: checking for $ac_word" >&5
+echo "configure:1591: 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"
@@ -1613,17 +1619,17 @@ test -n "$AR" || AR="echo"
 
     fi
     if test -z "$AS"; then
 	    for ac_prog in "${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:1622: checking for $ac_word" >&5
+echo "configure:1628: 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"
@@ -1650,17 +1656,17 @@ test -n "$AS" || AS="echo"
 
     fi
     if test -z "$LD"; then
 	    for ac_prog in "${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:1659: checking for $ac_word" >&5
+echo "configure:1665: 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"
@@ -1687,17 +1693,17 @@ test -n "$LD" || LD="echo"
 
     fi
     if test -z "$STRIP"; then
 	    for ac_prog in "${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:1696: checking for $ac_word" >&5
+echo "configure:1702: 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"
@@ -1724,17 +1730,17 @@ test -n "$STRIP" || STRIP="echo"
 
     fi
     if test -z "$DLLTOOL"; then
 	    for ac_prog in "${target_alias}-dlltool" "${target}-dlltool"
 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:1733: checking for $ac_word" >&5
+echo "configure:1739: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$DLLTOOL"; then
   ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
 else
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_dummy="$PATH"
@@ -1761,17 +1767,17 @@ test -n "$DLLTOOL" || DLLTOOL="echo"
 
     fi
     if test -z "$WINDRES"; then
 	    for ac_prog in "${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:1770: checking for $ac_word" >&5
+echo "configure:1776: 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"
@@ -1799,17 +1805,17 @@ test -n "$WINDRES" || WINDRES="echo"
     fi
 
 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:1808: checking for $ac_word" >&5
+echo "configure:1814: 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"
@@ -1831,33 +1837,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:1840: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:1846: 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 1851 "configure"
+#line 1857 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:1856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1862: \"$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
@@ -1873,31 +1879,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:1882: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1888: 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:1887: checking whether we are using GNU C++" >&5
+echo "configure:1893: 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:1896: \"$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:1902: \"$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
 
@@ -1906,17 +1912,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:1915: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:1921: 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
@@ -1943,17 +1949,17 @@ else
 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:1952: checking for $ac_word" >&5
+echo "configure:1958: 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"
@@ -1973,17 +1979,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:1982: checking for $ac_word" >&5
+echo "configure:1988: 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
@@ -2024,17 +2030,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:2033: checking for $ac_word" >&5
+echo "configure:2039: 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"
@@ -2056,33 +2062,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:2065: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:2071: 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 2076 "configure"
+#line 2082 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:2081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2087: \"$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
@@ -2098,31 +2104,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:2107: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2113: 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:2112: checking whether we are using GNU C" >&5
+echo "configure:2118: 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:2121: \"$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:2127: \"$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
 
@@ -2131,17 +2137,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:2140: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:2146: 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
@@ -2164,72 +2170,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:2173: checking how to run the C preprocessor" >&5
+echo "configure:2179: 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 2188 "configure"
+#line 2194 "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:2194: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2200: \"$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 2205 "configure"
+#line 2211 "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:2211: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2217: \"$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 2222 "configure"
+#line 2228 "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:2228: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2234: \"$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*
@@ -2246,17 +2252,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:2255: checking for $ac_word" >&5
+echo "configure:2261: 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"
@@ -2278,17 +2284,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:2287: checking for $ac_word" >&5
+echo "configure:2293: 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.
   ;;
   ?:/*)			 
@@ -2319,17 +2325,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:2328: checking for $ac_word" >&5
+echo "configure:2334: 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.
   ;;
   ?:/*)			 
@@ -2360,17 +2366,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:2369: checking for $ac_word" >&5
+echo "configure:2375: 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.
   ;;
   ?:/*)			 
@@ -2401,17 +2407,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:2410: checking for $ac_word" >&5
+echo "configure:2416: 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.
   ;;
   ?:/*)			 
@@ -2442,17 +2448,17 @@ test -n "$STRIP" && break
 done
 test -n "$STRIP" || STRIP="echo not_strip"
 
     for ac_prog in dlltool
 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:2451: checking for $ac_word" >&5
+echo "configure:2457: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_DLLTOOL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$DLLTOOL" in
   /*)
   ac_cv_path_DLLTOOL="$DLLTOOL" # Let the user override the test with a path.
   ;;
   ?:/*)			 
@@ -2483,17 +2489,17 @@ test -n "$DLLTOOL" && break
 done
 test -n "$DLLTOOL" || DLLTOOL="echo not_dlltool"
 
     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:2492: checking for $ac_word" >&5
+echo "configure:2498: 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.
   ;;
   ?:/*)			 
@@ -2549,17 +2555,17 @@ fi
 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:2558: checking for $ac_word" >&5
+echo "configure:2564: 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.
   ;;
   ?:/*)			 
@@ -2682,17 +2688,17 @@ elif test "$OS_ARCH" = "Windows_NT"; the
 # 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.
 #
     OS_ARCH=WINNT
-#    OS_MINOR_RELEASE=`uname -v`
+    OS_MINOR_RELEASE=`uname -v`
     if test "$OS_MINOR_RELEASE" = "00"; then
         OS_MINOR_RELEASE=0
     fi
     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
     CPU_ARCH=`uname -m`
     #
     # MKS's uname -m returns "586" on a Pentium machine.
     #
@@ -2743,17 +2749,17 @@ 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*)
+*-mingw*|*-cygwin*|*-msvc*|*-mksnt*)
     ;;
 *-beos*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
     ;;
 *os2*)
     ;;
 *)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
@@ -2773,27 +2779,27 @@ EOF
 
     cat >> confdefs.h <<\EOF
 #define SYSV 1
 EOF
 
     DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall'
     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:2782: checking for sys/atomic_op.h" >&5
+echo "configure:2788: 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 2787 "configure"
+#line 2793 "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:2792: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2798: \"$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
@@ -3089,16 +3095,55 @@ EOF
 #define _PR_STAT_HAS_ST_ATIMESPEC 1
 EOF
 
         ;;
     esac
 
     ;;
 
+*-darwin*)
+    cat >> confdefs.h <<\EOF
+#define XP_UNIX 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define DARWIN 1
+EOF
+
+    cat >> confdefs.h <<\EOF
+#define HAVE_BSD_FLOCK 1
+EOF
+
+    CFLAGS="$CFLAGS -Wmost -fno-common -pipe"
+    if echo $OS_TEST | grep -c 86 2>/dev/null; then
+        CFLAGS="$CFLAGS -mno-486"
+        cat >> confdefs.h <<\EOF
+#define i386 1
+EOF
+
+        CPU_ARCH=i386
+    else
+        cat >> confdefs.h <<\EOF
+#define ppc 1
+EOF
+
+        CPU_ARCH=ppc
+    fi
+    DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@'
+    # Use the standard preprocessor (cpp)
+    CFLAGS="$CFLAGS -traditional-cpp"
+    MKSHLIB='$(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -o $@'
+    STRIP="$STRIP -x -S"
+    DLL_SUFFIX=dylib
+    USE_PTHREADS=1
+    MDCPUCFG_H=_darwin.cfg
+    PR_MD_CSRCS=darwin.c
+    ;;
+
 *-dgux*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define _PR_LOCAL_THREADS_ONLY 1
 EOF
@@ -3228,17 +3273,17 @@ EOF
 
     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
         cat >> confdefs.h <<\EOF
 #define HAVE_INT_LOCALTIME_R 1
 EOF
 
     fi
 
-    if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00)' >/dev/null; then
+    if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00|B.11.11)' >/dev/null; then
         cat >> confdefs.h <<\EOF
 #define HAVE_POINTER_LOCALTIME_R 1
 EOF
 
     fi
 
     if test "$OS_RELEASE" = "B.10.01"; then
         cat >> confdefs.h <<\EOF
@@ -3287,17 +3332,17 @@ EOF
 
         if test -z "$GNU_CC"; then
             CFLAGS="$CFLAGS +DAportable +DS1.1"
             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
         fi
         DEFAULT_IMPL_STRATEGY=_PTH
     fi
 
-    if test "$OS_RELEASE" = "B.11.00"; then
+    if echo "$OS_RELEASE" | egrep '^(B.11.00|B.11.11)' >/dev/null; then
         cat >> confdefs.h <<\EOF
 #define HPUX10 1
 EOF
 
         cat >> confdefs.h <<\EOF
 #define HPUX11 1
 EOF
 
@@ -3552,17 +3597,17 @@ EOF
         # bug in the 68060 which causes gcc to crash.  The simplest way to
         # avoid this is to enable a minimum level of optimization.
         #
         _DEBUG_FLAGS="$_DEBUG_FLAGS -O"
         ;;
     esac    
     ;;
 
-*-mingw*|*-cygwin*|*-msvc*)
+*-mingw*|*-cygwin*|*-msvc*|*-mksnt*)
     cat >> confdefs.h <<\EOF
 #define XP_PC 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define WIN32 1
 EOF
 
@@ -3912,26 +3957,22 @@ EOF
 EOF
 
     cat >> confdefs.h <<\EOF
 #define HAVE_POINTER_LOCALTIME_R 1
 EOF
 
     MDCPUCFG_H=_nto.cfg
     PR_MD_CSRCS=nto.c
-    MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -M -o $(@:$(OBJDIR)/%.so=%.so)'
-    CFLAGS="$CFLAGS -Wc,-Wall -Wc,-Wno-parentheses -shared"
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
+    DSO_CFLAGS=-fPIC
+    DSO_LDOPTS=-shared
     OS_LIBS="$OS_LIBS -lsocket"
     _OPTIMIZE_FLAGS="-O1"
-    _DEBUG_FLAGS="-O1 -gstabs"
-    CC="qcc -Vgcc_ntox86 -w"
-    CXX='$(CC)'
-    LD="qcc -Vgcc_ntox86 -nostdlib"
-    AR="qcc -Vgcc_ntox86 -M -a $@"
-    AR_FLAGS=
+    _DEBUG_FLAGS="-gstabs"
 	;;
 
 *-openbsd*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
     cat >> confdefs.h <<\EOF
@@ -4005,27 +4046,27 @@ EOF
 EOF
 
     cat >> confdefs.h <<\EOF
 #define _REENTRANT 1
 EOF
 
     ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6
-echo "configure:4014: checking for machine/builtins.h" >&5
+echo "configure:4055: 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 4019 "configure"
+#line 4060 "configure"
 #include "confdefs.h"
 #include <machine/builtins.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4024: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4065: \"$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
@@ -4096,52 +4137,16 @@ EOF
 #define _PR_NEED_H_ERRNO 1
 EOF
 
     USE_NSPR_THREADS=1
     MDCPUCFG_H=_qnx.cfg
     PR_MD_CSRCS=qnx.c
     ;;
 
-*-darwin*)
-    cat >> confdefs.h <<\EOF
-#define XP_UNIX 1
-EOF
-
-    cat >> confdefs.h <<\EOF
-#define RHAPSODY 1
-EOF
-
-    cat >> confdefs.h <<\EOF
-#define HAVE_BSD_FLOCK 1
-EOF
-
-    CFLAGS="$CFLAGS -Wmost -fno-common -pipe"    
-    if echo $OS_TEST | grep -c 86 2>/dev/null; then
-        CFLAGS="$CFLAGS -mno-486"
-        cat >> confdefs.h <<\EOF
-#define i386 1
-EOF
-
-        CPU_ARCH=i386
-    else
-        cat >> confdefs.h <<\EOF
-#define ppc 1
-EOF
-
-        CPU_ARCH=ppc
-    fi
-    DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load'
-    MKSHLIB='$(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -o $@'
-    DLL_SUFFIX=dylib
-    USE_PTHREADS=1
-    MDCPUCFG_H=_rhapsody.cfg
-    PR_MD_CSRCS=rhapsody.c
-    ;;
-
 *-*-sco*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define SCO 1
 EOF
@@ -4562,22 +4567,22 @@ EOF
 
     ;;
    
 esac
 
 if test -z "$SKIP_LIBRARY_CHECKS"; then
 
 echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:4571: checking for dlopen" >&5
+echo "configure:4576: checking for dlopen" >&5
 if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4576 "configure"
+#line 4581 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dlopen(); 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 dlopen();
@@ -4590,17 +4595,17 @@ int main() {
 #if defined (__stub_dlopen) || defined (__stub___dlopen)
 choke me
 #else
 dlopen();
 #endif
 
 ; return 0; }
 EOF
-if { (eval echo configure:4599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4604: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_dlopen=yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   eval "ac_cv_func_dlopen=no"
 fi
@@ -4609,36 +4614,36 @@ fi
 
 if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   :
 else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:4618: checking for dlopen in -ldl" >&5
+echo "configure:4623: 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 4626 "configure"
+#line 4631 "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:4637: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4642: \"$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
@@ -4656,23 +4661,23 @@ fi
 
 fi
 
 
 
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:4665: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:4670: 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 4671 "configure"
+#line 4676 "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
@@ -4680,17 +4685,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 4689 "configure"
+#line 4694 "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
@@ -4704,22 +4709,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:4713: checking for $ac_func" >&5
+echo "configure:4718: 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 4718 "configure"
+#line 4723 "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();
@@ -4732,17 +4737,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:4741: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4746: \"$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
@@ -4770,17 +4775,17 @@ if test "${enable_strip+set}" = set; the
    ENABLE_STRIP=1 
 fi
 
 
 
 
 
 echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:4779: checking for pthread_create in -lpthreads" >&5
+echo "configure:4784: checking for pthread_create in -lpthreads" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { int a = 1;  } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -4792,17 +4797,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:4801: checking for pthread_create in -lpthread" >&5
+echo "configure:4806: checking for pthread_create in -lpthread" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { int a = 1;  } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -4814,17 +4819,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:4823: checking for pthread_create in -lc_r" >&5
+echo "configure:4828: checking for pthread_create in -lc_r" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { int a = 1;  } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -4836,17 +4841,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:4845: checking for pthread_create in -lc" >&5
+echo "configure:4850: checking for pthread_create in -lc" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { int a = 1;  } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -4986,33 +4991,33 @@ 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:4995: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5000: 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
 	    CFLAGS="$CFLAGS -pthread"
 	    CXXFLAGS="$CXXFLAGS -pthread"
 	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:5011: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5016: 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
@@ -5162,17 +5167,17 @@ EOF
 *-linux*)
     if test -n "$USE_NSPR_THREADS"; then
         cat >> confdefs.h <<\EOF
 #define _PR_LOCAL_THREADS_ONLY 1
 EOF
 
     fi
     ;;
-*-mingw*|*-cygwin*|*-uwin*|*-msvc*)
+*-mingw*|*-cygwin*|*-msvc*|*-mksnt*)
         USE_PTHREADS=
     _PTHREAD_LDFLAGS=
     USE_USER_PTHREADS=
     ;;
 *-netbsd*)
     if test -n "$USE_NSPR_THREADS"; then
         cat >> confdefs.h <<\EOF
 #define _PR_LOCAL_THREADS_ONLY 1
@@ -5228,16 +5233,28 @@ EOF
             if test -n "$USE_64"; then
                 PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS_sparcv9.s"
             else
                 PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS_32.s"
             fi
         fi
     fi
     ;;
+*-nto*)
+    if test -n "$USE_PTHREADS"; then
+        cat >> confdefs.h <<\EOF
+#define _PR_HAVE_GETHOST_R 1
+EOF
+
+        cat >> confdefs.h <<\EOF
+#define _PR_HAVE_GETHOST_R_POINTER 1
+EOF
+
+    fi
+    ;;
 esac
 
 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
 
 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
     _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
 fi
 
@@ -5359,16 +5376,17 @@ config/autoconf.mk
 config/nsprincl.mk
 config/nsprincl.sh
 config/nspr-config
 lib/Makefile 
 lib/ds/Makefile 
 lib/libc/Makefile 
 lib/libc/include/Makefile 
 lib/libc/src/Makefile 
+lib/tests/Makefile
 pr/Makefile 
 pr/include/Makefile 
 pr/include/md/Makefile 
 pr/include/obsolete/Makefile 
 pr/include/private/Makefile 
 pr/src/Makefile 
 pr/src/io/Makefile 
 pr/src/linking/Makefile 
@@ -5463,17 +5481,17 @@ trap 'rm -f $CONFIG_STATUS conftest*; ex
 # Protect against Makefile macro expansion.
 cat > conftest.defs <<\EOF
 s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
 s%[ 	`~#$^&*(){}\\|;'"<>?]%\\&%g
 s%\[%\\&%g
 s%\]%\\&%g
 s%\$%$$%g
 EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '| tr '\015' ' '`
 rm -f conftest.defs
 
 
 # Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
 
 echo creating $CONFIG_STATUS
 rm -f $CONFIG_STATUS
--- a/configure.in
+++ b/configure.in
@@ -96,46 +96,52 @@ case "$target" in
             _WIN32_MSVC=1
         fi
         rm -f dummy dummy.o dummy.obj dummy.exe dummy.c
     fi
     ;;
 *-msvc*)
     _WIN32_MSVC=1
     ;;
+*-mksnt*)
+    _WIN32_MSVC=1
+    ;;
 esac
 
 if test -n "$_WIN32_MSVC"; then
     SKIP_PATH_CHECKS=1
     SKIP_COMPILER_CHECKS=1
     SKIP_LIBRARY_CHECKS=1
 fi
 
 dnl ========================================================
 dnl =
 dnl = Check options that may affect the compiler
 dnl =
 dnl ========================================================
 dist_prefix='${MOD_DEPTH}/dist'
 dist_bindir='${dist_prefix}/bin'
-dist_includedir='${dist_prefix}/include'
+dist_includedir='${dist_prefix}/include/nspr'
 dist_libdir='${dist_prefix}/lib'
+if test "${includedir}" = '${prefix}/include'; then
+    includedir='${prefix}/include/nspr'
+fi
 
 AC_ARG_WITH(dist-prefix,
     [  --with-dist-prefix=DIST_PREFIX
                           place build files in DIST_PREFIX [dist]],
     dist_prefix=$withval)
 
 AC_ARG_WITH(dist-bindir,
     [  --with-dist-bindir=DIR  build execuatables in DIR [DIST_PREFIX/bin]],
     dist_bindir=$withval)
 
 AC_ARG_WITH(dist-includedir,
     [  --with-dist-includedir=DIR
-                          build include files in DIR [DIST_PREFIX/include]],
+                          build include files in DIR [DIST_PREFIX/include/nspr]],
     dist_includedir=$withval)
 
 AC_ARG_WITH(dist-libdir,
     [  --with-dist-libdir=DIR  build library files in DIR [DIST_PREFIX/lib]],
     dist_libdir=$withval)
 
 AC_SUBST(dist_prefix)
 AC_SUBST(dist_bindir)
@@ -532,17 +538,17 @@ elif test "$OS_ARCH" = "Windows_NT"; the
 # 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.
 #
     OS_ARCH=WINNT
-#    OS_MINOR_RELEASE=`uname -v`
+    OS_MINOR_RELEASE=`uname -v`
     if test "$OS_MINOR_RELEASE" = "00"; then
         OS_MINOR_RELEASE=0
     fi
     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
     CPU_ARCH=`uname -m`
     #
     # MKS's uname -m returns "586" on a Pentium machine.
     #
@@ -597,17 +603,17 @@ fi
 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
 
 dnl ========================================================
 
 dnl ========================================================
 dnl Override of system specific host options
 dnl ========================================================
 case "$host" in
-*-mingw*|*-cygwin*|*-msvc*)
+*-mingw*|*-cygwin*|*-msvc*|*-mksnt*)
     ;;
 *-beos*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
     ;;
 *os2*)
     ;;
 *)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
@@ -773,16 +779,40 @@ case "$target" in
         AC_DEFINE(HAVE_DLL)
         AC_DEFINE(USE_DLFCN)
         AC_DEFINE(_PR_STAT_HAS_ST_ATIMESPEC)
         ;;
     esac
 
     ;;
 
+*-darwin*)
+    AC_DEFINE(XP_UNIX)
+    AC_DEFINE(DARWIN)
+    AC_DEFINE(HAVE_BSD_FLOCK)
+    CFLAGS="$CFLAGS -Wmost -fno-common -pipe"
+    if echo $OS_TEST | grep -c 86 2>/dev/null; then
+        CFLAGS="$CFLAGS -mno-486"
+        AC_DEFINE(i386)
+        CPU_ARCH=i386
+    else
+        AC_DEFINE(ppc)
+        CPU_ARCH=ppc
+    fi
+    DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@'
+    # Use the standard preprocessor (cpp)
+    CFLAGS="$CFLAGS -traditional-cpp"
+    MKSHLIB='$(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -o $@'
+    STRIP="$STRIP -x -S"
+    DLL_SUFFIX=dylib
+    USE_PTHREADS=1
+    MDCPUCFG_H=_darwin.cfg
+    PR_MD_CSRCS=darwin.c
+    ;;
+
 *-dgux*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
     AC_DEFINE(SVR4)
     AC_DEFINE(SYSV)
     AC_DEFINE(DGUX)
     AC_DEFINE(_DGUX_SOURCE)
     AC_DEFINE(_POSIX4A_DRAFT6_SOURCE)
@@ -855,17 +885,17 @@ case "$target" in
     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
         AC_DEFINE(_PR_NEED_H_ERRNO)
     fi
 
     if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
         AC_DEFINE(HAVE_INT_LOCALTIME_R)
     fi
 
-    if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00)' >/dev/null; then
+    if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00|B.11.11)' >/dev/null; then
         AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
     fi
 
     if test "$OS_RELEASE" = "B.10.01"; then
         AC_DEFINE(HPUX10)
         DEFAULT_IMPL_STRATEGY=_EMU
     fi
 
@@ -890,17 +920,17 @@ case "$target" in
         AC_DEFINE(HPUX10_30)
         if test -z "$GNU_CC"; then
             CFLAGS="$CFLAGS +DAportable +DS1.1"
             CXXFLAGS="$CXXFLAGS +DAportable +DS1.1"
         fi
         DEFAULT_IMPL_STRATEGY=_PTH
     fi
 
-    if test "$OS_RELEASE" = "B.11.00"; then
+    if echo "$OS_RELEASE" | egrep '^(B.11.00|B.11.11)' >/dev/null; then
         AC_DEFINE(HPUX10)
         AC_DEFINE(HPUX11)
         AC_DEFINE(_LARGEFILE64_SOURCE)
         AC_DEFINE(_PR_HAVE_OFF64_T)
         AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
         if test -z "$GNU_CC"; then
             if test -z "$USE_64"; then
                 CFLAGS="$CFLAGS +DAportable +DS2.0"
@@ -1078,17 +1108,17 @@ case "$target" in
         # bug in the 68060 which causes gcc to crash.  The simplest way to
         # avoid this is to enable a minimum level of optimization.
         #
         _DEBUG_FLAGS="$_DEBUG_FLAGS -O"
         ;;
     esac    
     ;;
 
-*-mingw*|*-cygwin*|*-msvc*)
+*-mingw*|*-cygwin*|*-msvc*|*-mksnt*)
     AC_DEFINE(XP_PC)
     AC_DEFINE(WIN32)
     PR_MD_ARCH_DIR=windows
     RESOLVE_LINK_SYMBOLS=1
 
     if test -n "$GNU_CC"; then
         AC_DEFINE(NONAMELESSUNION)
         MKSHLIB='$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@'
@@ -1315,26 +1345,22 @@ mips-sony-newsos*)
 
 *-nto*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(NTO)
     AC_DEFINE(_QNX_SOURCE)
     AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
     MDCPUCFG_H=_nto.cfg
     PR_MD_CSRCS=nto.c
-    MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -M -o $(@:$(OBJDIR)/%.so=%.so)'
-    CFLAGS="$CFLAGS -Wc,-Wall -Wc,-Wno-parentheses -shared"
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(notdir $@) -o $@'
+    DSO_CFLAGS=-fPIC
+    DSO_LDOPTS=-shared
     OS_LIBS="$OS_LIBS -lsocket"
     _OPTIMIZE_FLAGS="-O1"
-    _DEBUG_FLAGS="-O1 -gstabs"
-    CC="qcc -Vgcc_ntox86 -w"
-    CXX='$(CC)'
-    LD="qcc -Vgcc_ntox86 -nostdlib"
-    AR="qcc -Vgcc_ntox86 -M -a $@"
-    AR_FLAGS=
+    _DEBUG_FLAGS="-gstabs"
 	;;
 
 *-openbsd*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(OPENBSD)
     AC_DEFINE(HAVE_BSD_FLOCK)
     CFLAGS="$CFLAGS -ansi -Wall -pipe"
     CXXFLAGS="$CXXFLAGS -ansi -Wall -pipe"
@@ -1410,37 +1436,16 @@ 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
     ;;
 
-*-darwin*)
-    AC_DEFINE(XP_UNIX)
-    AC_DEFINE(RHAPSODY)
-    AC_DEFINE(HAVE_BSD_FLOCK)
-    CFLAGS="$CFLAGS -Wmost -fno-common -pipe"    
-    if echo $OS_TEST | grep -c 86 2>/dev/null; then
-        CFLAGS="$CFLAGS -mno-486"
-        AC_DEFINE(i386)
-        CPU_ARCH=i386
-    else
-        AC_DEFINE(ppc)
-        CPU_ARCH=ppc
-    fi
-    DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load'
-    MKSHLIB='$(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -o $@'
-    DLL_SUFFIX=dylib
-    USE_PTHREADS=1
-    MDCPUCFG_H=_rhapsody.cfg
-    PR_MD_CSRCS=rhapsody.c
-    ;;
-
 *-*-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'
@@ -2058,17 +2063,17 @@ case "$target" in
         fi
     fi
     ;;
 *-linux*)
     if test -n "$USE_NSPR_THREADS"; then
         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
     fi
     ;;
-*-mingw*|*-cygwin*|*-uwin*|*-msvc*)
+*-mingw*|*-cygwin*|*-msvc*|*-mksnt*)
     dnl win32 does not use pthreads
     USE_PTHREADS=
     _PTHREAD_LDFLAGS=
     USE_USER_PTHREADS=
     ;;
 *-netbsd*)
     if test -n "$USE_NSPR_THREADS"; then
         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
@@ -2104,16 +2109,22 @@ case "$target" in
             if test -n "$USE_64"; then
                 PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS_sparcv9.s"
             else
                 PR_MD_ASFILES="$PR_MD_ASFILES os_SunOS_32.s"
             fi
         fi
     fi
     ;;
+*-nto*)
+    if test -n "$USE_PTHREADS"; then
+        AC_DEFINE(_PR_HAVE_GETHOST_R)
+        AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
+    fi
+    ;;
 esac
 
 OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
 
 dnl If the user passed in arg to --enable-optimize,
 dnl make sure that we use it.
 if test -n "$_SAVE_OPTIMIZE_FLAGS"; then
     _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS"
@@ -2243,16 +2254,17 @@ config/autoconf.mk
 config/nsprincl.mk
 config/nsprincl.sh
 config/nspr-config
 lib/Makefile 
 lib/ds/Makefile 
 lib/libc/Makefile 
 lib/libc/include/Makefile 
 lib/libc/src/Makefile 
+lib/tests/Makefile
 pr/Makefile 
 pr/include/Makefile 
 pr/include/md/Makefile 
 pr/include/obsolete/Makefile 
 pr/include/private/Makefile 
 pr/src/Makefile 
 pr/src/io/Makefile 
 pr/src/linking/Makefile 
--- a/lib/libc/include/plstr.h
+++ b/lib/libc/include/plstr.h
@@ -13,16 +13,17 @@
  * 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) 1998-2000 Netscape Communications Corporation.  All
  * Rights Reserved.
  * 
  * Contributor(s):
+ *   Roland Mainz <roland mainz@informatik.med.uni-giessen.de>
  * 
  * 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
@@ -429,16 +430,38 @@ PL_strncasestr(const char *big, const ch
  * n characters of the big one, ignoring case.  It returns null if either string is
  * null.  It returns null if the length of the little string is greater than n.
  */
 
 PR_EXTERN(char *)
 PL_strncaserstr(const char *big, const char *little, PRUint32 max);
 
 /*
- * Things not (yet?) included: strspn/strcspn, strtok/strtok_r, strsep.
+ * PL_strtok_r
+ *
+ * Splits the string s1 into tokens, separated by one or more characters
+ * from the separator string s2.  The argument lasts points to a
+ * user-supplied char * pointer in which PL_strtok_r stores information
+ * for it to continue scanning the same string.
+ *
+ * In the first call to PL_strtok_r, s1 points to a string and the value
+ * of *lasts is ignored.  PL_strtok_r returns a pointer to the first
+ * token, writes '\0' into the character following the first token, and
+ * updates *lasts.
+ *
+ * In subsequent calls, s1 is null and lasts must stay unchanged from the
+ * previous call.  The separator string s2 may be different from call to
+ * call.  PL_strtok_r returns a pointer to the next token in s1.  When no
+ * token remains in s1, PL_strtok_r returns null.
+ */
+
+PR_EXTERN(char *)
+PL_strtok_r(char *s1, const char *s2, char **lasts);
+
+/*
+ * Things not (yet?) included: strspn/strcspn, strsep.
  * memchr, memcmp, memcpy, memccpy, index, rindex, bcmp, bcopy, bzero.
  * Any and all i18n/l10n stuff.
  */
 
 PR_END_EXTERN_C
 
 #endif /* _plstr_h */
--- a/lib/libc/src/Makefile.in
+++ b/lib/libc/src/Makefile.in
@@ -52,16 +52,17 @@ CSRCS =\
 	strdup.c  \
 	strcat.c  \
 	strcmp.c  \
 	strccmp.c \
 	strchr.c  \
 	strpbrk.c \
 	strstr.c  \
 	strcstr.c \
+	strtok.c  \
 	base64.c \
 	plerror.c \
 	plgetopt.c \
 	$(NULL)
 
 LIBRARY_NAME	= plc
 LIBRARY_VERSION	= $(MOD_MAJOR_VERSION)
 
new file mode 100644
--- /dev/null
+++ b/lib/libc/src/strtok.c
@@ -0,0 +1,86 @@
+/* -*- 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) 2001 Netscape Communications Corporation.  All
+ * Rights Reserved.
+ * 
+ * Contributor(s):
+ *   Roland Mainz <roland mainz@informatik.med.uni-giessen.de>
+ * 
+ * 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.
+ */
+
+#include "plstr.h"
+
+PR_IMPLEMENT(char *)
+PL_strtok_r(char *s1, const char *s2, char **lasts)
+{
+    const char *sepp;
+    int         c, sc;
+    char       *tok;
+
+    if( s1 == NULL )
+    {
+        if( *lasts == NULL )
+            return NULL;
+
+        s1 = *lasts;
+    }
+  
+    for( ; (c = *s1) != 0; s1++ )
+    {
+        for( sepp = s2 ; (sc = *sepp) != 0 ; sepp++ )
+        {
+            if( c == sc )
+                break;
+        }
+        if( sc == 0 )
+            break; 
+    }
+
+    if( c == 0 )
+    {
+        *lasts = NULL;
+        return NULL;
+    }
+  
+    tok = s1++;
+
+    for( ; (c = *s1) != 0; s1++ )
+    {
+        for( sepp = s2; (sc = *sepp) != 0; sepp++ )
+        {
+            if( c == sc )
+            {
+                *s1++ = '\0';
+                *lasts = s1;
+                return tok;
+            }
+        }
+    }
+    *lasts = NULL;
+    return tok;
+}
--- a/lib/tests/string.c
+++ b/lib/tests/string.c
@@ -2998,16 +2998,69 @@ PRBool test_030(void)
             }
         }
     }
 
     printf("PASS\n");
     return PR_TRUE;
 }
 
+/* PL_strtok_r */
+PRBool test_031(void)
+{
+    static const char *tokens[] = {
+        "wtc", "relyea", "nelsonb", "jpierre", "nicolson",
+        "ian.mcgreer", "kirk.erickson", "sonja.mirtitsch", "mhein"
+    };
+
+    static const char *seps[] = {
+        ", ", ",", " ", "\t", ",,,", " ,", "    ", " \t\t", ","
+    };
+
+    static const char s2[] = ", \t";
+
+    char string[ 1024 ];
+    char *s1;
+    char *token;
+    char *lasts;
+    unsigned int i;
+
+    printf("Test 031 (PL_strtok_r)    ..."); fflush(stdout);
+
+    /* Build the string. */
+    string[0] = '\0';
+    for( i = 0; i < sizeof(tokens)/sizeof(tokens[0]); i++ )
+    {
+        PL_strcat(string, tokens[i]);
+        PL_strcat(string, seps[i]);
+    }
+    
+    /* Scan the string for tokens. */
+    i = 0;
+    s1 = string;
+    while( (token = PL_strtok_r(s1, s2, &lasts)) != NULL)
+    {
+        if( PL_strcmp(token, tokens[i]) != 0 )
+        {
+            printf("FAIL wrong token scanned\n");
+            return PR_FALSE;
+        }
+        i++;
+        s1 = NULL;
+    }
+    if( i != sizeof(tokens)/sizeof(tokens[0]) )
+    {
+        printf("FAIL wrong number of tokens scanned\n");
+        return PR_FALSE;
+    }
+
+    printf("PASS\n");
+    return PR_TRUE;
+}
+
 int
 main
 (
     int     argc,
     char   *argv[]
 )
 {
     printf("Testing the Portable Library string functions:\n");
@@ -3039,16 +3092,17 @@ main
         && test_023()
         && test_024()
         && test_025()
         && test_026()
         && test_027()
         && test_028()
         && test_029()
         && test_030()
+        && test_031()
       )
     {
         printf("Suite passed.\n");
         return 0;
     }
     else
     {
         printf("Suite failed.\n");
index a0a17543ac92688733d1c3145654aaba60558ccf..ee949c268029e695628bdcacd0efa9b0ad21bd9d
GIT binary patch
literal 163973
zc%1EB34k0$)voTD-Q4#<NFYq^KwvisA%s<MlidUY+0ByOm=KQa?93!P$z06LhJe36
z`2`eE5D*W%Kmi5C6A!=(5kW-(1r-7c9)KvGsNjM5-`DkKre~&)+U&@NY`x@lzpZ{#
zU0wa^y;s$*sv_xhLI@EM!dNKG<Q2k9eNl)B4^!IL4bu<>Xh}z7o5I;_Je>`7WYarh
zk-QjE5EKT35cP)Gx36$v-#$ZFsY1*&iWPR<bwa#hAO2C2Ax6}<rBmTZ+WQU*#Yp2G
zb5HSH0ai|nj3)z+1xAWXh568_LNs4YiE9bFg*fu{LL4pR-{Qw&wDqH(h>_O$r}XO>
zVHmj(1_*<Mb@F+{Fv8)4BM3(ljv^dQIEHX6;W)xwgcAuT5l$wYLO7N15W;DMhZ0UF
zoI!XP;o%1AM2I5@Lxi&kXA{mLoJ%;5a6aJz!i9uK5*|gkh_H>Yop24|(S*kko=n(4
z*hsjTa0%g3!ea@S5gtdloNxu<34~3ArxR`@>>%7kcn0AX!m|j^COn65D`7Wb4`GBb
zO1O=1J7F(joNx!>PQnCXlJH!@EMbnY&ya5?FY4r*7vjQw6~{VaFe=~Z(1YQ^Rtwx*
z3@MUQ01ZPX7t>7p&qq*2h8xm-15iG1AXwSav5xZJv-$4*&&Qr$@sEwhRmKSOP30WM
zo`K(`493W8#rXEljt#A`p1$o39og8n`0grB!$IWg3VO_txrh;MvF!F(X#M`yYOzLf
zw_xkKlQ&0p#-p$jn>ssMM4f2}qeA$N;ycIdHOpVJCm6Oz8q1Gh9Y=2LSlf_st_Jx_
zJ{lgav_IlmUXOLAsCr7$I6`U@r0)_r+jH9)o%DiH_Ugz!Tl(BO-%<By7uEU&l|KnO
zKevV<1qN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F!G4-6C}6aWAK
--- a/pr/include/gencfg.c
+++ b/pr/include/gencfg.c
@@ -89,18 +89,18 @@
 #endif
 #if !defined(M_UNIX) && defined(_USLC_)
 #ifndef UNIXWARE
       error - UNIXWARE is not defined
 #endif
 #endif
 
 #if defined(__APPLE__)
-#ifndef RHAPSODY
-      error - RHAPSODY is not defined
+#ifndef DARWIN
+      error - DARWIN is not defined
 #endif
 #endif
 
 #if defined(__NeXT__)
 #ifndef NEXTSTEP
       error - NEXTSTEP is not defined
 #endif
 #endif
--- a/pr/include/md/Makefile.in
+++ b/pr/include/md/Makefile.in
@@ -36,34 +36,36 @@
 MOD_DEPTH	= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(MOD_DEPTH)/config/autoconf.mk
 
 HEADERS = $(wildcard $(srcdir)/*.h)
+CONFIGS = $(wildcard $(srcdir)/*.cfg)
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(MDCPUCFG_H)
 	$(INSTALL) -m 444 $(srcdir)/$(MDCPUCFG_H) $(dist_includedir)
+	$(INSTALL) -m 444 $(CONFIGS) $(HEADERS) $(dist_includedir)/md
 ifneq ($(OS_ARCH),OpenVMS)
 	mv -f $(dist_includedir)/$(MDCPUCFG_H) $(dist_includedir)/prcpucfg.h
 else
 # mv'ing a link causes the file itself to move, not the link.
 	rm -f $(dist_includedir)/$(MDCPUCFG_H)
 	rm -f $(dist_includedir)/prcpucfg.h
 	ln -fs $(srcdir)/$(MDCPUCFG_H) $(dist_includedir)/prcpucfg.h
 endif
 
 real_install::
 	$(NSINSTALL) -D $(DESTDIR)$(includedir)/md
 	cp $(srcdir)/$(MDCPUCFG_H) $(DESTDIR)$(includedir)/prcpucfg.h
-	$(NSINSTALL) -t -m 644 $(HEADERS) $(DESTDIR)$(includedir)/md
+	$(NSINSTALL) -t -m 644 $(CONFIG) $(HEADERS) $(DESTDIR)$(includedir)/md
 
 release:: export
 	@echo "Copying machine-dependent prcpucfg.h"
 	@if test -z "$(BUILD_NUMBER)"; then \
 		echo "BUILD_NUMBER must be defined"; \
 		false; \
 	fi
 	@if test ! -d $(RELEASE_INCLUDE_DIR); then \
--- a/pr/include/md/_darwin.cfg
+++ b/pr/include/md/_darwin.cfg
@@ -34,18 +34,18 @@
 
 #ifndef nspr_cpucfg___
 #define nspr_cpucfg___
 
 #ifndef XP_UNIX
 #define XP_UNIX
 #endif
 
-#ifndef RHAPOSDY
-#define RHAPOSDY
+#ifndef DARWIN
+#define DARWIN
 #endif
 
 #define PR_AF_INET6 30  /* same as AF_INET6 */
 
 #if defined(i386)
 #undef IS_BIG_ENDIAN
 #define  IS_LITTLE_ENDIAN 1
 #else
--- a/pr/include/md/_darwin.h
+++ b/pr/include/md/_darwin.h
@@ -27,25 +27,25 @@
  * 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.
  */
 
-#ifndef nspr_rhapsody_defs_h___
-#define nspr_rhapsody_defs_h___
+#ifndef nspr_darwin_defs_h___
+#define nspr_darwin_defs_h___
 
 #include "prthread.h"
 
 #include <sys/syscall.h>
 
-#define PR_LINKER_ARCH	"rhapsody"
-#define _PR_SI_SYSNAME  "RHAPSODY"
+#define PR_LINKER_ARCH	"darwin"
+#define _PR_SI_SYSNAME  "DARWIN"
 #ifdef i386
 #define _PR_SI_ARCHITECTURE "x86"
 #else
 #define _PR_SI_ARCHITECTURE "ppc"
 #endif
 #define PR_DLL_SUFFIX		".dylib"
 
 #define _PR_VMBASE              0x30000000
@@ -214,9 +214,9 @@ extern PRIntervalTime   _PR_UNIX_TicksPe
  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
  * unwrapped version.
  */
 #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
 
 /* For writev() */
 #include <sys/uio.h>
 
-#endif /* nspr_rhapsody_defs_h___ */
+#endif /* nspr_darwin_defs_h___ */
--- a/pr/include/md/_macos.h
+++ b/pr/include/md/_macos.h
@@ -115,34 +115,50 @@ struct _MDFileDesc {
 	PRBool      orderlyDisconnect;
 	PRBool      readReady;
 	PRBool      writeReady;
 	PRBool      exceptReady;
 	PRLock *    miscLock;
 	
 	/* Server sockets: listen bit tells the notifier func what to do */
 	PRBool		doListen;
-	
+
 	_MDSocketCallerInfo  misc;
 	_MDSocketCallerInfo  read;
 	_MDSocketCallerInfo  write;
-	_MDSocketCallerInfo  poll;
 };
 
 /*
 ** Iinitialization Related definitions
 */
 
 #define _MD_EARLY_INIT		_MD_EarlyInit
 #define _MD_FINAL_INIT		_MD_FinalInit
 
 /*
 ** Interrupts Related definitions
 */
 
+#define _MD_GET_INTSOFF()               (_pr_intsOff)
+
+#define _MD_INTSOFF(_is)                                  \
+    PR_BEGIN_MACRO                                        \
+        ENTER_CRITICAL_REGION();                          \
+        (_is) = _PR_MD_GET_INTSOFF();                     \
+        _PR_MD_SET_INTSOFF(1);                            \
+        LEAVE_CRITICAL_REGION();                          \
+    PR_END_MACRO
+
+#if TARGET_CARBON
+extern void _MD_SetIntsOff(PRInt32 ints);
+#define _MD_SET_INTSOFF(_val)           _MD_SetIntsOff(_val)
+#else /* not TARGET_CARBON */
+#define _MD_SET_INTSOFF(_val)           (_pr_intsOff = _val)
+#endif /* TARGET_CARBON */
+
 #define _MD_START_INTERRUPTS			_MD_StartInterrupts
 #define _MD_STOP_INTERRUPTS	    		_MD_StopInterrupts
 #define _MD_BLOCK_CLOCK_INTERRUPTS()
 #define _MD_UNBLOCK_CLOCK_INTERRUPTS()
 #define _MD_DISABLE_CLOCK_INTERRUPTS()
 #define _MD_ENABLE_CLOCK_INTERRUPTS()
 
 /*
@@ -233,26 +249,29 @@ extern PRStatus _MD_InitThread(PRThread 
     PR_BEGIN_MACRO				      					\
 	PR_DestroyCondVar(_thread->md.asyncIOCVar);			\
 	PR_DestroyLock(_thread->md.asyncIOLock);			\
     PR_END_MACRO
 
 
 /*
 ** Initialize the thread context preparing it to execute _main.
+** *sp = 0 zeros out the sp for the first stack frame so that
+** stack walking code can find the top of the stack.
 */
 #if defined(powerc) || defined(__powerc)
 #define _MD_INIT_CONTEXT(_thread, _sp, _main, _status)	\
     PR_BEGIN_MACRO				      					\
  	unsigned char *sp;									\
  	unsigned long *tvect;								\
 	long **jb = (_thread)->md.jb;		      			\
     *((PRBool *)_status) = PR_TRUE;              		\
 	(void) setjmp(jb);			      					\
     sp = INIT_STACKPTR(_sp);							\
+    *sp = 0;                                            \
     (_MD_GET_SP(_thread)) = (long) sp;   				\
 	tvect = (unsigned long *)_main;						\
     (_MD_GET_PC(_thread)) = (int) *tvect;   			\
     (_MD_GET_TOC(_thread)) = (int) *(tvect+1);   		\
 	_thread->no_sched = 0;                              \
     PR_END_MACRO
 #else
 #define _MD_INIT_CONTEXT(_thread, _sp, _main, _status)	\
@@ -622,9 +641,41 @@ extern PRStatus _MD_MemUnmap(void *addr,
 #define _MD_MEM_UNMAP _MD_MemUnmap
 
 extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
 #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
 
 extern void SetLogFileTypeCreator(const char *logFile);
 extern int _MD_mac_get_nonblocking_connect_error(PRInt32 osfd);
 
+
+/*
+ * Critical section support
+ */
+
+#define MAC_CRITICAL_REGIONS  TARGET_CARBON
+
+#if MAC_CRITICAL_REGIONS
+
+extern void InitCriticalRegion();
+extern void TermCriticalRegion();
+
+extern void EnterCritialRegion();
+extern void LeaveCritialRegion();
+
+#define INIT_CRITICAL_REGION()     InitCriticalRegion()
+#define TERM_CRITICAL_REGION()     TermCriticalRegion()
+
+#define ENTER_CRITICAL_REGION()     EnterCritialRegion()
+#define LEAVE_CRITICAL_REGION()     LeaveCritialRegion()
+
+#else
+
+#define INIT_CRITICAL_REGION()
+#define TERM_CRITICAL_REGION()
+
+#define ENTER_CRITICAL_REGION()
+#define LEAVE_CRITICAL_REGION()
+
+#endif
+
+
 #endif /* prmacos_h___ */
--- a/pr/include/md/_nto.h
+++ b/pr/include/md/_nto.h
@@ -57,16 +57,17 @@
 #define _PR_HAVE_SOCKADDR_LEN
 #undef  HAVE_BSD_FLOCK
 #define HAVE_FCNTL_FILE_LOCKING
 #define _PR_NO_LARGE_FILES
 #define _PR_STAT_HAS_ONLY_ST_ATIME
 #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
 #define _PR_HAVE_POSIX_SEMAPHORES
 
+#undef FD_SETSIZE
 #define FD_SETSIZE	4096
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/select.h>
 
 #undef  HAVE_STACK_GROWING_UP
 #define	HAVE_DLL
 #define	USE_DLFCN
--- a/pr/include/md/_pth.h
+++ b/pr/include/md/_pth.h
@@ -91,16 +91,62 @@
 #define _PT_PTHREAD_MUTEXATTR_DESTROY     pthread_mutexattr_destroy
 #define _PT_PTHREAD_MUTEX_INIT(m, a)      pthread_mutex_init(&(m), &(a))
 #define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))
 #define _PT_PTHREAD_CONDATTR_INIT         pthread_condattr_init
 #define _PT_PTHREAD_CONDATTR_DESTROY      pthread_condattr_destroy
 #define _PT_PTHREAD_COND_INIT(m, a)       pthread_cond_init(&(m), &(a))
 #endif
 
+/* The pthreads standard does not specify an invalid value for the
+ * pthread_t handle.  (0 is usually an invalid pthread identifier
+ * but there are exceptions, for example, DG/UX.)  These macros
+ * define a way to set the handle to or compare the handle with an
+ * invalid identifier.  These macros are not portable and may be
+ * more of a problem as we adapt to more pthreads implementations.
+ * They are only used in the PRMonitor functions.  Do not use them
+ * in new code.
+ *
+ * Unfortunately some of our clients depend on certain properties
+ * of our PRMonitor implementation, preventing us from replacing
+ * it by a portable implementation.
+ * - High-performance servers like the fact that PR_EnterMonitor
+ *   only calls PR_Lock and PR_ExitMonitor only calls PR_Unlock.
+ *   (A portable implementation would use a PRLock and a PRCondVar
+ *   to implement the recursive lock in a monitor and call both
+ *   PR_Lock and PR_Unlock in PR_EnterMonitor and PR_ExitMonitor.)
+ *   Unfortunately this forces us to read the monitor owner field
+ *   without holding a lock.
+ * - One way to make it safe to read the monitor owner field
+ *   without holding a lock is to make that field a PRThread*
+ *   (one should be able to read a pointer with a single machine
+ *   instruction).  However, PR_GetCurrentThread calls calloc if
+ *   it is called by a thread that was not created by NSPR.  The
+ *   malloc tracing tools in the Mozilla client use PRMonitor for
+ *   locking in their malloc, calloc, and free functions.  If
+ *   PR_EnterMonitor calls any of these functions, infinite
+ *   recursion ensues.
+ */
+#if defined(_PR_DCETHREADS)
+#define _PT_PTHREAD_INVALIDATE_THR_HANDLE(t) \
+	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)
+#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)
 #define _PT_PTHREAD_ATTR_INIT            pthread_attr_create
 #define _PT_PTHREAD_ATTR_DESTROY         pthread_attr_delete
 #define _PT_PTHREAD_CREATE(t, a, f, r)   pthread_create(t, a, f, r) 
 #define _PT_PTHREAD_KEY_CREATE           pthread_keycreate
 #define _PT_PTHREAD_ATTR_SETSCHEDPOLICY  pthread_attr_setsched
 #define _PT_PTHREAD_ATTR_GETSTACKSIZE(a, s) \
                                      (*(s) = pthread_attr_getstacksize(*(a)), 0)
@@ -194,17 +240,17 @@
  * Solaris doesn't seem to have macros for the min/max priorities.
  * The range of 0-127 is mentioned in the pthread_setschedparam(3T)
  * man pages, and pthread_setschedparam indeed allows 0-127.  However,
  * pthread_attr_setschedparam does not allow 0; it allows 1-127.
  */
 #define PT_PRIO_MIN            1
 #define PT_PRIO_MAX            127
 #elif defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
-	|| defined(BSDI) || defined(RHAPSODY) /* XXX */
+	|| defined(BSDI) || defined(DARWIN) /* 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.
@@ -227,15 +273,15 @@ extern int (*_PT_aix_yield_fcn)();
 #define _PT_PTHREAD_YIELD() \
     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(RHAPSODY)
+	|| defined(BSDI) || defined(NTO) || defined(DARWIN)
 #define _PT_PTHREAD_YIELD()            	sched_yield()
 #else
 #error "Need to define _PT_PTHREAD_YIELD for this platform"
 #endif
 
 #endif /* nspr_pth_defs_h_ */
--- a/pr/include/md/_unixos.h
+++ b/pr/include/md/_unixos.h
@@ -38,17 +38,17 @@
 /*
  * If FD_SETSIZE is not defined on the command line, set the default value
  * before include select.h
  */
 /*
  * Linux: FD_SETSIZE is defined in /usr/include/sys/select.h and should
  * not be redefined.
  */
-#if !defined(LINUX) && !defined(RHAPSODY) && !defined(NEXTSTEP)
+#if !defined(LINUX) && !defined(DARWIN) && !defined(NEXTSTEP)
 #ifndef FD_SETSIZE
 #define FD_SETSIZE  4096
 #endif
 #endif
 
 #include <unistd.h>
 #include <stddef.h>
 #include <sys/stat.h>
@@ -160,17 +160,17 @@ extern void _MD_unix_init_running_cpu(st
 ** work - it just means that we don't really have a functional
 ** redzone.
 */
 #include <sys/mman.h>
 #ifndef PROT_NONE
 #define PROT_NONE 0x0
 #endif
 
-#if defined(DEBUG) && !defined(RHAPSODY) && !defined(NEXTSTEP)
+#if defined(DEBUG) && !defined(DARWIN) && !defined(NEXTSTEP)
 #if !defined(SOLARIS)	
 #include <string.h>  /* for memset() */
 #define _MD_INIT_STACK(ts,REDZONE)					\
     PR_BEGIN_MACRO                 					\
 	(void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE);	\
 	(void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\
 			REDZONE, PROT_NONE);				\
     /*									\
--- a/pr/include/md/prosdep.h
+++ b/pr/include/md/prosdep.h
@@ -88,18 +88,18 @@ PR_BEGIN_EXTERN_C
 #include "md/_irix.h"
 
 #elif defined(LINUX)
 #include "md/_linux.h"
 
 #elif defined(OSF1)
 #include "md/_osf1.h"
 
-#elif defined(RHAPSODY)
-#include "md/_rhapsody.h"
+#elif defined(DARWIN)
+#include "md/_darwin.h"
 
 #elif defined(NEXTSTEP)
 #include "md/_nextstep.h"
 
 #elif defined(SOLARIS)
 #include "md/_solaris.h"
 
 #elif defined(SUNOS4)
--- a/pr/include/obsolete/protypes.h
+++ b/pr/include/obsolete/protypes.h
@@ -105,17 +105,17 @@ typedef PRUintn uint;
 typedef PRUint64 uint64;
 #endif
 
 /*
  * uint32
  */
 
 #if !defined(XP_BEOS) && !defined(VMS)
-#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2)
+#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO)
 typedef PRUint32 uint32;
 #else
 typedef unsigned long uint32;
 #endif
 #endif
 
 /*
  * uint16
@@ -145,17 +145,17 @@ typedef PRInt64 int64;
 /*
  * int32
  */
 
 #if !defined(XP_BEOS) && !defined(VMS) \
     && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
     && !defined(HPUX)
 #if !defined(WIN32) || !defined(_WINSOCK2API_)  /* defines its own "int32" */
-#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2)
+#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO)
 typedef PRInt32 int32;
 #else
 typedef long int32;
 #endif
 #endif
 #endif
 
 /*
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -323,18 +323,20 @@ NSPR_API(PRInt32)                      _
 
 #define _MD_CURRENT_CPU()               (_pr_currentCPU)
 #define _MD_SET_CURRENT_CPU(_cpu)       (_pr_currentCPU = (_cpu))
 #define _MD_CURRENT_THREAD()            (_pr_currentThread)
 #define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread))
 #define _MD_LAST_THREAD()               (_pr_lastThread)
 #define _MD_SET_LAST_THREAD(t)          (_pr_lastThread = t)
 
+#ifndef XP_MAC
 #define _MD_GET_INTSOFF()               (_pr_intsOff)
 #define _MD_SET_INTSOFF(_val)           (_pr_intsOff = _val)
+#endif
 
 
 /* The unbalanced curly braces in these two macros are intentional */
 #define _PR_LOCK_HEAP() { PRIntn _is; if (_pr_currentCPU) _PR_INTSOFF(_is);
 #define _PR_UNLOCK_HEAP() if (_pr_currentCPU) _PR_INTSON(_is); }
 
 #endif /* _PR_LOCAL_THREADS_ONLY */
 
@@ -369,22 +371,30 @@ extern PRInt32                  _native_
 
 #define _PR_THREAD_SWITCH_CPU(_thread, _newCPU)
 
 #define _PR_IS_NATIVE_THREAD(thread) 1
 #define _PR_IS_NATIVE_THREAD_SUPPORTED() 1
 
 #else
 
+#ifdef XP_MAC
+
+#define _PR_INTSOFF(_is)        _MD_INTSOFF(_is)
+
+#else /* XP_MAC */
+
 #define _PR_INTSOFF(_is) \
     PR_BEGIN_MACRO \
         (_is) = _PR_MD_GET_INTSOFF(); \
         _PR_MD_SET_INTSOFF(1); \
     PR_END_MACRO
 
+#endif /* XP_MAC */
+
 #define _PR_FAST_INTSON(_is) \
     PR_BEGIN_MACRO \
         _PR_MD_SET_INTSOFF(_is); \
     PR_END_MACRO
 
 #define _PR_INTSON(_is) \
     PR_BEGIN_MACRO \
         if ((_is == 0) && (_PR_MD_CURRENT_CPU())->u.bits) \
@@ -1445,17 +1455,17 @@ struct PRCondVar {
 };
 
 /************************************************************************/
 
 struct PRMonitor {
     const char* name;           /* monitor name for debugging */
 #if defined(_PR_PTHREADS)
     PRLock lock;                /* the lock structure */
-    PRThread *owner;            /* the owner of the lock or NULL */
+    pthread_t owner;            /* the owner of the lock or invalid */
     PRCondVar *cvar;            /* condition variable queue */
 #else  /* defined(_PR_PTHREADS) */
     PRCondVar *cvar;            /* associated lock and condition variable queue */
 #endif /* defined(_PR_PTHREADS) */
     PRUint32 entryCount;        /* # of times re-entered */
 };
 
 /************************************************************************/
@@ -1780,17 +1790,17 @@ extern PRLogModuleInfo *_pr_gc_lm;
 extern PRFileDesc *_pr_stdin;
 extern PRFileDesc *_pr_stdout;
 extern PRFileDesc *_pr_stderr;
 
 /* Overriding malloc, free, etc. */
 #if !defined(_PR_NO_PREEMPT) && defined(XP_UNIX) \
         && !defined(_PR_PTHREADS) && !defined(_PR_GLOBAL_THREADS_ONLY) \
         && !defined(PURIFY) \
-        && !defined(RHAPSODY) \
+        && !defined(DARWIN) \
         && !defined(NEXTSTEP) \
         && !defined(QNX) \
         && !(defined (UNIXWARE) && defined (USE_SVR4_THREADS))
 #define _PR_OVERRIDE_MALLOC
 #endif
 
 /*************************************************************************
 * External machine-dependent code provided by each OS.                     *                                                                     *
--- a/pr/src/Makefile.in
+++ b/pr/src/Makefile.in
@@ -64,23 +64,34 @@ endif
 #
 # Define platform-dependent OS_LIBS
 #
 
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OS_LIBS			= -lm
 else	# 4.1.3_U1
+
+#
+# In Solaris 2.6 or earlier, -lrt is called -lposix4.
+# 
+LIBRT_TEST=$(firstword $(sort 5.7 $(OS_RELEASE)))
+ifeq (5.7, $(LIBRT_TEST))
+LIBRT=-lrt
+else
+LIBRT=-lposix4
+endif
+
 ifdef USE_PTHREADS
-OS_LIBS			= -lpthread -lthread -lposix4 -lsocket -lnsl -ldl
+OS_LIBS			= -lpthread -lthread ${LIBRT} -lsocket -lnsl -ldl
 else
 ifdef LOCAL_THREADS_ONLY
 OS_LIBS			= -lsocket -lnsl -ldl
 else
-OS_LIBS			= -lthread -lposix4 -lsocket -lnsl -ldl
+OS_LIBS			= -lthread ${LIBRT} -lsocket -lnsl -ldl
 endif	# LOCAL_THREADS_ONLY
 endif	# USE_PTHREADS
 endif	# 4.1.3_U1
 endif	# SunOS
 
 ifeq ($(OS_ARCH), IRIX)
 ifeq ($(USE_PTHREADS), 1)
 OS_LIBS = -lpthread
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -80,17 +80,17 @@
 #endif
 #endif /* XP_UNIX */
 
 #define _PR_DEFAULT_LD_FLAGS PR_LD_LAZY
 
 /*
  * On these platforms, symbols have a leading '_'.
  */
-#if defined(SUNOS4) || defined(RHAPSODY) || defined(NEXTSTEP) \
+#if defined(SUNOS4) || defined(DARWIN) || defined(NEXTSTEP) \
     || defined(OPENBSD) || defined(WIN16) \
     || (defined(NETBSD) && !defined(__ELF__))
 #define NEED_LEADING_UNDERSCORE
 #endif
 
 #ifdef XP_PC
 typedef PRStaticLinkTable *NODL_PROC(void);
 #endif
@@ -743,17 +743,22 @@ pr_LoadLibraryByPathname(const char *nam
 
     }
 #endif
 
 #ifdef XP_UNIX
 #ifdef HAVE_DLL
     {
 #if defined(USE_DLFCN)
+#ifdef NTO
+    /* Neutrino needs RTLD_GROUP to load Netscape plugins. (bug 71179) */
+    int dl_flags = RTLD_GROUP;
+#else
     int dl_flags = 0;
+#endif
     void *h;
 
     if (flags & PR_LD_LAZY) {
         dl_flags |= RTLD_LAZY;
     }
     if (flags & PR_LD_NOW) {
         dl_flags |= RTLD_NOW;
     }
--- a/pr/src/md/beos/beos_errors.c
+++ b/pr/src/md/beos/beos_errors.c
@@ -171,22 +171,16 @@ void _MD_unix_map_unlink_error(int err)
 			PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
 			break;
 		case EPERM:
 			PR_SetError(PR_IS_DIRECTORY_ERROR, err);
 			break;
 		case EROFS:
 			PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
 			break;
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY) && !defined(BEOS)
-		case EMULTIHOP:
-		case ENOLINK:
-			PR_SetError(PR_REMOTE_FILE_ERROR, err);
-			break;
-#endif
 		default:
 			PR_SetError(PR_UNKNOWN_ERROR, err);
 			break;
 	}
 }
 
 void _MD_unix_map_stat_error(int err)
 {
@@ -196,20 +190,16 @@ void _MD_unix_map_stat_error(int err)
 			break;
 		case EFAULT:
 			PR_SetError(PR_ACCESS_FAULT_ERROR, err);
 			break;
 		case EINTR:
 			PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
 			break;
 		case ETIMEDOUT:
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY) && !defined(BEOS)
-		case EMULTIHOP:
-		case ENOLINK:
-#endif
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 		case ELOOP:
 			PR_SetError(PR_LOOP_ERROR, err);
 			break;
 		case ENAMETOOLONG:
 			PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
 			break;
@@ -289,22 +279,16 @@ void _MD_unix_map_rename_error(int err)
 			PR_SetError(PR_IO_ERROR, err);
 			break;
 		case EISDIR:
 			PR_SetError(PR_IS_DIRECTORY_ERROR, err);
 			break;
 		case ELOOP:
 			PR_SetError(PR_LOOP_ERROR, err);
 			break;
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY) && !defined(BEOS)
-		case EMULTIHOP:
-		case ENOLINK:
-			PR_SetError(PR_REMOTE_FILE_ERROR, err);
-			break;
-#endif
 		case ENAMETOOLONG:
 			PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
 			break;
 		case ENOENT:
 			PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
 			break;
 		case ENOSPC:
 			PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err);
@@ -340,20 +324,16 @@ void _MD_unix_map_access_error(int err)
 			PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
 			break;
 		case EINVAL:
 			PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
 			break;
 		case ELOOP:
 			PR_SetError(PR_LOOP_ERROR, err);
 			break;
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY) && !defined(BEOS)
-		case EMULTIHOP:
-		case ENOLINK:
-#endif
 		case ETIMEDOUT:
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 		case ENAMETOOLONG:
 			PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
 			break;
 		case ENOENT:
 			PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
@@ -406,22 +386,16 @@ void _MD_unix_map_mkdir_error(int err)
 #ifdef EDQUOT
 		case EDQUOT:
 			PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err);
 			break;
 #endif
 		case EIO:
 			PR_SetError(PR_IO_ERROR, err);
 			break;
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY) && !defined(BEOS)
-		case EMULTIHOP:
-		case ENOLINK:
-			PR_SetError(PR_REMOTE_FILE_ERROR, err);
-			break;
-#endif
 		default:
 			PR_SetError(PR_UNKNOWN_ERROR, err);
 			break;
 	}
 }
 
 void _MD_unix_map_rmdir_error(int err)
 {
@@ -443,20 +417,16 @@ void _MD_unix_map_rmdir_error(int err)
 			PR_SetError(PR_DIRECTORY_NOT_EMPTY_ERROR, err);
 			break;
 		case EIO:
 			PR_SetError(PR_IO_ERROR, err);
 			break;
 		case ELOOP:
 			PR_SetError(PR_LOOP_ERROR, err);
 			break;
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY) && !defined(BEOS)
-		case EMULTIHOP:
-		case ENOLINK:
-#endif
 		case ETIMEDOUT:
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 		case ENAMETOOLONG:
 			PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
 			break;
 		case ENOENT:
 			PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
@@ -1392,20 +1362,16 @@ void _MD_unix_map_open_error(int err)
 			break;
 		case ENOTDIR:
 			PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
 			break;
 		case EPERM:
 			PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
 			break;
 		case ETIMEDOUT:
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY) && !defined(BEOS)
-		case EMULTIHOP:
-		case ENOLINK:
-#endif
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 		case EROFS:
 			PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
 			break;
 		default:
 			PR_SetError(PR_UNKNOWN_ERROR, err);
 			break;
--- a/pr/src/md/mac/macio.c
+++ b/pr/src/md/mac/macio.c
@@ -86,30 +86,31 @@ struct ExtendedParamBlock {
 typedef struct ExtendedParamBlock ExtendedParamBlock;
 
 
 /* XXX Not done yet for 68K */
 /* I/O completion routne for _MD_READ and _MD_WRITE */
 static void AsyncIOCompletion (ExtendedParamBlock *pbAsyncPtr)
 {
     _PRCPU *cpu = _PR_MD_CURRENT_CPU();
-	PRThread *thread = pbAsyncPtr->thread;
-
+    PRThread *thread = pbAsyncPtr->thread;    
+    PRIntn is;
+    
     if (_PR_MD_GET_INTSOFF()) {
+        thread->md.missedIONotify = PR_TRUE;
         cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
-        thread->md.missedIONotify = PR_TRUE;
-		return;
+        return;
     }
-    _PR_MD_SET_INTSOFF(1);
+
+    _PR_INTSOFF(is);
 
-	thread->md.osErrCode = noErr;
-	DoneWaitingOnThisThread(thread);
+    thread->md.osErrCode = noErr;
+    DoneWaitingOnThisThread(thread);
 
-    _PR_MD_SET_INTSOFF(0);
-
+    _PR_FAST_INTSON(is);
 }
 
 void  _MD_SetError(OSErr oserror)
 {
     PRErrorCode code;
 
     switch (oserror) {
       case memFullErr:
@@ -242,19 +243,19 @@ void _MD_IOInterrupt(void)
 ** All PR_read and PR_Write calls are synchronous from caller's perspective.
 ** They are internally made asynchronous calls.  This gives cpu to other
 ** user threads while the async io is in progress.
 */
 PRInt32 ReadWriteProc(PRFileDesc *fd, void *buf, PRUint32 bytes, IOOperation op)
 {
 	PRInt32 refNum = fd->secret->md.osfd;
 	OSErr				err;
- 	ExtendedParamBlock 	pbAsync;
+	ExtendedParamBlock 	pbAsync;
 	PRThread			*me = _PR_MD_CURRENT_THREAD();
-    _PRCPU *cpu = _PR_MD_CURRENT_CPU();
+	_PRCPU *cpu = _PR_MD_CURRENT_CPU();
 
 	/* quick hack to allow PR_fprintf, etc to work with stderr, stdin, stdout */
 	/* note, if a user chooses "seek" or the like as an operation in another function */
 	/* this will not work */
 	if (refNum >= 0 && refNum < 3)
 	{
 		switch (refNum)
 		{
@@ -265,22 +266,23 @@ PRInt32 ReadWriteProc(PRFileDesc *fd, vo
 					break;
 				case 1: /* stdout */
 				case 2: /* stderr */
 					puts(buf);
 					break;
 		}
 		
 		return (bytes);
-
 	}
 	else
 	{
 		static IOCompletionUPP	sCompletionUPP = NULL;
 		
+		PRBool  doingAsync = PR_FALSE;
+		
 		/* allocate the callback Universal Procedure Pointer (UPP). This actually allocates
 		   a 32 byte Ptr in the heap, so only do this once
 		*/
 		if (!sCompletionUPP)
 			sCompletionUPP = NewIOCompletionProc((IOCompletionProcPtr)&AsyncIOCompletion);
 			
 		/* grab the thread so we know which one to post to at completion */
 		pbAsync.thread	= me;
@@ -291,77 +293,73 @@ PRInt32 ReadWriteProc(PRFileDesc *fd, vo
 		pbAsync.pb.ioParam.ioBuffer		= buf;
 		pbAsync.pb.ioParam.ioReqCount	= bytes;
 		pbAsync.pb.ioParam.ioPosMode	= fsAtMark;
 		pbAsync.pb.ioParam.ioPosOffset	= 0;
 
 		/* 
 		** Issue the async read call and wait for the io semaphore associated
 		** with this thread.
-		** Don't compute error code from async call. Bug in OS returns a garbage value.
+		** Async file system calls *never* return error values, so ignore their
+		** results (see <http://developer.apple.com/technotes/fl/fl_515.html>);
+		** the completion routine is always called.
 		*/
-	    me->io_fd = refNum;
+		me->io_fd = refNum;
 		me->md.osErrCode = noErr;
 		if (op == READ_ASYNC)
 		{
 			/*
 			**  Skanky optimization so that reads < 20K are actually done synchronously
 			**  to optimize performance on small reads (e.g. registry reads on startup)
 			*/
 			if ( bytes > 20480L )
 			{
-				err = PBReadAsync(&pbAsync.pb);
-				if (err != noErr && err != eofErr)
-					goto ErrorExit;
+				doingAsync = PR_TRUE;
+				me->io_pending = PR_TRUE;
 				
-	   			me->io_pending = PR_TRUE; /* Only mark thread io pending if async call worked */
+				(void)PBReadAsync(&pbAsync.pb);
 			}
 			else
 			{
-				(void) PBReadSync(&pbAsync.pb);
-				/*
-				** This is probbaly redundant but want to make sure we indicate the read
-				** is complete so we don't wander off into the Sargasso Sea of Mac
-				** threading
-				*/
-				pbAsync.pb.ioParam.ioResult = 0;
+				pbAsync.pb.ioParam.ioCompletion = NULL;
+				me->io_pending = PR_FALSE;
+				
+				err = PBReadSync(&pbAsync.pb);
+				if (err != noErr && err != eofErr)
+					goto ErrorExit;
 			}
 		}
 		else
 		{
+			doingAsync = PR_TRUE;
+			me->io_pending = PR_TRUE;
+
 			/* writes are currently always async */
-			err = PBWriteAsync(&pbAsync.pb);
-				if (err != noErr)
-					goto ErrorExit;
-			
-			/* Didn't get an error on the asyn call so mark thread io pending */
-	   		me->io_pending = PR_TRUE;
+			(void)PBWriteAsync(&pbAsync.pb);
 		}
 		
-		/* See if the i/o call is still pending before we actually yield */
-		if (pbAsync.pb.ioParam.ioResult == 1)
+		if (doingAsync) {
 			WaitOnThisThread(me, PR_INTERVAL_NO_TIMEOUT);
-		else
-			me->io_pending = PR_FALSE; /* io completed so don't mark thread io pending */
+		}
 	}
 	
 	err = me->md.osErrCode;
 	if (err != noErr)
 		goto ErrorExit;
 
 	err = pbAsync.pb.ioParam.ioResult;
 	if (err != noErr && err != eofErr)
 		goto ErrorExit;
-	else
-		return pbAsync.pb.ioParam.ioActCount;
+	
+	return pbAsync.pb.ioParam.ioActCount;
 
 ErrorExit:
 	me->md.osErrCode = err;
 	_MD_SetError(err);
-    return -1;
+	return -1;
 }
 
 /*
 Special WriteSyncProc for logging only.  IO occurs synchronously.  Otherwise,
 logging internal to NSPR causes ReadWriteProc above to recurse on PR_WaitSem logging.
 */
 PRInt32 WriteSyncProc(PRFileDesc *fd, void *buf, PRUint32 bytes)
 {
--- a/pr/src/md/mac/macrng.c
+++ b/pr/src/md/mac/macrng.c
@@ -28,23 +28,16 @@
  * 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.
  */
 
 
-#if 0 /* XXX what the flip is this all about? No MAC Wizards here. */
-#ifdef notdef
-#include "xp_core.h"
-#include "xp_file.h"
-#endif
-#endif /* 0 */
-
 /* XXX are all these headers required for a call to TickCount()? */
 #include <Events.h>
 #include <OSUtils.h>
 #include <QDOffscreen.h>
 #include <PPCToolbox.h>
 #include <Processes.h>
 #include <LowMem.h>
 #include "primpl.h"
--- a/pr/src/md/mac/macsockotpt.c
+++ b/pr/src/md/mac/macsockotpt.c
@@ -166,34 +166,34 @@ static pascal void  DNSNotifierRoutine(v
 	OSStatus    errOT;
 
 		dnsContext.thread->md.osErrCode = result;
 		dnsContext.cookie = cookie;
 	
 	switch (otEvent) {
 		case T_DNRSTRINGTOADDRCOMPLETE:
 				if (_PR_MD_GET_INTSOFF()) {
+					dnsContext.thread->md.missedIONotify = PR_TRUE;
 					cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
-					dnsContext.thread->md.missedIONotify = PR_TRUE;
 					return;
 				}
 				DoneWaitingOnThisThread(dnsContext.thread);
 				break;
 		
         case kOTProviderWillClose:
                 errOT = OTSetSynchronous(dnsContext.serviceRef);
                 // fall through to kOTProviderIsClosed case
 		
         case kOTProviderIsClosed:
                 errOT = OTCloseProvider((ProviderRef)dnsContext.serviceRef);
                 dnsContext.serviceRef = nil;
 
 				if (_PR_MD_GET_INTSOFF()) {
+					dnsContext.thread->md.missedIONotify = PR_TRUE;
 					cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
-					dnsContext.thread->md.missedIONotify = PR_TRUE;
 					return;
 				}
 				DoneWaitingOnThisThread(dnsContext.thread);
                 break;
 
         default: // or else we don't handle the event
 	            PR_ASSERT(otEvent==NULL);
 		
@@ -289,212 +289,208 @@ static void PrepareForAsyncCompletion(PR
 void
 WakeUpNotifiedThread(PRThread *thread, OTResult result)
 {
     _PRCPU *      cpu      = _PR_MD_CURRENT_CPU(); 
 
 	if (thread) {
 		thread->md.osErrCode = result;
 		if (_PR_MD_GET_INTSOFF()) {
+			thread->md.missedIONotify = PR_TRUE;
 			cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
-			thread->md.missedIONotify = PR_TRUE;
 			return;
 		}
 		DoneWaitingOnThisThread(thread);
 	}
 }
 
 // Notification routine
 // Async callback routine.
 // A5 is OK. Cannot allocate memory here
+// Ref: http://gemma.apple.com/techpubs/mac/NetworkingOT/NetworkingWOT-100.html
+//
 static pascal void  NotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
 {
-	PRFilePrivate *secret  = (PRFilePrivate *) contextPtr;
-	_MDFileDesc * md       = &(secret->md);
-	EndpointRef   endpoint = (EndpointRef)secret->md.osfd;
-    PRThread *    thread   = NULL;
-    PRThread *	  pollThread = md->poll.thread;
-	OSStatus      err;
-	OTResult	  resultOT;
-    TDiscon		  discon;
+    PRFilePrivate *secret  = (PRFilePrivate *) contextPtr;
+    _MDFileDesc * md       = &(secret->md);
+    EndpointRef   endpoint = (EndpointRef)secret->md.osfd;
+    PRThread *    readThread   = NULL;          // also used for 'misc'
+    PRThread *    writeThread  = NULL;
+    OSStatus      err;
+    OTResult      resultOT;
+    TDiscon       discon;
 
     switch (code)
     {
 // OTLook Events - 
         case T_LISTEN:        // A connection request is available
-        	// If md->doListen is true, then PR_Listen has been
-        	// called on this endpoint; therefore, we're ready to
-        	// accept connections. But we'll do that with PR_Accept
-        	// (which calls OTListen, OTAccept, etc) instead of 
-        	// doing it here. 
-        	if (md->doListen) {
-				thread = secret->md.misc.thread;
-	            secret->md.misc.thread    = NULL;
-	            secret->md.misc.cookie    = cookie;
-	            break;
-        	} else {
-        		// Reject the connection, we're not listening
-        		OTSndDisconnect(endpoint, NULL);
-        	}
+            // If md->doListen is true, then PR_Listen has been
+            // called on this endpoint; therefore, we're ready to
+            // accept connections. But we'll do that with PR_Accept
+            // (which calls OTListen, OTAccept, etc) instead of 
+            // doing it here. 
+            if (md->doListen) {
+                readThread = secret->md.misc.thread;
+                secret->md.misc.thread    = NULL;
+                secret->md.misc.cookie    = cookie;
+                break;
+            } else {
+                // Reject the connection, we're not listening
+                OTSndDisconnect(endpoint, NULL);
+            }
             break;
-			
+
         case T_CONNECT:      // Confirmation of a connect request
-			// cookie = sndCall parameter from OTConnect()
+            // cookie = sndCall parameter from OTConnect()
             err = OTRcvConnect(endpoint, NULL);
             PR_ASSERT(err == kOTNoError);
 
-			// wake up waiting thread, if any
-            thread = secret->md.write.thread;
+            // wake up waiting thread, if any.
+            writeThread = secret->md.write.thread;
             secret->md.write.thread    = NULL;
-            secret->md.write.cookie    = cookie;
+            secret->md.write.cookie    = cookie;            
             break;
 
         case T_DATA:        // Standard data is available
-			// Mark this socket as readable.
-			secret->md.readReady = PR_TRUE;
+            // Mark this socket as readable.
+            secret->md.readReady = PR_TRUE;
 
-			// wake up waiting thread, if any
-            thread = secret->md.read.thread;
+            // wake up waiting thread, if any
+            readThread = secret->md.read.thread;
             secret->md.read.thread    = NULL;
             secret->md.read.cookie    = cookie;
-			break;
+            break;
 
         case T_EXDATA:      // Expedited data is available
             PR_ASSERT(!"T_EXDATA Not implemented");
-			return;
+            return;
 
         case T_DISCONNECT:  // A disconnect is available
             discon.udata.len = 0;
             err = OTRcvDisconnect(endpoint, &discon);
             PR_ASSERT(err == kOTNoError);
-            secret->md.exceptReady     = PR_TRUE;
-
-			// wake up waiting threads, if any
-			result = -3199 - discon.reason; // obtain the negative error code
+            secret->md.exceptReady = PR_TRUE;       // XXX Check this
 
-            if ((thread = secret->md.read.thread) != NULL) {
-		        secret->md.read.thread    = NULL;
-    	        secret->md.read.cookie    = cookie;
-            	WakeUpNotifiedThread(thread, result);
-    	    }
-            
-            if ((thread = secret->md.write.thread) != NULL) {
-	            secret->md.write.thread    = NULL;
-	            secret->md.write.cookie    = cookie;
-	            WakeUpNotifiedThread(thread, result);
-	        }
-	        
-	        thread = NULL; // already took care of notification here
+            // wake up waiting threads, if any
+            result = -3199 - discon.reason; // obtain the negative error code
+            if ((readThread = secret->md.read.thread) != NULL) {
+                secret->md.read.thread    = NULL;
+                secret->md.read.cookie    = cookie;
+            }
+
+            if ((writeThread = secret->md.write.thread) != NULL) {
+                secret->md.write.thread    = NULL;
+                secret->md.write.cookie    = cookie;
+            }
             break;
-		
+
         case T_ERROR:       // obsolete/unused in library
             PR_ASSERT(!"T_ERROR Not implemented");
-			return;		
-		
+            return;
+
         case T_UDERR:       // UDP Send error; clear the error
-			(void) OTRcvUDErr((EndpointRef) cookie, NULL);
+            (void) OTRcvUDErr((EndpointRef) cookie, NULL);
             break;
 
         case T_ORDREL:      // An orderly release is available
             err = OTRcvOrderlyDisconnect(endpoint);
             PR_ASSERT(err == kOTNoError);
             secret->md.readReady      = PR_TRUE;   // mark readable (to emulate bsd sockets)
             // remember connection is closed, so we can return 0 on read or receive
-			secret->md.orderlyDisconnect = PR_TRUE;
-	
-            thread = secret->md.read.thread;
-	        secret->md.read.thread    = NULL;
-	        secret->md.read.cookie    = cookie;
-
+            secret->md.orderlyDisconnect = PR_TRUE;
+            
+            readThread = secret->md.read.thread;
+            secret->md.read.thread    = NULL;
+            secret->md.read.cookie    = cookie;
             break;		
 
         case T_GODATA:   // Flow control lifted on standard data
             secret->md.writeReady = PR_TRUE;
-			resultOT = OTLook(endpoint);		// clear T_GODATA event
-			PR_ASSERT(resultOT == T_GODATA);
-			
-			// wake up waiting thread, if any
-            thread = secret->md.write.thread;
+            resultOT = OTLook(endpoint);        // clear T_GODATA event
+            PR_ASSERT(resultOT == T_GODATA);
+            
+            // wake up waiting thread, if any
+            writeThread = secret->md.write.thread;
             secret->md.write.thread    = NULL;
             secret->md.write.cookie    = cookie;
             break;
 
         case T_GOEXDATA: // Flow control lifted on expedited data
             PR_ASSERT(!"T_GOEXDATA Not implemented");
-			return;
+            return;
 
         case T_REQUEST:  // An Incoming request is available
             PR_ASSERT(!"T_REQUEST Not implemented");
             return;
 
         case T_REPLY:    // An Incoming reply is available
             PR_ASSERT(!"T_REPLY Not implemented");
             return;
 
         case T_PASSCON:  // State is now T_DATAXFER
-			// OTAccept() complete, receiving endpoint in T_DATAXFER state
-			// cookie = OTAccept() resRef parameter
-			break;
+            // OTAccept() complete, receiving endpoint in T_DATAXFER state
+            // cookie = OTAccept() resRef parameter
+            break;
 
         case T_RESET:    // Protocol has been reset
             PR_ASSERT(!"T_RESET Not implemented");
-			return;
+            return;
             
 // Async Completion Events
         case T_BINDCOMPLETE:
         case T_UNBINDCOMPLETE:
         case T_ACCEPTCOMPLETE:
         case T_OPTMGMTCOMPLETE:
         case T_GETPROTADDRCOMPLETE:
-			thread = secret->md.misc.thread;
+            readThread = secret->md.misc.thread;
             secret->md.misc.thread    = NULL;
             secret->md.misc.cookie    = cookie;
             break;
 
-//      case T_OPENCOMPLETE:			// we open endpoints in synchronous mode
+//      case T_OPENCOMPLETE:            // we open endpoints in synchronous mode
 //      case T_REPLYCOMPLETE:
-//      case T_DISCONNECTCOMPLETE:		// we don't call OTSndDisconnect()
+//      case T_DISCONNECTCOMPLETE:      // we don't call OTSndDisconnect()
 //      case T_RESOLVEADDRCOMPLETE:
 //      case T_GETINFOCOMPLETE:
 //      case T_SYNCCOMPLETE:
-//      case T_MEMORYRELEASED:			// only if OTAckSends() called on endpoint
+//      case T_MEMORYRELEASED:          // only if OTAckSends() called on endpoint
 //      case T_REGNAMECOMPLETE:
 //      case T_DELNAMECOMPLETE:
 //      case T_LKUPNAMECOMPLETE:
 //      case T_LKUPNAMERESULT:
-		// OpenTptInternet.h
-//      case T_DNRSTRINGTOADDRCOMPLETE:	// DNS is handled by dnsContext in DNSNotifierRoutine()
+        // OpenTptInternet.h
+//      case T_DNRSTRINGTOADDRCOMPLETE: // DNS is handled by dnsContext in DNSNotifierRoutine()
 //      case T_DNRADDRTONAMECOMPLETE:
 //      case T_DNRSYSINFOCOMPLETE:
 //      case T_DNRMAILEXCHANGECOMPLETE:
 //      case T_DNRQUERYCOMPLETE:
         default:
-        	// we should probably have a bit more sophisticated handling of kOTSystemSleep, etc.
-			// PR_ASSERT(code != 0);
+            // we should probably have a bit more sophisticated handling of kOTSystemSleep, etc.
+            // PR_ASSERT(code != 0);
             return;
     }
 
-	if (pollThread)
-		WakeUpNotifiedThread(pollThread, kOTNoError);
+    if (readThread)
+        WakeUpNotifiedThread(readThread, result);
 
-	if (thread && (thread != pollThread))
-		WakeUpNotifiedThread(thread, result);
+    if (writeThread && (writeThread != readThread))
+        WakeUpNotifiedThread(writeThread, result);
 }
 
 
 static OSErr CreateSocket(int type, EndpointRef *endpoint)
 {
     OSStatus err;
     PRThread *me = _PR_MD_CURRENT_THREAD();
     char *  configName;
     OTConfiguration *config;
     EndpointRef ep;
 
-	// for now we just create the endpoint
-	// we'll make it asynchronous and give it a notifier routine in _MD_makenonblock()
+    // for now we just create the endpoint
+    // we'll make it asynchronous and give it a notifier routine in _MD_makenonblock()
 
     switch (type){
         case SOCK_STREAM:   configName = kTCPName;  break;
         case SOCK_DGRAM:    configName = kUDPName;  break;
     }
     config = OTCreateConfiguration(configName);
     ep = OT_OPEN_ENDPOINT(config, 0, NULL, &err);
     if (err != kOTNoError)
@@ -514,17 +510,17 @@ ErrorExit:
 // kOTXXXX - OT returned error
 // EPROTONOSUPPORT - bad socket type/protocol
 // ENOBUFS - not enough space for another socket, or failure in socket creation routine
 PRInt32 _MD_socket(int domain, int type, int protocol)
 {
     OSStatus    err;
     EndpointRef endpoint;
     
-    	_MD_FinishInitNetAccess();
+    _MD_FinishInitNetAccess();
 
     // We only deal with internet domain
     if (domain != AF_INET) {
         err = kEPROTONOSUPPORTErr;
         goto ErrorExit;
     }
     
     // We only know about tcp & udp
@@ -1166,18 +1162,18 @@ static pascal void  RawEndpointNotifierR
 		// for other OT events, see NotifierRoutine above
         default:
             return;
     }
 
 	if (thread) {
 		thread->md.osErrCode = result;
 		if (_PR_MD_GET_INTSOFF()) {
+			thread->md.asyncNotifyPending = PR_TRUE;
 			cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
-			thread->md.asyncNotifyPending = PR_TRUE;
 			return;
 		}
 		DoneWaitingOnThisThread(thread);
 	}
 }
 
 PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout)
 {
@@ -1344,17 +1340,18 @@ PRInt32 _MD_connect(PRFileDesc *fd, PRNe
 
     memset(&sndCall, 0 , sizeof(sndCall));
 
     sndCall.addr.maxlen = addrlen;
     sndCall.addr.len = addrlen;
     sndCall.addr.buf = (UInt8*) addr;
 
 	if (!fd->secret->nonblocking) {    
-        PrepareForAsyncCompletion(me, fd->secret->md.osfd);    
+        PrepareForAsyncCompletion(me, fd->secret->md.osfd);
+        PR_ASSERT(fd->secret->md.write.thread == NULL);
 	    fd->secret->md.write.thread = me;
     }
 	
     err = OTConnect (endpoint, &sndCall, NULL);
 	if (err == kOTNoError) {
         PR_ASSERT(!"OTConnect returned kOTNoError in async mode!?!");	
 	}
 	if (fd->secret->nonblocking) {
@@ -1402,26 +1399,28 @@ static PRInt32 SendReceiveStream(PRFileD
         err = kEBADFErr;
         goto ErrorExit;
     }
         
     if (buf == NULL) {
         err = kEFAULTErr;
         goto ErrorExit;
     }
-    
+
+    PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == NULL :
+                                       fd->secret->md.read.thread  == NULL);
+
     while (bytesLeft > 0)
     {
         Boolean disabledNotifications = OTEnterNotifier(endpoint);
     
         PrepareForAsyncCompletion(me, fd->secret->md.osfd);    
 
         if (opCode == kSTREAM_SEND) {
         	do {
-
 				fd->secret->md.write.thread = me;
 				fd->secret->md.writeReady = PR_FALSE;				// expect the worst
 	            result = OTSnd(endpoint, buf, bytesLeft, NULL);
 				fd->secret->md.writeReady = (result != kOTFlowErr);
 				if (fd->secret->nonblocking)							// hope for the best
 					break;
 				else {
 
@@ -1495,73 +1494,86 @@ static PRInt32 SendReceiveStream(PRFileD
 
         // turn notifications back on
         if (disabledNotifications)
             OTLeaveNotifier(endpoint);
 
         if (result > 0) {
             buf = (void *) ( (UInt32) buf + (UInt32)result );
             bytesLeft -= result;
-            if (opCode == kSTREAM_RECEIVE)
-                return result;
+            if (opCode == kSTREAM_RECEIVE) {
+                amount = result;
+                goto NormalExit;
+            }
         } else {
 			switch (result) {
 				case kOTLookErr:
 				    PR_ASSERT(!"call to OTLook() required after all.");
 					break;
 				
 				case kOTFlowErr:
 				case kOTNoDataErr:
 				case kEAGAINErr:
 				case kEWOULDBLOCKErr:
 					if (fd->secret->nonblocking) {
-						err = result;
-						goto ErrorExit;
+					
+					    if (bytesLeft == amount) {  // no data was sent
+						    err = result;
+						    goto ErrorExit;
+						}
+						
+						// some data was sent
+						amount -= bytesLeft;
+						goto NormalExit;
 					}
 
 					WaitOnThisThread(me, timeout);
 					err = me->md.osErrCode;
 					if (err != kOTNoError)
 						goto ErrorExit;				
 					break;
 					
 				case kOTOutStateErr:	// if provider already closed, fall through to handle error
-					if (fd->secret->md.orderlyDisconnect)
-						return 0;
+					if (fd->secret->md.orderlyDisconnect) {
+						amount = 0;
+						goto NormalExit;
+					}
+					// else fall through
 				default:
 					err = result;
 					goto ErrorExit;
 			}
 		}
     }
 
-    PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == nil :
-                                       fd->secret->md.read.thread  == nil);
+NormalExit:
+    PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == NULL :
+                                       fd->secret->md.read.thread  == NULL);
     return amount;
 
 ErrorExit:
-    PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == nil :
-                                       fd->secret->md.read.thread  == nil);
+    PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == NULL :
+                                       fd->secret->md.read.thread  == NULL);
     macsock_map_error(err);
     return -1;
-}                               
+}
 
 
 PRInt32 _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount, 
                                PRIntn flags, PRIntervalTime timeout)
 {
     return (SendReceiveStream(fd, buf, amount, flags, timeout, kSTREAM_RECEIVE));
-}                               
+}
 
 
 PRInt32 _MD_send(PRFileDesc *fd,const void *buf, PRInt32 amount, 
                                PRIntn flags, PRIntervalTime timeout)
 {
     return (SendReceiveStream(fd, (void *)buf, amount, flags, timeout, kSTREAM_SEND));
-}                               
+}
 
 
 // Errors:
 // EBADF -- bad socket id
 // EFAULT -- bad buffer
 static PRInt32 SendReceiveDgram(PRFileDesc *fd, void *buf, PRInt32 amount, 
                                PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen, 
                                PRIntervalTime timeout, SndRcvOpCode opCode)
@@ -1633,35 +1645,35 @@ static PRInt32 SendReceiveDgram(PRFileDe
     if (opCode == kDGRAM_RECEIVE)
         *addrlen = dgram.addr.len;
 
     return amount;
 
 ErrorExit:
     macsock_map_error(err);
     return -1;
-}                               
+}
 
 
 PRInt32 _MD_recvfrom(PRFileDesc *fd, void *buf, PRInt32 amount, 
                                PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen,
                                PRIntervalTime timeout)
 {
     return (SendReceiveDgram(fd, buf, amount, flags, addr, addrlen,
                             timeout, kDGRAM_RECEIVE));
-}                               
+}
 
 
 PRInt32 _MD_sendto(PRFileDesc *fd,const void *buf, PRInt32 amount, 
                                PRIntn flags, PRNetAddr *addr, PRUint32 addrlen,
                                PRIntervalTime timeout)
 {
     return (SendReceiveDgram(fd, (void *)buf, amount, flags, addr, &addrlen,
                             timeout, kDGRAM_SEND));
-}                               
+}
 
 
 PRInt32 _MD_closesocket(PRInt32 osfd)
 {
     OSStatus err;
     EndpointRef endpoint = (EndpointRef) osfd;
     PRThread *me = _PR_MD_CURRENT_THREAD();
 
@@ -1678,47 +1690,67 @@ PRInt32 _MD_closesocket(PRInt32 osfd)
     if (err != kOTNoError)
         goto ErrorExit;
 
     return kOTNoError;
 
 ErrorExit:
     macsock_map_error(err);
     return -1;
-}                               
+}
 
 
 PRInt32 _MD_writev(PRFileDesc *fd, const struct PRIOVec *iov, PRInt32 iov_size, PRIntervalTime timeout)
 {
 #pragma unused (fd, iov, iov_size, timeout)
 
     PR_ASSERT(0);
     _PR_MD_CURRENT_THREAD()->md.osErrCode = unimpErr;
     return -1;
-}                               
+}
 
-
+// OT endpoint states are documented here:
+// http://gemma.apple.com/techpubs/mac/NetworkingOT/NetworkingWOT-27.html#MARKER-9-65
+//
 static PRBool GetState(PRFileDesc *fd, PRBool *readReady, PRBool *writeReady, PRBool *exceptReady)
 {
     OTResult resultOT;
     // hack to emulate BSD sockets; say that a socket that has disconnected
     // is still readable.
     size_t   availableData = 1;
     if (!fd->secret->md.orderlyDisconnect)
         OTCountDataBytes((EndpointRef)fd->secret->md.osfd, &availableData);
 
     *readReady = fd->secret->md.readReady && (availableData > 0);
-	*exceptReady = fd->secret->md.exceptReady;
+    *exceptReady = fd->secret->md.exceptReady;
 
     resultOT = OTGetEndpointState((EndpointRef)fd->secret->md.osfd);
-    switch (resultOT)    {
-        case T_DATAXFER:
-        case T_INREL:
-            *writeReady = PR_TRUE;
+    switch (resultOT) {
+        case T_IDLE:
+        case T_UNBND:
+            // the socket is not connected. Emulating BSD sockets,
+            // we mark it readable and writable. The next PR_Read
+            // or PR_Write will then fail. Usually, in this situation,
+            // fd->secret->md.exceptReady is also set, and returned if
+            // anyone is polling for it.
+            *readReady = PR_FALSE;
+            *writeReady = PR_FALSE;
             break;
+
+        case T_DATAXFER:        // data transfer
+            *writeReady = fd->secret->md.writeReady;
+            break;
+
+        case T_INREL:           // incoming orderly release
+            *writeReady = fd->secret->md.writeReady;
+            break;
+
+        case T_OUTCON:          // outgoing connection pending  
+        case T_INCON:           // incoming connection pending
+        case T_OUTREL:          // outgoing orderly release
         default:
             *writeReady = PR_FALSE;
     }
     
     return  *readReady || *writeReady || *exceptReady;
 }
 
 // check to see if any of the poll descriptors have data available
@@ -1806,55 +1838,66 @@ static void SetDescPollThread(PRPollDesc
 
     for (pd = pds, epd = pd + npds; pd < epd; pd++)
     {   
         if (pd->fd)
         { 
             PRFileDesc *bottomFD = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);
             if (bottomFD && (_PR_FILEDESC_OPEN == bottomFD->secret->state))
             {
-                bottomFD->secret->md.poll.thread = thread;
+                if (pd->in_flags & PR_POLL_READ) {
+                    PR_ASSERT(thread == NULL || bottomFD->secret->md.read.thread == NULL);
+                    bottomFD->secret->md.read.thread = thread;
+                }
+
+                if (pd->in_flags & PR_POLL_WRITE) {
+                    // it's possible for the writing thread to be non-null during
+                    // a non-blocking connect, so we assert that we're on
+                    // the same thread, or the thread is null.
+                    // Note that it's strictly possible for the connect and poll
+                    // to be on different threads, so ideally we need to assert
+                    // that if md.write.thread is non-null, there is a non-blocking
+                    // connect in progress.
+                    PR_ASSERT(thread == NULL ||
+                        (bottomFD->secret->md.write.thread == NULL ||
+                         bottomFD->secret->md.write.thread == thread));
+                    bottomFD->secret->md.write.thread = thread;
+                }
             }
         }        
     }
 }
 
 PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
 {
     PRThread    *thread = _PR_MD_CURRENT_THREAD();
     intn is;
     PRInt32 ready;
-    OSErr   result;
     
-    if (timeout == PR_INTERVAL_NO_WAIT) {        
+    if (timeout == PR_INTERVAL_NO_WAIT) {
         return CheckPollDescs(pds, npds);
     }
     
     _PR_INTSOFF(is);
     PR_Lock(thread->md.asyncIOLock);
 
     // ensure that we don't miss the firing of the notifier while checking socket status
     // need to set up the thread
     PrepareForAsyncCompletion(thread, 0);
 
-    SetDescPollThread(pds, npds, thread);        
+    SetDescPollThread(pds, npds, thread);
     ready = CheckPollDescs(pds, npds);
 
     PR_Unlock(thread->md.asyncIOLock);
     _PR_FAST_INTSON(is);
 
     if (ready == 0) {
         WaitOnThisThread(thread, timeout);
-        result = thread->md.osErrCode;
-        if (result != noErr && result != kETIMEDOUTErr) {
-            PR_ASSERT(0);   /* debug: catch unexpected errors */
-            ready = -1;
-        } else {
-            ready = CheckPollDescs(pds, npds);
-        }
+        ready = CheckPollDescs(pds, npds);
+
     } else {
         thread->io_pending = PR_FALSE;
     }
 
     SetDescPollThread(pds, npds, NULL);
 
     return ready;
 }
@@ -1932,17 +1975,17 @@ void _MD_queryfdinheritable(PRFileDesc *
 
 
 PR_IMPLEMENT(PRInt32) _MD_shutdown(PRFileDesc *fd, PRIntn how)
 {
 #pragma unused (fd, how)
 
 /* Just succeed silently!!! */
 return (0);
-}                               
+}
 
 
 PR_IMPLEMENT(PRStatus) 
 _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen)
 {
     PRThread *me = _PR_MD_CURRENT_THREAD();
 	EndpointRef ep = (EndpointRef) fd->secret->md.osfd;
 	InetAddress inetAddr;
@@ -1982,25 +2025,25 @@ PR_IMPLEMENT(PRStatus)
     addr->inet.ip = (PRUint32) inetAddr.fHost;
     
     *addrlen = PR_NETADDR_SIZE(addr); // return the amount of data obtained
 	return PR_SUCCESS;
 
 ErrorExit:
     macsock_map_error(err);
     return PR_FAILURE;
-}                               
+}
 
 
 PR_IMPLEMENT(unsigned long) inet_addr(const char *cp)
 {
     OSStatus err;
     InetHost host;    
 
-    	_MD_FinishInitNetAccess();
+    _MD_FinishInitNetAccess();
 
     err = OTInetStringToHost((char*) cp, &host);
     if (err != kOTNoError)
         return -1;
     
     return host;
 }
 
@@ -2062,30 +2105,30 @@ PR_IMPLEMENT(struct hostent *) gethostby
     OTInetHostToString((InetHost)addr, sHostInfo.name);
     
     return (gethostbyname(sHostInfo.name));
 }
 
 
 PR_IMPLEMENT(char *) inet_ntoa(struct in_addr addr)
 {
-    	_MD_FinishInitNetAccess();
+    _MD_FinishInitNetAccess();
 
     OTInetHostToString((InetHost)addr.s_addr, sHostInfo.name);
     
     return sHostInfo.name;
 }
 
 
 PRStatus _MD_gethostname(char *name, int namelen)
 {
     OSStatus err;
     InetInterfaceInfo info;
 
-    	_MD_FinishInitNetAccess();
+    _MD_FinishInitNetAccess();
 
     /*
      *    On a Macintosh, we don't have the concept of a local host name.
      *    We do though have an IP address & everyone should be happy with
      *     a string version of that for a name.
      *    The alternative here is to ping a local DNS for our name, they
      *    will often know it.  This is the cheap, easiest, and safest way out.
      */
@@ -2159,15 +2202,15 @@ int _MD_mac_get_nonblocking_connect_erro
         case T_OUTCON:
             macsock_map_error(EINPROGRESS);
             return -1;
         case T_DATAXFER:
             return 0;
         case T_IDLE:
             return -1;
         case T_INREL:
-        	macsock_map_error(ENOTCONN);
-        	return -1;
+            macsock_map_error(ENOTCONN);
+            return -1;
         default:
             PR_ASSERT(0);
             return -1;
     }
 }
--- a/pr/src/md/mac/macthr.c
+++ b/pr/src/md/mac/macthr.c
@@ -31,22 +31,25 @@
  * may use your version of this file under either the MPL or the
  * GPL.
  */
 
 #include "primpl.h"
 
 #include <string.h>
 
-#include <Types.h>
+#include <MacTypes.h>
 #include <Timer.h>
 #include <OSUtils.h>
 
 #include <LowMem.h>
+#include <Multiprocessing.h>
+#include <Gestalt.h>
 
+#include "mdcriticalregion.h"
 
 TimerUPP	gTimerCallbackUPP	= NULL;
 PRThread *	gPrimaryThread		= NULL;
 
 PR_IMPLEMENT(PRThread *) PR_GetPrimaryThread()
 {
 	return gPrimaryThread;
 }
@@ -163,34 +166,36 @@ extern void _MD_IOInterrupt(void);
     { "clock", _PR_MISSED_CLOCK, _PR_ClockInterrupt, },
     { "i/o", _PR_MISSED_IO, _MD_IOInterrupt, },
     { 0 }
 };
 
 pascal void TimerCallback(TMTaskPtr tmTaskPtr)
 {
     _PRCPU *cpu = _PR_MD_CURRENT_CPU();
+    PRIntn is;
 
     if (_PR_MD_GET_INTSOFF()) {
         cpu->u.missed[cpu->where] |= _PR_MISSED_CLOCK;
-		PrimeTime((QElemPtr)tmTaskPtr, kMacTimerInMiliSecs);
-		return;
+        PrimeTime((QElemPtr)tmTaskPtr, kMacTimerInMiliSecs);
+        return;
     }
-    _PR_MD_SET_INTSOFF(1);
+
+    _PR_INTSOFF(is);
 
-	//	And tell nspr that a clock interrupt occured.
-	_PR_ClockInterrupt();
+    //	And tell nspr that a clock interrupt occured.
+    _PR_ClockInterrupt();
 	
-	if ((_PR_RUNQREADYMASK(cpu)) >> ((_PR_MD_CURRENT_THREAD()->priority)))
-		_PR_SET_RESCHED_FLAG();
+    if ((_PR_RUNQREADYMASK(cpu)) >> ((_PR_MD_CURRENT_THREAD()->priority)))
+        _PR_SET_RESCHED_FLAG();
 	
-    _PR_MD_SET_INTSOFF(0);
+    _PR_FAST_INTSON(is);
 
-	//	Reset the clock timer so that we fire again.
-	PrimeTime((QElemPtr)tmTaskPtr, kMacTimerInMiliSecs);
+    //	Reset the clock timer so that we fire again.
+    PrimeTime((QElemPtr)tmTaskPtr, kMacTimerInMiliSecs);
 }
 
 
 void _MD_StartInterrupts(void)
 {
 	gPrimaryThread = _PR_MD_CURRENT_THREAD();
 
 	if ( !gTimerCallbackUPP )
@@ -214,35 +219,32 @@ void _MD_StopInterrupts(void)
 	if (gTimeManagerTaskElem.tmAddr != NULL) {
 		RmvTime((QElemPtr)&gTimeManagerTaskElem);
 		gTimeManagerTaskElem.tmAddr = NULL;
 	}
 }
 
 void _MD_PauseCPU(PRIntervalTime timeout)
 {
-#pragma unused (timeout)
-
-	/* unsigned long finalTicks; */
-	EventRecord theEvent;
+    if (timeout != PR_INTERVAL_NO_WAIT)
+    {
+        EventRecord theEvent;
 	
-	if (timeout != PR_INTERVAL_NO_WAIT) {
-	   /* Delay(1,&finalTicks); */
+         /*
+            ** Calling WaitNextEvent() here is suboptimal. This routine should
+            ** pause the process until IO or the timeout occur, yielding time to
+            ** other processes on operating systems that require this (Mac OS classic).
+            ** WaitNextEvent() may incur too much latency, and has other problems,
+            ** such as the potential to drop suspend/resume events, and to handle
+            ** AppleEvents at a time at which we're not prepared to handle them.
+         */
+        (void) WaitNextEvent(nullEvent, &theEvent, 1, NULL);
 	   
-	   /*
-	   ** Rather than calling Delay() which basically just wedges the processor
-	   ** we'll instead call WaitNextEvent() with a mask that ignores all events
-	   ** which gives other apps a chance to get time rather than just locking up
-	   ** the machine when we're waiting for a long time (or in an infinite loop,
-	   ** whichever comes first)
-	   */
-	   (void)WaitNextEvent(nullEvent, &theEvent, 1, NULL);
-	   
-	    (void) _MD_IOInterrupt();
-	}
+        (void) _MD_IOInterrupt();
+    }
 }
 
 
 //##############################################################################
 //##############################################################################
 #pragma mark -
 #pragma mark THREAD SUPPORT FUNCTIONS
 
@@ -271,16 +273,21 @@ PRStatus _MD_wait(PRThread *thread, PRIn
 
 
 void WaitOnThisThread(PRThread *thread, PRIntervalTime timeout)
 {
     intn is;
     PRIntervalTime timein = PR_IntervalNow();
 	PRStatus status = PR_SUCCESS;
 
+    // Turn interrupts off to avoid a race over lock ownership with the callback
+    // (which can fire at any time). Interrupts may stay off until we leave
+    // this function, or another NSPR thread turns them back on. They certainly
+    // stay off until PR_WaitCondVar() relinquishes the asyncIOLock lock, which
+    // is what we care about.
 	_PR_INTSOFF(is);
 	PR_Lock(thread->md.asyncIOLock);
 	if (timeout == PR_INTERVAL_NO_TIMEOUT) {
 	    while ((thread->io_pending) && (status == PR_SUCCESS))
 	        status = PR_WaitCondVar(thread->md.asyncIOCVar, PR_INTERVAL_NO_TIMEOUT);
 	} else {
 	    while ((thread->io_pending) && ((PRIntervalTime)(PR_IntervalNow() - timein) < timeout) && (status == PR_SUCCESS))
 	        status = PR_WaitCondVar(thread->md.asyncIOCVar, timeout);
@@ -297,33 +304,49 @@ void WaitOnThisThread(PRThread *thread, 
 	_PR_FAST_INTSON(is);
 }
 
 
 void DoneWaitingOnThisThread(PRThread *thread)
 {
     intn is;
 
+    PR_ASSERT(thread->md.asyncIOLock->owner == NULL);
+
+	// DoneWaitingOnThisThread() is called from OT notifiers and async file I/O
+	// callbacks that can run at "interrupt" time (Classic Mac OS) or on pthreads
+	// that may run concurrently with the main threads (Mac OS X). They can thus
+	// be called when any NSPR thread is running, or even while NSPR is in a
+	// thread context switch. It is therefore vital that we can guarantee to
+	// be able to get the asyncIOLock without blocking (thus avoiding code
+	// that makes assumptions about the current NSPR thread etc). To achieve
+	// this, we use NSPR interrrupts as a semaphore on the lock; all code 
+	// that grabs the lock also disables interrupts for the time the lock
+	// is held. Callers of DoneWaitingOnThisThread() thus have to check whether
+	// interrupts are already off, and, if so, simply set the missed_IO flag on
+	// the CPU rather than calling this function.
+	
 	_PR_INTSOFF(is);
 	PR_Lock(thread->md.asyncIOLock);
-    thread->io_pending = PR_FALSE;
+	thread->io_pending = PR_FALSE;
 	/* let the waiting thread know that async IO completed */
 	PR_NotifyCondVar(thread->md.asyncIOCVar);
 	PR_Unlock(thread->md.asyncIOLock);
 	_PR_FAST_INTSON(is);
 }
 
 
 PR_IMPLEMENT(void) PR_Mac_WaitForAsyncNotify(PRIntervalTime timeout)
 {
     intn is;
     PRIntervalTime timein = PR_IntervalNow();
 	PRStatus status = PR_SUCCESS;
     PRThread *thread = _PR_MD_CURRENT_THREAD();
 
+    // See commments in WaitOnThisThread()
 	_PR_INTSOFF(is);
 	PR_Lock(thread->md.asyncIOLock);
 	if (timeout == PR_INTERVAL_NO_TIMEOUT) {
 	    while ((!thread->md.asyncNotifyPending) && (status == PR_SUCCESS))
 	        status = PR_WaitCondVar(thread->md.asyncIOCVar, PR_INTERVAL_NO_TIMEOUT);
 	} else {
 	    while ((!thread->md.asyncNotifyPending) && ((PRIntervalTime)(PR_IntervalNow() - timein) < timeout) && (status == PR_SUCCESS))
 	        status = PR_WaitCondVar(thread->md.asyncIOCVar, timeout);
@@ -339,33 +362,36 @@ PR_IMPLEMENT(void) PR_Mac_WaitForAsyncNo
 	_PR_FAST_INTSON(is);
 }
 
 
 void AsyncNotify(PRThread *thread)
 {
     intn is;
 	
+    PR_ASSERT(thread->md.asyncIOLock->owner == NULL);
+
+    // See commments in DoneWaitingOnThisThread()
 	_PR_INTSOFF(is);
 	PR_Lock(thread->md.asyncIOLock);
-    thread->md.asyncNotifyPending = PR_TRUE;
+	thread->md.asyncNotifyPending = PR_TRUE;
 	/* let the waiting thread know that async IO completed */
-	PR_NotifyCondVar(thread->md.asyncIOCVar);	// let thread know that async IO completed
+	PR_NotifyCondVar(thread->md.asyncIOCVar);
 	PR_Unlock(thread->md.asyncIOLock);
 	_PR_FAST_INTSON(is);
 }
 
 
 PR_IMPLEMENT(void) PR_Mac_PostAsyncNotify(PRThread *thread)
 {
 	_PRCPU *  cpu = _PR_MD_CURRENT_CPU();
 	
 	if (_PR_MD_GET_INTSOFF()) {
+		thread->md.missedAsyncNotify = PR_TRUE;
 		cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
-		thread->md.missedAsyncNotify = PR_TRUE;
 	} else {
 		AsyncNotify(thread);
 	}
 }
 
 
 //##############################################################################
 //##############################################################################
@@ -402,8 +428,141 @@ PRStatus _MD_WaitProcess(PRProcess *proc
 
 PRStatus _MD_KillProcess(PRProcess *process)
 {
 #pragma unused (process)
 
 	PR_SetError(PR_NOT_IMPLEMENTED_ERROR, unimpErr);
 	return PR_FAILURE;
 }
+//##############################################################################
+//##############################################################################
+#pragma mark -
+#pragma mark INTERRUPT SUPPORT
+
+#if TARGET_CARBON
+
+/*
+     This critical region support is required for Mac NSPR to work correctly on dual CPU
+     machines on Mac OS X. This note explains why.
+
+     NSPR uses a timer task, and has callbacks for async file I/O and Open Transport
+     whose runtime behaviour differs depending on environment. On "Classic" Mac OS
+     these run at "interrupt" time (OS-level interrupts, that is, not NSPR interrupts),
+     and can thus preempt other code, but they always run to completion.
+
+     On Mac OS X, these are all emulated using MP tasks, which sit atop pthreads. Thus,
+     they can be preempted at any time (and not necessarily run to completion), and can
+     also run *concurrently* with eachother, and with application code, on multiple
+     CPU machines. Note that all NSPR threads are emulated, and all run on the main
+     application MP task.
+
+     We thus have to use MP critical sections to protect data that is shared between
+     the various callbacks and the main MP thread. It so happens that NSPR has this
+     concept of software interrupts, and making interrupt-off times be critical
+     sections works.
+
+*/
+
+
+/*  
+    Whether to use critical regions. True if running on Mac OS X and later
+*/
+
+PRBool  gUseCriticalRegions;
+
+/*
+    Count of the number of times we've entered the critical region.
+    We need this because ENTER_CRITICAL_REGION() will *not* block when
+    called from different NSPR threads (which all run on one MP thread),
+    and we need to ensure that when code turns interrupts back on (by
+    settings _pr_intsOff to 0) we exit the critical section enough times
+    to leave it.
+*/
+
+PRInt32 gCriticalRegionEntryCount;
+
+
+void _MD_SetIntsOff(PRInt32 ints)
+{
+    ENTER_CRITICAL_REGION();
+    gCriticalRegionEntryCount ++;
+    
+    _pr_intsOff = ints;
+    
+    if (!ints)
+    {
+        PRInt32     i = gCriticalRegionEntryCount;
+
+        gCriticalRegionEntryCount = 0;
+        for ( ;i > 0; i --) {
+            LEAVE_CRITICAL_REGION();
+        }
+    }
+}
+
+
+#endif /* TARGET_CARBON */
+
+
+//##############################################################################
+//##############################################################################
+#pragma mark -
+#pragma mark CRITICAL REGION SUPPORT
+
+#if MAC_CRITICAL_REGIONS
+
+MDCriticalRegionID  gCriticalRegion;
+
+void InitCriticalRegion()
+{
+    long        systemVersion;
+    OSStatus    err;    
+    
+    // we only need to do critical region stuff on Mac OS X    
+    err = Gestalt(gestaltSystemVersion, &systemVersion);
+    gUseCriticalRegions = (err == noErr) && (systemVersion >= 0x00001000);
+    
+    if (!gUseCriticalRegions) return;
+    
+    err = MD_CriticalRegionCreate(&gCriticalRegion);
+    PR_ASSERT(err == noErr);
+}
+
+void TermCriticalRegion()
+{
+    OSStatus    err;    
+
+    if (!gUseCriticalRegions) return;
+
+    err = MD_CriticalRegionDelete(gCriticalRegion);
+    PR_ASSERT(err == noErr);
+}
+
+
+void EnterCritialRegion()
+{
+    OSStatus    err;
+    
+    if (!gUseCriticalRegions) return;
+
+    PR_ASSERT(gCriticalRegion != kInvalidID);
+    
+    /* Change to a non-infinite timeout for debugging purposes */
+    err = MD_CriticalRegionEnter(gCriticalRegion, kDurationForever /* 10000 * kDurationMillisecond */ );
+    PR_ASSERT(err == noErr);
+}
+
+void LeaveCritialRegion()
+{
+    OSStatus    err;    
+
+    if (!gUseCriticalRegions) return;
+
+    PR_ASSERT(gCriticalRegion != kInvalidID);
+
+    err = MD_CriticalRegionExit(gCriticalRegion);
+    PR_ASSERT(err == noErr);
+}
+
+
+#endif // MAC_CRITICAL_REGIONS
+
new file mode 100644
--- /dev/null
+++ b/pr/src/md/mac/mdcriticalregion.c
@@ -0,0 +1,169 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: NULL; 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) 1998-2000 Netscape Communications Corporation.  All
+ * Rights Reserved.
+ * 
+ * Contributor(s):
+ *                George Warner, Apple Computer Inc.
+ *                Simon Fraser  <sfraser@netscape.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.
+ */
+
+#include "mdcriticalregion.h"
+
+/*
+  This code is a replacement for MPEnterCriticalRegion/MPLeaveCriticalRegion,
+  which is broken on Mac OS 10.0.x builds, but fixed in 10.1. This code works
+  everywhere.
+*/
+
+
+typedef struct MDCriticalRegionData_struct {
+  MPTaskID        mMPTaskID;          /* Who's in the critical region? */
+  UInt32          mDepthCount;        /* How deep? */
+  MPSemaphoreID   mMPSemaphoreID;     /* ready semaphore */
+} MDCriticalRegionData, *MDCriticalRegionDataPtr;
+
+
+OSStatus
+MD_CriticalRegionCreate(MDCriticalRegionID * outCriticalRegionID)
+{
+  MDCriticalRegionDataPtr newCriticalRegionPtr;
+  MPSemaphoreID           mpSemaphoreID;
+  OSStatus                err = noErr;
+
+  if (outCriticalRegionID == NULL)
+    return paramErr;
+
+  *outCriticalRegionID = NULL;
+
+  newCriticalRegionPtr = (MDCriticalRegionDataPtr)MPAllocateAligned(sizeof(MDCriticalRegionData),
+                        kMPAllocateDefaultAligned, kMPAllocateClearMask);
+  if (newCriticalRegionPtr == NULL)
+    return memFullErr;
+
+  // Note: this semaphore is pre-fired (ready!)
+  err = MPCreateBinarySemaphore(&mpSemaphoreID);
+  if (err == noErr)
+  {
+    newCriticalRegionPtr->mMPTaskID = kInvalidID;
+    newCriticalRegionPtr->mDepthCount = 0;
+    newCriticalRegionPtr->mMPSemaphoreID = mpSemaphoreID;
+
+    *outCriticalRegionID = (MDCriticalRegionID)newCriticalRegionPtr;
+  }
+  else
+  {
+    MPFree((LogicalAddress)newCriticalRegionPtr);
+  }
+
+  return err;
+}
+
+OSStatus
+MD_CriticalRegionDelete(MDCriticalRegionID inCriticalRegionID)
+{
+  MDCriticalRegionDataPtr criticalRegion = (MDCriticalRegionDataPtr)inCriticalRegionID;
+  OSStatus                err = noErr;
+
+  if (criticalRegion == NULL)
+    return paramErr;
+
+  if ((criticalRegion->mMPTaskID != kInvalidID) && (criticalRegion->mDepthCount > 0))
+    return kMPInsufficientResourcesErr;
+
+  if (criticalRegion->mMPSemaphoreID != kInvalidID)
+    err = MPDeleteSemaphore(criticalRegion->mMPSemaphoreID);
+  if (noErr != err) return err;
+
+  criticalRegion->mMPSemaphoreID = kInvalidID;
+  MPFree((LogicalAddress) criticalRegion);
+
+  return noErr;
+}
+
+OSStatus
+MD_CriticalRegionEnter(MDCriticalRegionID inCriticalRegionID, Duration inTimeout)
+{
+  MDCriticalRegionDataPtr criticalRegion = (MDCriticalRegionDataPtr)inCriticalRegionID;
+  MPTaskID                currentTaskID = MPCurrentTaskID();
+  OSStatus                err = noErr;
+
+  if (criticalRegion == NULL)
+    return paramErr;
+
+  // if I'm inside the critical region...
+  if (currentTaskID == criticalRegion->mMPTaskID)
+  {
+    // bump my depth
+    criticalRegion->mDepthCount++;
+    // and continue
+    return noErr;
+  }
+
+  // wait for the ready semaphore
+  err = MPWaitOnSemaphore(criticalRegion->mMPSemaphoreID, inTimeout);
+  // we didn't get it. return the error
+  if (noErr != err) return err;
+
+  // we got it!
+  criticalRegion->mMPTaskID = currentTaskID;
+  criticalRegion->mDepthCount = 1;
+
+  return noErr;
+}
+
+OSStatus
+MD_CriticalRegionExit(MDCriticalRegionID inCriticalRegionID)
+{
+  MDCriticalRegionDataPtr   criticalRegion = (MDCriticalRegionDataPtr)inCriticalRegionID;
+  MPTaskID                  currentTaskID = MPCurrentTaskID();
+  OSStatus                  err = noErr;
+
+  // if we don't own the critical region...
+  if (currentTaskID != criticalRegion->mMPTaskID)
+    return kMPInsufficientResourcesErr;
+
+  // if we aren't at a depth...
+  if (criticalRegion->mDepthCount == 0)
+    return kMPInsufficientResourcesErr;
+
+  // un-bump my depth
+  criticalRegion->mDepthCount--;
+
+  // if we just bottomed out...
+  if (criticalRegion->mDepthCount == 0)
+  {
+    // release ownership of the structure
+    criticalRegion->mMPTaskID = kInvalidID;
+    // and signal the ready semaphore
+    err = MPSignalSemaphore(criticalRegion->mMPSemaphoreID);
+  }
+  return err;
+}
+
new file mode 100644
--- /dev/null
+++ b/pr/src/md/mac/mdcriticalregion.h
@@ -0,0 +1,56 @@
+/* -*- 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) 1998-2000 Netscape Communications Corporation.  All
+ * Rights Reserved.
+ * 
+ * Contributor(s):
+ *                George Warner, Apple Computer Inc.
+ *                Simon Fraser  <sfraser@netscape.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.
+ */
+
+#ifndef mdcriticalregion_h___
+#define mdcriticalregion_h___
+
+
+#ifndef __MULTIPROCESSING__
+#include <Multiprocessing.h>
+#endif
+
+typedef struct OpaqueMDCriticalRegionID*  MDCriticalRegionID;
+
+OSStatus MD_CriticalRegionCreate(MDCriticalRegionID * pMDCriticalRegionID);
+
+OSStatus MD_CriticalRegionDelete(MDCriticalRegionID pMDCriticalRegionID);
+
+OSStatus MD_CriticalRegionEnter(MDCriticalRegionID pMDCriticalRegionID, Duration pTimeout);
+
+OSStatus MD_CriticalRegionExit(MDCriticalRegionID pMDCriticalRegionID);
+
+#endif /* mdcriticalregion_h___ */
+
--- a/pr/src/md/mac/mdmac.c
+++ b/pr/src/md/mac/mdmac.c
@@ -283,16 +283,18 @@ void _MD_GetRegisters(PRUint32 *to)
 {
   (void) setjmp((void*) to);
 }
 
 void _MD_EarlyInit()
 {
 	Handle				environmentVariables;
 
+	INIT_CRITICAL_REGION();
+
 #if !defined(MAC_NSPR_STANDALONE)
 	// MacintoshInitializeMemory();  Moved to mdmacmem.c: AllocateRawMemory(Size blockSize)
 #else
 	MacintoshInitializeMemory();
 #endif
 	MacintoshInitializeTime();
 	
 	//	Install resource-controlled environment variables.
@@ -369,16 +371,17 @@ extern OTClientContextPtr	clientContext;
 
 extern pascal void __NSTerminate(void);
 
 void CleanupTermProc(void)
 {
 	_MD_StopInterrupts();	// deactive Time Manager task
 
 	CLOSE_OPEN_TRANSPORT();
+	TERM_CRITICAL_REGION();
 	
 	__NSTerminate();
 }
 
 
 
 //##############################################################################
 //##############################################################################
--- a/pr/src/md/os2/os2cv.c
+++ b/pr/src/md/os2/os2cv.c
@@ -270,17 +270,19 @@ void
         md_UnlockAndPostNotifies(lock, thred, cv);
     } else {
         AddThreadToCVWaitQueueInternal(thred, cv);
         DosReleaseMutexSem(lock->mutex); 
     }
 
     /* Wait for notification or timeout; don't really care which */
     rv = DosWaitEventSem(thred->md.blocked_sema.sem, msecs);
-    DosResetEventSem(thred->md.blocked_sema.sem, &count);
+    if (rv == NO_ERROR) {
+        DosResetEventSem(thred->md.blocked_sema.sem, &count);
+    }
 
     DosRequestMutexSem((lock->mutex), SEM_INDEFINITE_WAIT);
 
     PR_ASSERT(rv == NO_ERROR || rv == ERROR_TIMEOUT);
 
     if(rv == ERROR_TIMEOUT)
     {
        if (thred->md.inCVWaitQueue) {
@@ -309,17 +311,19 @@ void
        } else {
            /*
             * This thread must have been notified, but the
             * SemRelease call happens after SemRequest
             * times out.  Wait on the semaphore again to make it
             * non-signaled.  We assume this wait won't take long.
             */
            rv = DosWaitEventSem(thred->md.blocked_sema.sem, SEM_INDEFINITE_WAIT);
-           DosResetEventSem(thred->md.blocked_sema.sem, &count);
+           if (rv == NO_ERROR) {
+               DosResetEventSem(thred->md.blocked_sema.sem, &count);
+           }
            PR_ASSERT(rv == NO_ERROR);
        }
     }
     PR_ASSERT(thred->md.inCVWaitQueue == PR_FALSE);
     return;
 } /* --- end _PR_MD_WAIT_CV() --- */
 
 void
--- a/pr/src/md/prosdep.c
+++ b/pr/src/md/prosdep.c
@@ -57,17 +57,17 @@ PRInt32 _pr_pageSize;
 static void GetPageSize(void)
 {
 	PRInt32 pageSize;
 
     /* Get page size */
 #ifdef XP_UNIX
 #if defined SUNOS4 || defined LINUX || defined BSDI || defined AIX \
         || defined FREEBSD || defined NETBSD || defined OPENBSD \
-        || defined RHAPSODY || defined NEXTSTEP
+        || defined DARWIN || defined NEXTSTEP
     _pr_pageSize = getpagesize();
 #elif defined(HPUX)
     /* I have no idea. Don't get me started. --Rob */
     _pr_pageSize = sysconf(_SC_PAGE_SIZE);
 #else
     _pr_pageSize = sysconf(_SC_PAGESIZE);
 #endif
 #endif /* XP_UNIX */
--- a/pr/src/md/unix/unix.c
+++ b/pr/src/md/unix/unix.c
@@ -64,17 +64,17 @@
  * Make sure _PRSockLen_t is 32-bit, because we will cast a PRUint32* or
  * PRInt32* pointer to a _PRSockLen_t* pointer.
  */
 #if defined(HAVE_SOCKLEN_T)
 #define _PRSockLen_t socklen_t
 #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(RHAPSODY) \
+    || 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)
 #define _PRSockLen_t size_t
 #else
 #error "Cannot determine architecture"
--- a/pr/src/md/unix/unix_errors.c
+++ b/pr/src/md/unix/unix_errors.c
@@ -378,19 +378,24 @@ void _MD_unix_map_mkdir_error(int err)
     _MD_unix_map_default_error(err);
 }
 
 void _MD_unix_map_rmdir_error(int err)
 {
     PRErrorCode prError;
 
     switch (err) {
+        /*
+         * On AIX 4.3, ENOTEMPTY is defined as EEXIST.
+         */
+#if ENOTEMPTY != EEXIST
         case ENOTEMPTY:
             prError = PR_DIRECTORY_NOT_EMPTY_ERROR;
             break;
+#endif
         case EEXIST:
             prError = PR_DIRECTORY_NOT_EMPTY_ERROR;
             break;
         case EINVAL:
             prError = PR_DIRECTORY_NOT_EMPTY_ERROR;
             break;
         case ETIMEDOUT:
             prError = PR_REMOTE_FILE_ERROR;
--- a/pr/src/md/unix/uxproces.c
+++ b/pr/src/md/unix/uxproces.c
@@ -38,17 +38,17 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <sys/wait.h>
 #if defined(AIX)
 #include <dlfcn.h>  /* For dlopen, dlsym, dlclose */
 #endif
 
-#if defined(RHAPSODY)
+#if defined(DARWIN)
 #include <crt_externs.h>
 #else
 extern char **environ;
 #endif
 
 /*
  * HP-UX 9 doesn't have the SA_RESTART flag.
  */
@@ -178,17 +178,17 @@ ForkAndExec(
     if (!process) {
         PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
         return NULL;
     }
 
     childEnvp = envp;
     if (attr && attr->fdInheritBuffer) {
         if (NULL == childEnvp) {
-#ifdef RHAPSODY
+#ifdef DARWIN
             childEnvp = *(_NSGetEnviron());
 #else
             childEnvp = environ;
 #endif
         }
         for (nEnv = 0; childEnvp[nEnv]; nEnv++) {
         }
         newEnvp = (char **) PR_MALLOC((nEnv + 2) * sizeof(char *));
@@ -262,16 +262,56 @@ ForkAndExec(
            }
        }
     }
 }
 #endif /* VMS */
 
 #ifdef AIX
     process->md.pid = (*pr_wp.forkptr)();
+#elif defined(NTO)
+    /*
+     * fork() & exec() does not work in a multithreaded process.
+     * Use spawn() instead.
+     */
+    {
+        int fd_map[3] = { 0, 1, 2 };
+
+        if (attr) {
+            if (attr->stdinFd && attr->stdinFd->secret->md.osfd != 0) {
+                fd_map[0] = dup(attr->stdinFd->secret->md.osfd);
+                flags = fcntl(fd_map[0], F_GETFL, 0);
+                if (flags & O_NONBLOCK)
+                    fcntl(fd_map[0], F_SETFL, flags & ~O_NONBLOCK);
+            }
+            if (attr->stdoutFd && attr->stdoutFd->secret->md.osfd != 1) {
+                fd_map[1] = dup(attr->stdoutFd->secret->md.osfd);
+                flags = fcntl(fd_map[1], F_GETFL, 0);
+                if (flags & O_NONBLOCK)
+                    fcntl(fd_map[1], F_SETFL, flags & ~O_NONBLOCK);
+            }
+            if (attr->stderrFd && attr->stderrFd->secret->md.osfd != 2) {
+                fd_map[2] = dup(attr->stderrFd->secret->md.osfd);
+                flags = fcntl(fd_map[2], F_GETFL, 0);
+                if (flags & O_NONBLOCK)
+                    fcntl(fd_map[2], F_SETFL, flags & ~O_NONBLOCK);
+            }
+
+            PR_ASSERT(attr->currentDirectory == NULL);  /* not implemented */
+        }
+
+        process->md.pid = spawn(path, 3, fd_map, NULL, argv, childEnvp);
+
+        if (fd_map[0] != 0)
+            close(fd_map[0]);
+        if (fd_map[1] != 1)
+            close(fd_map[1]);
+        if (fd_map[2] != 2)
+            close(fd_map[2]);
+    }
 #else
     process->md.pid = fork();
 #endif
     if ((pid_t) -1 == process->md.pid) {
         PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, errno);
         PR_DELETE(process);
         if (newEnvp) {
             PR_DELETE(newEnvp);
@@ -280,16 +320,17 @@ ForkAndExec(
     } else if (0 == process->md.pid) {  /* the child process */
         /*
          * If the child process needs to exit, it must call _exit().
          * Do not call exit(), because exit() will flush and close
          * the standard I/O file descriptors, and hence corrupt
          * the parent process's standard I/O data structures.
          */
 
+#if !defined(NTO)
 #ifdef VMS
        /* OpenVMS has already handled all this above */
 #else
         if (attr) {
             /* the osfd's to redirect stdin, stdout, and stderr to */
             int in_osfd = -1, out_osfd = -1, err_osfd = -1;
 
             if (attr->stdinFd
@@ -362,16 +403,17 @@ ForkAndExec(
        }
        if (VMScurdir[0] != '\0')
            chdir(VMScurdir);
        PR_Unlock(_pr_vms_fork_lock);
        return NULL;
 #else
         _exit(1);
 #endif /* VMS */
+#endif /* !NTO */
     }
 
     if (newEnvp) {
         PR_DELETE(newEnvp);
     }
 #ifdef VMS
     /* If we switched directories, then remember to switch back */
     if (VMScurdir[0] != '\0') {
--- a/pr/src/md/unix/uxrng.c
+++ b/pr/src/md/unix/uxrng.c
@@ -273,17 +273,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(RHAPSODY)
+    || defined(QNX) || defined(DARWIN)
 #include <sys/times.h>
 
 static size_t
 GetHighResClock(void *buf, size_t maxbytes)
 {
     int ticks;
     struct tms buffer;
 
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -79,17 +79,17 @@ PRLock *_pr_dnsLock = NULL;
 
 /*
  * Some platforms have the reentrant getprotobyname_r() and
  * getprotobynumber_r().  However, they come in two flavors.
  * Some return a pointer to struct protoent, others return
  * an int.
  */
 
-#if defined(SOLARIS) \
+#if defined(SOLARIS) || (defined(BSDI) && defined(_REENTRANT)) \
 	|| (defined(LINUX) && defined(_REENTRANT) \
         && !(defined(__GLIBC__) && __GLIBC__ >= 2))
 #define _PR_HAVE_GETPROTO_R
 #define _PR_HAVE_GETPROTO_R_POINTER
 #endif
 
 #if defined(OSF1) \
         || defined(AIX4_3) || (defined(AIX) && defined(_THREAD_SAFE)) \
--- a/pr/src/misc/prsystem.c
+++ b/pr/src/misc/prsystem.c
@@ -46,17 +46,17 @@
 /* define the required constant if it is not already defined in the headers */
 #ifndef QSV_NUMPROCESSORS
 #define QSV_NUMPROCESSORS 26
 #endif
 #endif
 
 /* BSD-derived systems use sysctl() to get the number of processors */
 #if defined(BSDI) || defined(FREEBSD) || defined(NETBSD) \
-    || defined(OPENBSD) || defined(RHAPSODY)
+    || defined(OPENBSD) || defined(DARWIN)
 #define _PR_HAVE_SYSCTL
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #endif
 
 #if defined(HPUX)
 #include <sys/mp.h>
 #endif
--- a/pr/src/misc/prtime.c
+++ b/pr/src/misc/prtime.c
@@ -1578,22 +1578,23 @@ PR_ParseTimeString(
                   /* Set this to -1 to tell mktime "I don't care".  If you set
                      it to 0 or 1, you are making assertions about whether the
                      date you are handing it is in daylight savings mode or not;
                      and if you're wrong, it will "fix" it for you. */
                   localTime.tm_isdst = -1;
                   secs = mktime(&localTime);
                   if (secs != (time_t) -1)
                     {
-#if defined(XP_MAC)
+#if defined(XP_MAC) && (__MSL__ < 0x6000)
                       /*
                        * The mktime() routine in MetroWerks MSL C
                        * Runtime library returns seconds since midnight,
-                       * 1 Jan. 1900, not 1970.  So we need to adjust
-                       * its return value to the NSPR epoch.
+                       * 1 Jan. 1900, not 1970 - in versions of MSL (Metrowerks Standard
+                       * Library) prior to version 6.  Only for older versions of
+                       * MSL do we adjust the value of secs to the NSPR epoch
                        */
                       secs -= ((365 * 70UL) + 17) * 24 * 60 * 60;
 #endif
                       LL_I2L(*result, secs);
                       LL_I2L(usec_per_sec, PR_USEC_PER_SEC);
                       LL_MUL(*result, *result, usec_per_sec);
                       return PR_SUCCESS;
                     }
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -179,31 +179,31 @@ static ssize_t (*pt_aix_sendfile_fptr)()
 #if !(defined(LINUX) && defined(__alpha))
 #include <netinet/tcp.h>  /* TCP_NODELAY, TCP_MAXSEG */
 #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(RHAPSODY)
+    || defined(NTO) || defined(OPENBSD) || defined(DARWIN)
 #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(RHAPSODY)
+    || defined(BSDI) || defined(VMS) || defined(NTO) || defined(DARWIN)
 #define _PRSelectFdSetArg_t fd_set *
 #else
 #error "Cannot determine architecture"
 #endif
 
 static PRFileDesc *pt_SetMethods(
     PRIntn osfd, PRDescType type, PRBool isAcceptedSocket, PRBool imported);
 
@@ -2961,17 +2961,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(RHAPSODY)
+    || defined(DARWIN)
 #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/ptsynch.c
+++ b/pr/src/pthreads/ptsynch.c
@@ -439,16 +439,18 @@ PR_IMPLEMENT(PRMonitor*) PR_NewMonitor(v
     }
     mon = PR_NEWZAP(PRMonitor);
     if (mon != NULL)
     {
         int rv;
         rv = _PT_PTHREAD_MUTEX_INIT(mon->lock.mutex, _pt_mattr); 
         PR_ASSERT(0 == rv);
 
+        _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner);
+
         mon->cvar = cvar;
         rv = _PT_PTHREAD_COND_INIT(mon->cvar->cv, _pt_cvar_attr); 
         PR_ASSERT(0 == rv);
         mon->entryCount = 0;
         mon->cvar->lock = &mon->lock;
         if (0 != rv)
         {
             PR_DELETE(mon);
@@ -479,119 +481,120 @@ PR_IMPLEMENT(void) PR_DestroyMonitor(PRM
 }  /* PR_DestroyMonitor */
 
 
 /* The GC uses this; it is quite arguably a bad interface.  I'm just 
  * duplicating it for now - XXXMB
  */
 PR_IMPLEMENT(PRInt32) PR_GetMonitorEntryCount(PRMonitor *mon)
 {
-    PRThread *self = PR_GetCurrentThread();
-    if (mon->owner == self)
+    pthread_t self = pthread_self();
+    if (pthread_equal(mon->owner, self))
         return mon->entryCount;
     return 0;
 }
 
 PR_IMPLEMENT(void) PR_EnterMonitor(PRMonitor *mon)
 {
-    PRThread *self = PR_GetCurrentThread();
+    pthread_t self = pthread_self();
 
     PR_ASSERT(mon != NULL);
     /*
-     * This is safe only if mon->owner (a PRThread*) can be
-     * read in one instruction.
+     * This is safe only if mon->owner (a pthread_t) can be
+     * read in one instruction.  Perhaps mon->owner should be
+     * a "PRThread *"?
      */
-    if (mon->owner != self)
+    if (!pthread_equal(mon->owner, self))
     {
         PR_Lock(&mon->lock);
         /* and now I have the lock */
         PR_ASSERT(0 == mon->entryCount);
-        PR_ASSERT(NULL == mon->owner);
-        mon->owner = self;
+        PR_ASSERT(_PT_PTHREAD_THR_HANDLE_IS_INVALID(mon->owner));
+        _PT_PTHREAD_COPY_THR_HANDLE(self, mon->owner);
     }
     mon->entryCount += 1;
 }  /* PR_EnterMonitor */
 
 PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PRMonitor *mon)
 {
-    PRThread *self = PR_GetCurrentThread();
+    pthread_t self = pthread_self();
 
     PR_ASSERT(mon != NULL);
     /* The lock better be that - locked */
     PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
     /* we'd better be the owner */
-    PR_ASSERT(mon->owner == self);
-    if (mon->owner != self)
+    PR_ASSERT(pthread_equal(mon->owner, self));
+    if (!pthread_equal(mon->owner, self))
         return PR_FAILURE;
 
     /* if it's locked and we have it, then the entries should be > 0 */
     PR_ASSERT(mon->entryCount > 0);
     mon->entryCount -= 1;  /* reduce by one */
     if (mon->entryCount == 0)
     {
         /* and if it transitioned to zero - unlock */
-        mon->owner = NULL;  /* make the owner unknown */
+        _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner);  /* make the owner unknown */
         PR_Unlock(&mon->lock);
     }
     return PR_SUCCESS;
 }  /* PR_ExitMonitor */
 
 PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime timeout)
 {
     PRStatus rv;
     PRInt16 saved_entries;
-    PRThread *saved_owner;
+    pthread_t saved_owner;
 
     PR_ASSERT(mon != NULL);
     /* we'd better be locked */
     PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
     /* and the entries better be positive */
     PR_ASSERT(mon->entryCount > 0);
     /* and it better be by us */
-    PR_ASSERT(mon->owner == PR_GetCurrentThread());
+    PR_ASSERT(pthread_equal(mon->owner, pthread_self()));
 
     /* tuck these away 'till later */
     saved_entries = mon->entryCount; 
     mon->entryCount = 0;
-    saved_owner = mon->owner;
-    mon->owner = NULL;
+    _PT_PTHREAD_COPY_THR_HANDLE(mon->owner, saved_owner);
+    _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner);
     
     rv = PR_WaitCondVar(mon->cvar, timeout);
 
     /* reinstate the intresting information */
     mon->entryCount = saved_entries;
-    mon->owner = saved_owner;
+    _PT_PTHREAD_COPY_THR_HANDLE(saved_owner, mon->owner);
 
     return rv;
 }  /* PR_Wait */
 
 PR_IMPLEMENT(PRStatus) PR_Notify(PRMonitor *mon)
 {
     PR_ASSERT(NULL != mon);
     /* we'd better be locked */
     PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
     /* and the entries better be positive */
     PR_ASSERT(mon->entryCount > 0);
     /* and it better be by us */
-    PR_ASSERT(mon->owner == PR_GetCurrentThread());
+    PR_ASSERT(pthread_equal(mon->owner, pthread_self()));
 
     pt_PostNotifyToCvar(mon->cvar, PR_FALSE);
 
     return PR_SUCCESS;
 }  /* PR_Notify */
 
 PR_IMPLEMENT(PRStatus) PR_NotifyAll(PRMonitor *mon)
 {
     PR_ASSERT(mon != NULL);
     /* we'd better be locked */
     PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(mon->lock.mutex));
     /* and the entries better be positive */
     PR_ASSERT(mon->entryCount > 0);
     /* and it better be by us */
-    PR_ASSERT(mon->owner == PR_GetCurrentThread());
+    PR_ASSERT(pthread_equal(mon->owner, pthread_self()));
 
     pt_PostNotifyToCvar(mon->cvar, PR_TRUE);
 
     return PR_SUCCESS;
 }  /* PR_NotifyAll */
 
 /**************************************************************/
 /**************************************************************/
--- a/pr/tests/Makefile.in
+++ b/pr/tests/Makefile.in
@@ -419,17 +419,17 @@ EXTRA_LIBS = -ldl
 endif
 endif
 
 ifeq ($(USE_PTHREADS),1)
 LIBPTHREAD = -lpthread
 ifeq ($(OS_ARCH),AIX)
 LIBPTHREAD = -lpthreads
 endif
-ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO Rhapsody,$(OS_ARCH)))
+ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO Darwin,$(OS_ARCH)))
 LIBPTHREAD =
 endif
 ifeq ($(OS_ARCH)$(basename $(OS_RELEASE)),HP-UXB.10)
 LIBPTHREAD = -ldce
 endif
 endif
 
 
--- a/pr/tests/dll/Makefile.in
+++ b/pr/tests/dll/Makefile.in
@@ -86,17 +86,17 @@ SHARED_LIBRARY	= $(OBJDIR)/libmy.$(DLL_S
 endif
 TARGETS		= $(SHARED_LIBRARY)
 endif
 
 #
 # To create a loadable module on Rhapsody, we must override
 # -dynamiclib with -bundle.
 #
-ifeq ($(OS_ARCH),Rhapsody)
+ifeq ($(OS_ARCH),Darwin)
 DSO_LDOPTS = -bundle
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(OS_TARGET), WIN16)
 # Note: The Win16 target: my.dll requires these macros
 # to be overridden to build the test .dll