Update NSPR to the NSPR_HEAD_20090828 CVS tag. Contains fixes
authorWan-Teh Chang <wtc@google.com>
Fri, 28 Aug 2009 19:53:48 -0700
changeset 32078 5375876a9319a105159767a755fd149635302701
parent 32077 3c4645c657add4e5c11e3f915c2b054b564cddfd
child 32079 80f4cdc242b90485fca542a7dd56997d3abaa01b
push id8832
push userwtc@google.com
push dateSat, 29 Aug 2009 02:54:04 +0000
treeherdermozilla-central@5375876a9319 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs366194, 506502, 508165, 509243, 510705, 511315, 512806
milestone1.9.3a1pre
Update NSPR to the NSPR_HEAD_20090828 CVS tag. Contains fixes for bug 366194, bug 506502, bug 508165, bug 509243, bug 510705, bug 511315, bug 512806.
nsprpub/config/prdepend.h
nsprpub/configure
nsprpub/configure.in
nsprpub/lib/ds/Makefile.in
nsprpub/lib/libc/include/Makefile.in
nsprpub/lib/libc/src/Makefile.in
nsprpub/lib/msgc/include/Makefile.in
nsprpub/lib/msgc/src/Makefile.in
nsprpub/pr/include/md/_os2.h
nsprpub/pr/include/md/_riscos.h
nsprpub/pr/include/md/_win95.h
nsprpub/pr/include/prlink.h
nsprpub/pr/src/Makefile.in
nsprpub/pr/src/linking/prlink.c
nsprpub/pr/src/md/os2/os2misc.c
nsprpub/pr/src/md/windows/ntmisc.c
nsprpub/pr/src/misc/prtime.c
nsprpub/pr/tests/Makefile.in
--- a/nsprpub/config/prdepend.h
+++ b/nsprpub/config/prdepend.h
@@ -37,9 +37,8 @@
 
 /*
  * A dummy header file that is a dependency for all the object files.
  * Used to force a full recompilation of NSPR in Mozilla's Tinderbox
  * depend builds.  See comments in rules.mk.
  */
 
 #error "Do not include this header file."
-
--- a/nsprpub/configure
+++ b/nsprpub/configure
@@ -2783,16 +2783,17 @@ if test -n "$CROSS_COMPILE"; then
     OS_RELEASE=
     OS_TEST="${target_cpu}"
     case "${target_os}" in
         linux*)       OS_ARCH=Linux ;;
         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
         mingw*)       OS_ARCH=WINNT ;;
         wince*)       OS_ARCH=WINCE ;;
         darwin*)      OS_ARCH=Darwin ;;
+        riscos*)      OS_ARCH=RISCOS ;;
     esac
 else
     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
     OS_RELEASE=`uname -r`
     OS_TEST=`uname -m`
 fi
 
 if test "$OS_ARCH" = "IRIX64"; then
@@ -2969,27 +2970,27 @@ EOF
 
     cat >> confdefs.h <<\EOF
 #define SYSV 1
 EOF
 
     DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
     ac_safe=`echo "sys/atomic_op.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/atomic_op.h""... $ac_c" 1>&6
-echo "configure:2978: checking for sys/atomic_op.h" >&5
+echo "configure:2979: 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 2983 "configure"
+#line 2984 "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:2988: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2989: \"$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
@@ -3136,36 +3137,36 @@ EOF
     PR_MD_ARCH_DIR=beos
     RESOLVE_LINK_SYMBOLS=1
     case "${target_cpu}" in
     i*86)
         _OPTIMIZE_FLAGS=-O2
         _DEBUG_FLAGS='-gdwarf-2 -O0'
         MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
         echo $ac_n "checking for gethostbyaddr in -lbind""... $ac_c" 1>&6
-echo "configure:3145: checking for gethostbyaddr in -lbind" >&5
+echo "configure:3146: checking for gethostbyaddr in -lbind" >&5
 ac_lib_var=`echo bind'_'gethostbyaddr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3153 "configure"
+#line 3154 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
 char gethostbyaddr();
 
 int main() {
 gethostbyaddr()
 ; return 0; }
 EOF
-if { (eval echo configure:3164: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3165: \"$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
@@ -4222,19 +4223,19 @@ EOF
     RESOLVE_LINK_SYMBOLS=1
 
     MDCPUCFG_H=_win95.cfg
     LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
     LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
 
     DLLFLAGS='-OUT:"$@"'
     if test -n "$MOZ_DEBUG_SYMBOLS"; then
-        OS_LDFLAGS=-DEBUG -DEBUGTYPE:CV
-        OS_DLLFLAGS=-DEBUG -DEBUGTYPE:CV
-        DSO_LDOPTS=-DEBUG -DEBUGTYPE:CV
+        OS_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
+        OS_DLLFLAGS='-DEBUG -DEBUGTYPE:CV'
+        DSO_LDOPTS='-DEBUG -DEBUGTYPE:CV'
     fi
     _DEBUG_FLAGS=-Zi
     _OPTIMIZE_FLAGS=-O2
     ;;
 
 *-ncr-sysv*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
@@ -4501,27 +4502,27 @@ EOF
     if test -z "$GNU_CC"; then
         CC="$CC -std1 -ieee_with_inexact"
         if test "$OS_RELEASE" != "V2.0"; then
             CC="$CC -readonly_strings"
         fi
         _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
         ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6
-echo "configure:4510: checking for machine/builtins.h" >&5
+echo "configure:4511: 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 4515 "configure"
+#line 4516 "configure"
 #include "confdefs.h"
 #include <machine/builtins.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4520: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4521: \"$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
@@ -4600,18 +4601,19 @@ EOF
 
     cat >> confdefs.h <<\EOF
 #define _PR_NEED_H_ERRNO 1
 EOF
 
     USE_PTHREADS=1
     MDCPUCFG_H=_riscos.cfg
     PR_MD_CSRCS=riscos.c
-    DLL_SUFFIX=a
-    LD="/home/riscos/env/ro-ar cr"
+    DSO_CFLAGS=-fPIC
+    DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     ;;
 
 *-*-sco*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
     cat >> confdefs.h <<\EOF
@@ -5127,17 +5129,16 @@ EOF
     DSO_CFLAGS=
     DSO_LDOPTS='-Zomf -Zdll'
     LDFLAGS='-Zmap'
     _OPTIMIZE_FLAGS="-O2 -s"
     _DEBUG_FLAGS="-g -fno-inline"
     if test -n "$MOZ_OPTIMIZE"; then
       DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
     fi
-    OS_LIBS="-lsocket"
     IMPLIB='emximp -o'
     FILTER='emxexp -o'
     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
       LDFLAGS="$LDFLAGS -Zhigh-mem"
       cat >> confdefs.h <<\EOF
 #define MOZ_OS2_HIGH_MEMORY 1
 EOF
 
@@ -5156,67 +5157,67 @@ EOF
    
 esac
 
 if test -z "$SKIP_LIBRARY_CHECKS"; then
 
 
 
 case $target in
-*-darwin*|*-beos*)
+*-darwin*|*-beos*|*-os2*)
     ;;
 *)
     echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:5169: checking for dlopen in -ldl" >&5
+echo "configure:5170: 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 5177 "configure"
+#line 5178 "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:5188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5189: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:5205: checking for dlfcn.h" >&5
+echo "configure:5206: checking for dlfcn.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5210 "configure"
+#line 5211 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5215: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5216: \"$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
@@ -5239,23 +5240,23 @@ fi
     ;;
 esac
 
 
 
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:5248: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:5249: 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 5254 "configure"
+#line 5255 "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
@@ -5263,17 +5264,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 5272 "configure"
+#line 5273 "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
@@ -5287,22 +5288,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:5296: checking for $ac_func" >&5
+echo "configure:5297: 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 5301 "configure"
+#line 5302 "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();
@@ -5315,17 +5316,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:5324: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5325: \"$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
@@ -5356,17 +5357,17 @@ if test "${enable_strip+set}" = set; the
 fi
 
 
 case "${target_os}" in
 hpux*)
 if test -z "$GNU_CC"; then
 
     echo $ac_n "checking for +Olit support""... $ac_c" 1>&6
-echo "configure:5365: checking for +Olit support" >&5
+echo "configure:5366: checking for +Olit support" >&5
 if eval "test \"`echo '$''{'ac_cv_hpux_usable_olit_option'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
                   ac_cv_hpux_usable_olit_option=no
         rm -f conftest*
         echo 'int main() { return 0; }' | cat > conftest.c
         ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
         if test $? -eq 0; then
@@ -5395,17 +5396,17 @@ esac
 
 case "$target_os" in
 darwin*)
     _HAVE_PTHREADS=1
     ;;
 *)
     
 echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:5404: checking for pthread_create in -lpthreads" >&5
+echo "configure:5405: checking for pthread_create in -lpthreads" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5417,17 +5418,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:5426: checking for pthread_create in -lpthread" >&5
+echo "configure:5427: checking for pthread_create in -lpthread" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5439,17 +5440,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:5448: checking for pthread_create in -lc_r" >&5
+echo "configure:5449: checking for pthread_create in -lc_r" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5461,17 +5462,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:5470: checking for pthread_create in -lc" >&5
+echo "configure:5471: checking for pthread_create in -lc" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5593,17 +5594,17 @@ EOF
     fi
 fi
 
 
 if test -n "$USE_PTHREADS"; then
       rm -f conftest*
    ac_cv_have_dash_pthread=no
    echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6
-echo "configure:5602: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5603: checking whether ${CC-cc} accepts -pthread" >&5
    echo 'int main() { return 0; }' | cat > conftest.c
    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
    if test $? -eq 0; then
 	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
 	    ac_cv_have_dash_pthread=yes
 		case "$target_os" in
 	    freebsd*)
 # Freebsd doesn't use -pthread for compiles, it uses them for linking
@@ -5616,17 +5617,17 @@ echo "configure:5602: checking whether $
 	fi
     fi
     rm -f conftest*
     echo "$ac_t""$ac_cv_have_dash_pthread" 1>&6
 
 			    ac_cv_have_dash_pthreads=no
     if test "$ac_cv_have_dash_pthread" = "no"; then
 	    echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6
-echo "configure:5625: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5626: checking whether ${CC-cc} accepts -pthreads" >&5
     	echo 'int main() { return 0; }' | cat > conftest.c
 	    ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
     	if test $? -eq 0; then
 	    	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
 			    ac_cv_have_dash_pthreads=yes
 			    CFLAGS="$CFLAGS -pthreads"
 			    CXXFLAGS="$CXXFLAGS -pthreads"
 		    fi
--- a/nsprpub/configure.in
+++ b/nsprpub/configure.in
@@ -644,16 +644,17 @@ if test -n "$CROSS_COMPILE"; then
     OS_RELEASE=
     OS_TEST="${target_cpu}"
     case "${target_os}" in
         linux*)       OS_ARCH=Linux ;;
         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
         mingw*)       OS_ARCH=WINNT ;;
         wince*)       OS_ARCH=WINCE ;;
         darwin*)      OS_ARCH=Darwin ;;
+        riscos*)      OS_ARCH=RISCOS ;;
     esac
 else
     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
     OS_RELEASE=`uname -r`
     OS_TEST=`uname -m`
 fi
 
 if test "$OS_ARCH" = "IRIX64"; then
@@ -1674,19 +1675,19 @@ tools are selected during the Xcode/Deve
     RESOLVE_LINK_SYMBOLS=1
 
     MDCPUCFG_H=_win95.cfg
     LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
     LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
 
     DLLFLAGS='-OUT:"$@"'
     if test -n "$MOZ_DEBUG_SYMBOLS"; then
-        OS_LDFLAGS=-DEBUG -DEBUGTYPE:CV
-        OS_DLLFLAGS=-DEBUG -DEBUGTYPE:CV
-        DSO_LDOPTS=-DEBUG -DEBUGTYPE:CV
+        OS_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
+        OS_DLLFLAGS='-DEBUG -DEBUGTYPE:CV'
+        DSO_LDOPTS='-DEBUG -DEBUGTYPE:CV'
     fi
     _DEBUG_FLAGS=-Zi
     _OPTIMIZE_FLAGS=-O2
     ;;
 
 *-ncr-sysv*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(SVR4)
@@ -1876,18 +1877,19 @@ mips-sony-newsos*)
 
 *-riscos*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(RISCOS)
     AC_DEFINE(_PR_NEED_H_ERRNO)
     USE_PTHREADS=1
     MDCPUCFG_H=_riscos.cfg
     PR_MD_CSRCS=riscos.c
-    DLL_SUFFIX=a
-    LD="/home/riscos/env/ro-ar cr"
+    DSO_CFLAGS=-fPIC
+    DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     ;;
 
 *-*-sco*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(SCO)
     AC_DEFINE(sco)
     AC_DEFINE(SYSV)
     AC_DEFINE(_SVID3)
@@ -2224,17 +2226,16 @@ mips-sony-newsos*)
     DSO_CFLAGS=
     DSO_LDOPTS='-Zomf -Zdll'
     LDFLAGS='-Zmap'
     _OPTIMIZE_FLAGS="-O2 -s"
     _DEBUG_FLAGS="-g -fno-inline"
     if test -n "$MOZ_OPTIMIZE"; then
       DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
     fi
-    OS_LIBS="-lsocket"
     IMPLIB='emximp -o'
     FILTER='emxexp -o'
     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
       LDFLAGS="$LDFLAGS -Zhigh-mem"
       AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
     fi
 
     # GCC for OS/2 currently predefines these, but we don't want them
@@ -2274,19 +2275,20 @@ dnl AC_CHECK_LIB(socket, main)
 dnl AC_CHECK_LIB(svld, main)
 dnl AC_CHECK_LIB(thread, main)
 dnl AC_CHECK_LIB(vms_jackets, main)
 
 
 dnl We don't want anything to link with libdl even if it's present on OS X, 
 dnl since it's not used and not part of the default installation.
 dnl The same goes for BeOS.
+dnl OS/2 has dlfcn in libc.
 
 case $target in
-*-darwin*|*-beos*)
+*-darwin*|*-beos*|*-os2*)
     ;;
 *)
     AC_CHECK_LIB(dl, dlopen,
         AC_CHECK_HEADER(dlfcn.h,
             OS_LIBS="-ldl $OS_LIBS"))
     ;;
 esac
 
--- a/nsprpub/lib/ds/Makefile.in
+++ b/nsprpub/lib/ds/Makefile.in
@@ -179,15 +179,8 @@ export:: $(TARGETS)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
 	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_libdir)
 	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_bindir)
 else
 	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_bindir)
 endif
 endif
-ifeq ($(MOZ_BITS),16)
-	$(INSTALL) -m 444 $(HEADERS) $(MOZ_INCL)
-	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
-	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
-endif
-
-
--- a/nsprpub/lib/libc/include/Makefile.in
+++ b/nsprpub/lib/libc/include/Makefile.in
@@ -49,13 +49,8 @@ HEADERS = $(wildcard $(srcdir)/*.h)
 
 RELEASE_HEADERS = $(HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(HEADERS)
 	$(INSTALL) -m 444 $(HEADERS) $(dist_includedir)
-ifeq ($(MOZ_BITS),16)
-	$(INSTALL) -m 444 $(HEADERS) $(MOZ_INCL)
-endif
-
-
--- a/nsprpub/lib/libc/src/Makefile.in
+++ b/nsprpub/lib/libc/src/Makefile.in
@@ -180,13 +180,8 @@ export:: $(TARGETS)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
 	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_libdir)
 	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_bindir)
 else
 	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_bindir)
 endif
 endif
-ifeq ($(MOZ_BITS),16)
-	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
-	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
-endif
-
--- a/nsprpub/lib/msgc/include/Makefile.in
+++ b/nsprpub/lib/msgc/include/Makefile.in
@@ -50,12 +50,8 @@ HEADERS = $(EXPORT_HEADERS) gcint.h
 
 RELEASE_HEADERS = $(EXPORT_HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(EXPORT_HEADERS)
 	$(INSTALL) -m 444 $(EXPORT_HEADERS) $(dist_includedir)
-ifeq ($(MOZ_BITS),16)
-	$(INSTALL) -m 444 $(EXPORT_HEADERS) $(MOZ_INCL)
-endif
-
--- a/nsprpub/lib/msgc/src/Makefile.in
+++ b/nsprpub/lib/msgc/src/Makefile.in
@@ -86,13 +86,8 @@ include $(topsrcdir)/config/rules.mk
 # so we also install them there.
 #
 
 export:: $(TARGETS)
 	$(INSTALL) -m 444 $(TARGETS) $(dist_libdir)
 ifdef SHARED_LIBRARY
 	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_bindir)
 endif
-ifeq ($(MOZ_BITS),16)
-	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
-	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
-endif	
-
--- a/nsprpub/pr/include/md/_os2.h
+++ b/nsprpub/pr/include/md/_os2.h
@@ -445,20 +445,22 @@ extern struct PRThread * _MD_CURRENT_THR
 
 /* --- Initialization stuff --- */
 #define _MD_INIT_LOCKS()
 
 /* --- Stack stuff --- */
 #define _MD_INIT_STACK(stack, redzone)
 #define _MD_CLEAR_STACK(stack)
 
-/* --- Memory-mapped files stuff --- not implemented on OS/2 */
-
+/* --- Memory-mapped files stuff --- */
+/* ReadOnly and WriteCopy modes are simulated on OS/2;
+ * ReadWrite mode is not supported.
+ */
 struct _MDFileMap {
-    PRInt8 unused;
+    PROffset64  maxExtent;
 };
 
 extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
 #define _MD_CREATE_FILE_MAP _MD_CreateFileMap
 
 extern PRInt32 _MD_GetMemMapAlignment(void);
 #define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment
 
--- a/nsprpub/pr/include/md/_riscos.h
+++ b/nsprpub/pr/include/md/_riscos.h
@@ -39,34 +39,34 @@
 #define nspr_riscos_defs_h___
 
 /*
 ** Internal configuration macros
 */
 #define PR_LINKER_ARCH		"riscos"
 #define _PR_SI_SYSNAME		"RISCOS"
 #define _PR_SI_ARCHITECTURE	"arm"
-#define PR_DLL_SUFFIX		".a"
+#define PR_DLL_SUFFIX		".so"
 
 #define _PR_POLL_AVAILABLE
 #define _PR_USE_POLL
 #define _PR_HAVE_SOCKADDR_LEN
 #undef HAVE_BSD_FLOCK
 #define _PR_NO_LARGE_FILES
 #define _PR_STAT_HAS_ONLY_ST_ATIME
 #define _PR_HAVE_POSIX_SEMAPHORES
 
 #include <sys/select.h>
 #include <sys/poll.h>
 #include <kernel.h>
 
 
 #undef  HAVE_STACK_GROWING_UP
-#undef  HAVE_DLL
-#undef  USE_DLFCN
+#define HAVE_DLL
+#define USE_DLFCN
 #define NEED_STRFTIME_LOCK
 #define NEED_TIME_R
 #define PT_NO_SIGTIMEDWAIT
 
 #ifndef HAVE_STRERROR
 #define HAVE_STRERROR
 #endif
 
--- a/nsprpub/pr/include/md/_win95.h
+++ b/nsprpub/pr/include/md/_win95.h
@@ -482,16 +482,21 @@ extern PRStatus _PR_KillWindowsProcess(s
 #define _MD_GET_INTERVAL                  _PR_MD_GET_INTERVAL
 #define _MD_INTERVAL_PER_SEC              _PR_MD_INTERVAL_PER_SEC
 #define _MD_INTERVAL_PER_MILLISEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000)
 #define _MD_INTERVAL_PER_MICROSEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000000)
 
 /* --- Time --- */
 extern void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm);
 
+#ifdef WINCE
+extern void _MD_InitTime(void);
+extern void _MD_CleanupTime(void);
+#endif
+
 /* --- Native-Thread Specific Definitions ------------------------------- */
 
 extern struct PRThread * _MD_CURRENT_THREAD(void);
 
 #ifdef _PR_USE_STATIC_TLS
 extern __declspec(thread) struct PRThread *_pr_currentThread;
 #define _MD_GET_ATTACHED_THREAD() _pr_currentThread
 #define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread))
--- a/nsprpub/pr/include/prlink.h
+++ b/nsprpub/pr/include/prlink.h
@@ -160,16 +160,18 @@ typedef struct PRLibSpec {
 ** as the 'flags' argument to PR_LoadLibraryWithFlags.
 ** Flags not supported by the underlying OS are ignored.
 */
 
 #define PR_LD_LAZY   0x1  /* equivalent to RTLD_LAZY on Unix */
 #define PR_LD_NOW    0x2  /* equivalent to RTLD_NOW on Unix */
 #define PR_LD_GLOBAL 0x4  /* equivalent to RTLD_GLOBAL on Unix */
 #define PR_LD_LOCAL  0x8  /* equivalent to RTLD_LOCAL on Unix */
+/* The following is equivalent to LOAD_WITH_ALTERED_SEARCH_PATH on Windows */
+#define PR_LD_ALT_SEARCH_PATH  0x10  
 /*                0x8000     reserved for NSPR internal use */
 
 /*
 ** Load the specified library, in the manner specified by 'flags'.
 */
 
 NSPR_API(PRLibrary *)
 PR_LoadLibraryWithFlags(
--- a/nsprpub/pr/src/Makefile.in
+++ b/nsprpub/pr/src/Makefile.in
@@ -393,19 +393,13 @@ export:: $(TARGETS)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
 	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_libdir)
 	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_bindir)
 else
 	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_bindir)
 endif
 endif
-ifeq ($(MOZ_BITS),16)
-	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
-	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
-endif
 
 ifeq ($(BUILD_AIX_RTL_LIBC),1)
 $(AIX_RTL_LIBC): /usr/ccs/lib/libc.a
 	rtl_enable -o $@ $<
 endif
-
-
--- a/nsprpub/pr/src/linking/prlink.c
+++ b/nsprpub/pr/src/linking/prlink.c
@@ -183,28 +183,22 @@ void _PR_InitLinker(void)
     if (!pr_linker_lock) {
         pr_linker_lock = PR_NewNamedMonitor("linker-lock");
     }
     PR_EnterMonitor(pr_linker_lock);
 
 #if defined(XP_PC)
     lm = PR_NEWZAP(PRLibrary);
     lm->name = strdup("Executable");
-        /* 
-        ** In WIN32, GetProcAddress(...) expects a module handle in order to
-        ** get exported symbols from the executable...
-        **
-        ** However, in WIN16 this is accomplished by passing NULL to 
-        ** GetProcAddress(...)
-        */
-#if defined(_WIN32)
-        lm->dlh = GetModuleHandle(NULL);
+#if defined(XP_OS2)
+    lm->dlh = NULLHANDLE;
 #else
-        lm->dlh = (HINSTANCE)NULL;
-#endif /* ! _WIN32 */
+    /* A module handle for the executable. */
+    lm->dlh = GetModuleHandle(NULL);
+#endif /* ! XP_OS2 */
 
     lm->refCount    = 1;
     lm->staticTable = NULL;
     pr_exe_loadmap  = lm;
     pr_loadmap      = lm;
 
 #elif defined(XP_UNIX)
 #ifdef HAVE_DLL
@@ -753,17 +747,19 @@ pr_LoadLibraryByPathname(const char *nam
           pr_loadmap = lm;
     }
 #endif /* XP_OS2 */
 
 #ifdef WIN32
     {
     HINSTANCE h;
 
-    h = LoadLibraryW(wname);
+    h = LoadLibraryExW(wname, NULL,
+                       (flags & PR_LD_ALT_SEARCH_PATH) ?
+                       LOAD_WITH_ALTERED_SEARCH_PATH : 0);
     if (h == NULL) {
         oserr = _MD_ERRNO();
         PR_DELETE(lm);
         goto unlock;
     }
     lm->name = strdup(utf8name);
     lm->dlh = h;
     lm->next = pr_loadmap;
--- a/nsprpub/pr/src/md/os2/os2misc.c
+++ b/nsprpub/pr/src/md/os2/os2misc.c
@@ -16,16 +16,17 @@
  *
  * The Initial Developer of the Original Code is
  * Netscape Communications Corporation.
  * Portions created by the Initial Developer are Copyright (C) 1998-2000
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Davide Bresolin <davide@teamos2.it>
+ *   Rich Walsh <dragtext@e-vertise.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -539,50 +540,114 @@ PRStatus _MD_OS2GetHostName(char *name, 
 }
 
 void
 _PR_MD_WAKEUP_CPUS( void )
 {
     return;
 }    
 
-
 /*
  **********************************************************************
  *
- * Memory-mapped files are not supported on OS/2 (or Win16).
+ * Memory-mapped files
+ *
+ * A credible emulation of memory-mapped i/o on OS/2 would require
+ * an exception-handler on each thread that might access the mapped
+ * memory.  In the Mozilla environment, that would be impractical.
+ * Instead, the following simulates those modes which don't modify
+ * the mapped file.  It reads the entire mapped file segment at once
+ * when MemMap is called, and frees it on MemUnmap.  CreateFileMap
+ * only does sanity-checks, while CloseFileMap does almost nothing.
  *
  **********************************************************************
  */
 
 PRStatus _MD_CreateFileMap(PRFileMap *fmap, PRInt64 size)
 {
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return PR_FAILURE;
+    PRFileInfo64 info;
+
+    /* assert on PR_PROT_READWRITE which modifies the underlying file */
+    PR_ASSERT(fmap->prot == PR_PROT_READONLY ||
+              fmap->prot == PR_PROT_WRITECOPY);
+    if (fmap->prot != PR_PROT_READONLY &&
+        fmap->prot != PR_PROT_WRITECOPY) {
+        PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
+        return PR_FAILURE;
+    }
+    if (PR_GetOpenFileInfo64(fmap->fd, &info) == PR_FAILURE) {
+        return PR_FAILURE;
+    }
+    /* reject zero-byte mappings & zero-byte files */
+    if (!size || !info.size) {
+        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
+        return PR_FAILURE;
+    }
+    /* file size rounded up to the next page boundary */
+    fmap->md.maxExtent = (info.size + 0xfff) & ~(0xfff);
+
+    return PR_SUCCESS;
 }
 
 PRInt32 _MD_GetMemMapAlignment(void)
 {
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return -1;
+    /* OS/2 pages are 4k */
+    return 0x1000;
 }
 
-void * _MD_MemMap(
-    PRFileMap *fmap,
-    PROffset64 offset,
-    PRUint32 len)
+void * _MD_MemMap(PRFileMap *fmap, PROffset64 offset, PRUint32 len)
 {
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return NULL;
+    PRUint32 rv;
+    void *addr;
+
+    /* prevent mappings beyond EOF + remainder of page */
+    if (offset + len > fmap->md.maxExtent) {
+        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
+        return NULL;
+    }
+    if (PR_Seek64(fmap->fd, offset, PR_SEEK_SET) == -1) {
+        return NULL;
+    }
+    /* try for high memory, fall back to low memory if hi-mem fails */
+    rv = DosAllocMem(&addr, len, OBJ_ANY | PAG_COMMIT | PAG_READ | PAG_WRITE);
+    if (rv) {
+        rv = DosAllocMem(&addr, len, PAG_COMMIT | PAG_READ | PAG_WRITE);
+        if (rv) {
+            PR_SetError(PR_OUT_OF_MEMORY_ERROR, rv);
+            return NULL;
+        }
+    }
+    if (PR_Read(fmap->fd, addr, len) == -1) {
+        DosFreeMem(addr);
+        return NULL;
+    }
+    /* don't permit writes if readonly */
+    if (fmap->prot == PR_PROT_READONLY) {
+        rv = DosSetMem(addr, len, PAG_READ);
+        if (rv) {
+            DosFreeMem(addr);
+            PR_SetError(PR_UNKNOWN_ERROR, rv);
+            return NULL;
+        }
+    }
+    return addr;
 }
 
 PRStatus _MD_MemUnmap(void *addr, PRUint32 len)
 {
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return PR_FAILURE;
+    PRUint32 rv;
+
+    /* we just have to trust that addr & len are those used by MemMap */
+    rv = DosFreeMem(addr);
+    if (rv) {
+        PR_SetError(PR_INVALID_ARGUMENT_ERROR, rv);
+        return PR_FAILURE;
+    }
+    return PR_SUCCESS;
 }
 
 PRStatus _MD_CloseFileMap(PRFileMap *fmap)
 {
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return PR_FAILURE;
+    /* nothing to do except free the PRFileMap struct */
+    PR_Free(fmap);
+    return PR_SUCCESS;
 }
 
--- a/nsprpub/pr/src/md/windows/ntmisc.c
+++ b/nsprpub/pr/src/md/windows/ntmisc.c
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
@@ -71,23 +71,25 @@ PRIntn _PR_MD_PUT_ENV(const char *name)
  */
 
 /*
  * The NSPR epoch (00:00:00 1 Jan 1970 UTC) in FILETIME.
  * We store the value in a PRTime variable for convenience.
  */
 #ifdef __GNUC__
 const PRTime _pr_filetime_offset = 116444736000000000LL;
+const PRTime _pr_filetime_divisor = 10LL;
 #else
 const PRTime _pr_filetime_offset = 116444736000000000i64;
+const PRTime _pr_filetime_divisor = 10i64;
 #endif
 
 #ifdef WINCE
 
-#define FILETIME2INT64(ft) \
+#define FILETIME_TO_INT64(ft) \
   (((PRInt64)ft.dwHighDateTime) << 32 | (PRInt64)ft.dwLowDateTime)
 
 static void
 LowResTime(LPFILETIME lpft)
 {
     GetCurrentFT(lpft);
 }
 
@@ -103,16 +105,19 @@ typedef struct CalibrationData {
 
     CRITICAL_SECTION data_lock;
     CRITICAL_SECTION calibration_lock;
     PRInt64 granularity;
 } CalibrationData;
 
 static CalibrationData calibration;
 
+typedef void (*GetSystemTimeAsFileTimeFcn)(LPFILETIME);
+static GetSystemTimeAsFileTimeFcn ce6_GetSystemTimeAsFileTime = NULL;
+
 static void
 NowCalibrate(void)
 {
     FILETIME ft, ftStart;
     LARGE_INTEGER liFreq, now;
 
     if (calibration.freq == 0.0) {
 	if(!QueryPerformanceFrequency(&liFreq)) {
@@ -131,21 +136,21 @@ NowCalibrate(void)
 	timeBeginPeriod(1);
 	LowResTime(&ftStart);
 	do {
 	    LowResTime(&ft);
 	} while (memcmp(&ftStart,&ft, sizeof(ft)) == 0);
 	timeEndPeriod(1);
 
 	calibration.granularity = 
-	    (FILETIME2INT64(ft) - FILETIME2INT64(ftStart))/10;
+	    (FILETIME_TO_INT64(ft) - FILETIME_TO_INT64(ftStart))/10;
 
 	QueryPerformanceCounter(&now);
 
-	calibration.offset = (long double) FILETIME2INT64(ft);
+	calibration.offset = (long double) FILETIME_TO_INT64(ft);
 	calibration.timer_offset = (long double) now.QuadPart;
 	/*
 	 * The windows epoch is around 1600. The unix epoch is around 1970. 
 	 * _pr_filetime_offset is the difference (in windows time units which
 	 * are 10 times more highres than the JS time unit) 
 	 */
 	calibration.offset -= _pr_filetime_offset;
 	calibration.offset *= 0.1;
@@ -154,37 +159,44 @@ NowCalibrate(void)
 	calibration.calibrated = PR_TRUE;
     }
 }
 
 #define CALIBRATIONLOCK_SPINCOUNT 0
 #define DATALOCK_SPINCOUNT 4096
 #define LASTLOCK_SPINCOUNT 4096
 
-static PRStatus
+void
 _MD_InitTime(void)
 {
-    memset(&calibration, 0, sizeof(calibration));
-    NowCalibrate();
-    InitializeCriticalSection(&calibration.calibration_lock);
-    InitializeCriticalSection(&calibration.data_lock);
-    return PR_SUCCESS;
+    /* try for CE6 GetSystemTimeAsFileTime first */
+    HANDLE h = GetModuleHandleW(L"coredll.dll");
+    ce6_GetSystemTimeAsFileTime = (GetSystemTimeAsFileTimeFcn)
+        GetProcAddressA(h, "GetSystemTimeAsFileTime");
+
+    /* otherwise go the slow route */
+    if (ce6_GetSystemTimeAsFileTime == NULL) {
+        memset(&calibration, 0, sizeof(calibration));
+        NowCalibrate();
+        InitializeCriticalSection(&calibration.calibration_lock);
+        InitializeCriticalSection(&calibration.data_lock);
+    }
 }
 
 void
 _MD_CleanupTime(void)
 {
-    DeleteCriticalSection(&calibration.calibration_lock);
-    DeleteCriticalSection(&calibration.data_lock);
+    if (ce6_GetSystemTimeAsFileTime == NULL) {
+        DeleteCriticalSection(&calibration.calibration_lock);
+        DeleteCriticalSection(&calibration.data_lock);
+    }
 }
 
 #define MUTEX_SETSPINCOUNT(m, c)
 
-static PRCallOnceType calibrationOnce;
-
 /*
  *-----------------------------------------------------------------------
  *
  * PR_Now --
  *
  *     Returns the current time in microseconds since the epoch.
  *     The epoch is midnight January 1, 1970 GMT.
  *     The implementation is machine dependent.  This is the
@@ -200,18 +212,33 @@ PR_Now(void)
     long double lowresTime, highresTimerValue;
     FILETIME ft;
     LARGE_INTEGER now;
     PRBool calibrated = PR_FALSE;
     PRBool needsCalibration = PR_FALSE;
     PRInt64 returnedTime;
     long double cachedOffset = 0.0;
 
-    /* For non threadsafe platforms, _MD_InitTime is not necessary */
-    PR_CallOnce(&calibrationOnce, _MD_InitTime);
+    if (ce6_GetSystemTimeAsFileTime) {
+        union {
+            FILETIME ft;
+            PRTime prt;
+        } currentTime;
+
+        PR_ASSERT(sizeof(FILETIME) == sizeof(PRTime));
+
+        ce6_GetSystemTimeAsFileTime(&currentTime.ft);
+
+        /* written this way on purpose, since the second term becomes
+         * a constant, and the entire expression is faster to execute.
+         */
+        return currentTime.prt/_pr_filetime_divisor -
+            _pr_filetime_offset/_pr_filetime_divisor;
+    }
+
     do {
 	if (!calibration.calibrated || needsCalibration) {
 	    EnterCriticalSection(&calibration.calibration_lock);
 	    EnterCriticalSection(&calibration.data_lock);
 
 	    /* Recalibrate only if no one else did before us */
 	    if (calibration.offset == cachedOffset) {
 		/*
@@ -228,18 +255,18 @@ PR_Now(void)
 		MUTEX_SETSPINCOUNT(&calibration.data_lock, DATALOCK_SPINCOUNT);
 	    }
 	    LeaveCriticalSection(&calibration.data_lock);
 	    LeaveCriticalSection(&calibration.calibration_lock);
 	}
 
 	/* Calculate a low resolution time */
 	LowResTime(&ft);
-	lowresTime = ((long double)(FILETIME2INT64(ft) - _pr_filetime_offset))
-		     * 0.1;
+	lowresTime =
+            ((long double)(FILETIME_TO_INT64(ft) - _pr_filetime_offset)) * 0.1;
 
 	if (calibration.freq > 0.0) {
 	    long double highresTime, diff;
 	    DWORD timeAdjustment, timeIncrement;
 	    BOOL timeAdjustmentDisabled;
 
 	    /* Default to 15.625 ms if the syscall fails */
 	    long double skewThreshold = 15625.25;
--- a/nsprpub/pr/src/misc/prtime.c
+++ b/nsprpub/pr/src/misc/prtime.c
@@ -581,16 +581,19 @@ static struct tm *MT_safe_localtime(cons
 
 #endif  /* definition of MT_safe_localtime() */
 
 void _PR_InitTime(void)
 {
 #ifdef HAVE_LOCALTIME_MONITOR
     monitor = PR_NewLock();
 #endif
+#ifdef WINCE
+    _MD_InitTime();
+#endif
 }
 
 void _PR_CleanupTime(void)
 {
 #ifdef HAVE_LOCALTIME_MONITOR
     if (monitor) {
         PR_DestroyLock(monitor);
         monitor = NULL;
--- a/nsprpub/pr/tests/Makefile.in
+++ b/nsprpub/pr/tests/Makefile.in
@@ -451,16 +451,20 @@ endif
 endif
 
 ifeq ($(OS_ARCH),BSD_OS)
 ifneq ($(OS_RELEASE),1.1)
 EXTRA_LIBS = -ldl
 endif
 endif
 
+ifeq ($(OS_ARCH),RISCOS)
+EXTRA_LIBS = -ldl
+endif
+
 ifeq ($(USE_PTHREADS),1)
 LIBPTHREAD = -lpthread
 ifeq ($(OS_ARCH),AIX)
 LIBPTHREAD = -lpthreads
 endif
 ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS QNX Darwin OpenUNIX,$(OS_ARCH)))
 LIBPTHREAD =
 endif