Bug 865828 - Upgrade Mozilla 23 to NSPR 4.10, r=wtc
authorKai Engert <kaie@kuix.de>
Thu, 25 Apr 2013 22:06:51 +0200
changeset 129958 572236490691cde4e673991eaba8d5092b73edfa
parent 129957 165352b12d5ef4dfbff5cbde7c7a06bd66d576eb
child 129959 30bc2a74313c9ced172a2fd1805300cd305eb6c5
push id24596
push userryanvm@gmail.com
push dateSat, 27 Apr 2013 01:20:57 +0000
treeherdermozilla-central@0e45f1b9521f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswtc
bugs865828
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 865828 - Upgrade Mozilla 23 to NSPR 4.10, r=wtc
nsprpub/TAG-INFO
nsprpub/configure
nsprpub/configure.in
nsprpub/lib/ds/plarena.c
nsprpub/lib/ds/plarena.h
nsprpub/pkg/linux/Makefile.in
nsprpub/pkg/solaris/Makefile-devl.com
nsprpub/pkg/solaris/Makefile-devl.targ
nsprpub/pkg/solaris/Makefile.com
nsprpub/pkg/solaris/Makefile.in
nsprpub/pkg/solaris/Makefile.targ
nsprpub/pkg/solaris/SUNWpr/Makefile.in
nsprpub/pkg/solaris/SUNWpr/depend
nsprpub/pkg/solaris/SUNWpr/pkginfo.tmpl
nsprpub/pkg/solaris/SUNWpr/prototype_com
nsprpub/pkg/solaris/SUNWpr/prototype_i386
nsprpub/pkg/solaris/SUNWpr/prototype_sparc
nsprpub/pkg/solaris/SUNWprd/Makefile.in
nsprpub/pkg/solaris/SUNWprd/depend
nsprpub/pkg/solaris/SUNWprd/pkginfo.tmpl
nsprpub/pkg/solaris/SUNWprd/prototype
nsprpub/pkg/solaris/bld_awk_pkginfo.ksh
nsprpub/pkg/solaris/proto64.mk
nsprpub/pr/include/md/_win95.cfg
nsprpub/pr/include/md/_win95.h
nsprpub/pr/include/prbit.h
nsprpub/pr/include/prinit.h
nsprpub/pr/include/prthread.h
nsprpub/pr/src/md/windows/ntsem.c
nsprpub/pr/src/md/windows/w95io.c
nsprpub/pr/src/misc/prlong.c
nsprpub/pr/src/misc/prsystem.c
nsprpub/pr/src/pthreads/ptthread.c
nsprpub/pr/tests/vercheck.c
--- a/nsprpub/TAG-INFO
+++ b/nsprpub/TAG-INFO
@@ -1,1 +1,1 @@
-NSPR_4_9_6_RTM
+NSPR_4_10_BETA1
--- a/nsprpub/configure
+++ b/nsprpub/configure
@@ -730,18 +730,18 @@ echo "$ac_t""$build" 1>&6
 
 test "$host_alias" != "$target_alias" &&
   test "$program_prefix$program_suffix$program_transform_name" = \
     NONENONEs,x,x, &&
   program_prefix=${target_alias}-
 
 
 MOD_MAJOR_VERSION=4
-MOD_MINOR_VERSION=9
-MOD_PATCH_VERSION=6
+MOD_MINOR_VERSION=10
+MOD_PATCH_VERSION=0
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_64=
 USE_CPLUS=
@@ -1014,20 +1014,16 @@ echo "configure:961: checking for androi
     if test -z "$HOST_LDFLAGS" ; then
         HOST_LDFLAGS=" "
     fi
 
     cat >> confdefs.h <<\EOF
 #define ANDROID 1
 EOF
 
-    cat >> confdefs.h <<EOF
-#define ANDROID_VERSION $android_version
-EOF
-
     ;;
 esac
 fi
 
 dist_prefix='${MOD_DEPTH}/dist'
 dist_bindir='${dist_prefix}/bin'
 dist_includedir='${dist_prefix}/include/nspr'
 dist_libdir='${dist_prefix}/lib'
@@ -1444,22 +1440,22 @@ test -n "$HOST_CC" || HOST_CC=""""
 
     echo $ac_n "checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works""... $ac_c" 1>&6
 echo "configure:1447: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5
     cat > conftest.$ac_ext <<EOF
 #line 1449 "configure"
 #include "confdefs.h"
 
 int main() {
-return(0);
+return 0;
 ; return 0; }
 EOF
 if { (eval echo configure:1456: \"$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
+  echo "$ac_t""yes" 1>&6
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   { echo "configure: error: installation or configuration problem: $host compiler $HOST_CC cannot create executables." 1>&2; exit 1; } 
 fi
 rm -f conftest*
 
--- a/nsprpub/configure.in
+++ b/nsprpub/configure.in
@@ -9,18 +9,18 @@ AC_INIT(config/libc_r.h)
 
 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
 AC_CANONICAL_SYSTEM
 
 dnl ========================================================
 dnl = Defaults
 dnl ========================================================
 MOD_MAJOR_VERSION=4
-MOD_MINOR_VERSION=9
-MOD_PATCH_VERSION=6
+MOD_MINOR_VERSION=10
+MOD_PATCH_VERSION=0
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_64=
 USE_CPLUS=
@@ -266,17 +266,16 @@ case "$target" in
     if test -z "$HOST_CXXFLAGS" ; then
         HOST_CXXFLAGS=" "
     fi
     if test -z "$HOST_LDFLAGS" ; then
         HOST_LDFLAGS=" "
     fi
 
     AC_DEFINE(ANDROID)
-    AC_DEFINE_UNQUOTED(ANDROID_VERSION, $android_version)
     ;;
 esac
 fi
 
 dnl ========================================================
 dnl =
 dnl = Check options that may affect the compiler
 dnl =
@@ -588,19 +587,19 @@ if test "$target" != "$host" -o -n "$CRO
         HOST_LDFLAGS="$LDFLAGS"
     fi
 
     CC="$HOST_CC"
     CFLAGS="$HOST_CFLAGS"
     LDFLAGS="$HOST_LDFLAGS"
 
     AC_MSG_CHECKING([whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
-    AC_TRY_COMPILE([], [return(0);], 
-        [ac_cv_prog_host_cc_works=1 AC_MSG_RESULT([yes])],
-        AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.]) )
+    AC_TRY_COMPILE([], [return 0;],
+        [AC_MSG_RESULT([yes])],
+        [AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.])] )
 
     CC=$_SAVE_CC
     CFLAGS=$_SAVE_CFLAGS
     LDFLAGS=$_SAVE_LDFLAGS
 
     case "$build:$target" in 
       powerpc-apple-darwin8*:i?86-apple-darwin*)
         dnl The Darwin cross compiler doesn't necessarily point itself at a
@@ -2548,18 +2547,18 @@ dnl since it's not used and not part of 
 dnl The same goes for BeOS.
 dnl OS/2 has dlfcn in libc.
 
 case $target in
 *-darwin*|*-beos*|*-os2*)
     ;;
 *)
     AC_CHECK_LIB(dl, dlopen,
-        AC_CHECK_HEADER(dlfcn.h,
-            OS_LIBS="-ldl $OS_LIBS"))
+        [AC_CHECK_HEADER(dlfcn.h,
+            OS_LIBS="-ldl $OS_LIBS")])
     ;;
 esac
 
 
 dnl ========================================================
 dnl Check for system header files.
 dnl ========================================================
 dnl AC_HEADER_DIRENT
--- a/nsprpub/lib/ds/plarena.c
+++ b/nsprpub/lib/ds/plarena.c
@@ -152,16 +152,17 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PL
     /* attempt to allocate from arenas at pool->current */
     {
         a = pool->current;
         do {
             if ( a->avail +nb <= a->limit )  {
                 pool->current = a;
                 rp = (char *)a->avail;
                 a->avail += nb;
+                PL_MAKE_MEM_UNDEFINED(rp, nb);
                 return rp;
             }
         } while( NULL != (a = a->next) );
     }
 
     /* attempt to allocate from arena_freelist */
     {
         PLArena *p; /* previous pointer, for unlinking from freelist */
@@ -182,41 +183,44 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PL
                 a->avail += nb;
                 /* the newly allocated arena is linked after pool->current 
                 *  and becomes pool->current */
                 a->next = pool->current->next;
                 pool->current->next = a;
                 pool->current = a;
                 if ( NULL == pool->first.next )
                     pool->first.next = a;
+                PL_MAKE_MEM_UNDEFINED(rp, nb);
                 return(rp);
             }
         }
         UnlockArena();
     }
 
     /* attempt to allocate from the heap */ 
     {  
         PRUint32 sz = PR_MAX(pool->arenasize, nb);
         sz += sizeof *a + pool->mask;  /* header and alignment slop */
         a = (PLArena*)PR_MALLOC(sz);
         if ( NULL != a )  {
             a->limit = (PRUword)a + sz;
             a->base = a->avail = (PRUword)PL_ARENA_ALIGN(pool, a + 1);
+            PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);
             rp = (char *)a->avail;
             a->avail += nb;
             /* the newly allocated arena is linked after pool->current 
             *  and becomes pool->current */
             a->next = pool->current->next;
             pool->current->next = a;
             pool->current = a;
             if ( NULL == pool->first.next )
                 pool->first.next = a;
             PL_COUNT_ARENA(pool,++);
             COUNT(pool, nmallocs);
+            PL_MAKE_MEM_UNDEFINED(rp, nb);
             return(rp);
         }
     }
 
     /* we got to here, and there's no memory to allocate */
     return(NULL);
 } /* --- end PL_ArenaAllocate() --- */
 
@@ -232,17 +236,18 @@ PR_IMPLEMENT(void *) PL_ArenaGrow(
 }
 
 static void ClearArenaList(PLArena *a, PRInt32 pattern)
 {
 
     for (; a; a = a->next) {
         PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);
         a->avail = a->base;
-	PL_CLEAR_UNUSED_PATTERN(a, pattern);
+        PL_CLEAR_UNUSED_PATTERN(a, pattern);
+        PL_MAKE_MEM_NOACCESS((void*)a->avail, a->limit - a->avail);
     }
 }
 
 PR_IMPLEMENT(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern)
 {
     ClearArenaList(pool->first.next, pattern);
 }
 
@@ -268,16 +273,18 @@ static void FreeArenaList(PLArenaPool *p
             *ap = a->next;
             PL_CLEAR_ARENA(a);
             PL_COUNT_ARENA(pool,--);
             PR_DELETE(a);
         } while ((a = *ap) != 0);
     } else {
         /* Insert the whole arena chain at the front of the freelist. */
         do {
+            PL_MAKE_MEM_NOACCESS((void*)(*ap)->base,
+                                 (*ap)->limit - (*ap)->base);
             ap = &(*ap)->next;
         } while (*ap);
         LockArena();
         *ap = arena_freelist;
         arena_freelist = a;
         head->next = 0;
         UnlockArena();
     }
--- a/nsprpub/lib/ds/plarena.h
+++ b/nsprpub/lib/ds/plarena.h
@@ -53,16 +53,78 @@ struct PLArenaPool {
     PRUint32    arenasize;      /* net exact size of a new arena */
     PRUword     mask;           /* alignment mask (power-of-2 - 1) */
 #ifdef PL_ARENAMETER
     PLArenaStats stats;
 #endif
 };
 
 /*
+ * WARNING: The PL_MAKE_MEM_ macros are for internal use by NSPR. Do NOT use
+ * them in your code.
+ *
+ * NOTE: Valgrind support to be added.
+ *
+ * The PL_MAKE_MEM_ macros are modeled after the MOZ_MAKE_MEM_ macros in
+ * Mozilla's mfbt/MemoryChecking.h. Only AddressSanitizer is supported now.
+ *
+ * Provides a common interface to the ASan (AddressSanitizer) and Valgrind
+ * functions used to mark memory in certain ways. In detail, the following
+ * three macros are provided:
+ *
+ *   PL_MAKE_MEM_NOACCESS  - Mark memory as unsafe to access (e.g. freed)
+ *   PL_MAKE_MEM_UNDEFINED - Mark memory as accessible, with content undefined
+ *   PL_MAKE_MEM_DEFINED - Mark memory as accessible, with content defined
+ *
+ * With Valgrind in use, these directly map to the three respective Valgrind
+ * macros. With ASan in use, the NOACCESS macro maps to poisoning the memory,
+ * while the UNDEFINED/DEFINED macros unpoison memory.
+ *
+ * With no memory checker available, all macros expand to the empty statement.
+ */
+
+/* WARNING: PL_SANITIZE_ADDRESS is for internal use by this header. Do NOT
+ * define or test this macro in your code.
+ */
+#if defined(__has_feature)
+#if __has_feature(address_sanitizer)
+#define PL_SANITIZE_ADDRESS 1
+#endif
+#elif defined(__SANITIZE_ADDRESS__)
+#define PL_SANITIZE_ADDRESS 1
+#endif
+
+#if defined(PL_SANITIZE_ADDRESS)
+
+/* These definitions are usually provided through the
+ * sanitizer/asan_interface.h header installed by ASan.
+ * See https://code.google.com/p/address-sanitizer/wiki/ManualPoisoning
+ */
+
+void __asan_poison_memory_region(void const volatile *addr, size_t size);
+void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
+
+#define PL_MAKE_MEM_NOACCESS(addr, size) \
+    __asan_poison_memory_region((addr), (size))
+
+#define PL_MAKE_MEM_UNDEFINED(addr, size) \
+    __asan_unpoison_memory_region((addr), (size))
+
+#define PL_MAKE_MEM_DEFINED(addr, size) \
+    __asan_unpoison_memory_region((addr), (size))
+
+#else
+
+#define PL_MAKE_MEM_NOACCESS(addr, size)
+#define PL_MAKE_MEM_UNDEFINED(addr, size)
+#define PL_MAKE_MEM_DEFINED(addr, size)
+
+#endif
+
+/*
  * If the including .c file uses only one power-of-2 alignment, it may define
  * PL_ARENA_CONST_ALIGN_MASK to the alignment mask and save a few instructions
  * per ALLOCATE and GROW.
  */
 #ifdef PL_ARENA_CONST_ALIGN_MASK
 #define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + PL_ARENA_CONST_ALIGN_MASK) \
                                 & ~PL_ARENA_CONST_ALIGN_MASK)
 
@@ -73,63 +135,73 @@ struct PLArenaPool {
 #endif
 
 #define PL_ARENA_ALLOCATE(p, pool, nb) \
     PR_BEGIN_MACRO \
         PLArena *_a = (pool)->current; \
         PRUint32 _nb = PL_ARENA_ALIGN(pool, nb); \
         PRUword _p = _a->avail; \
         PRUword _q = _p + _nb; \
-        if (_q > _a->limit) \
+        if (_q > _a->limit) { \
             _p = (PRUword)PL_ArenaAllocate(pool, _nb); \
-        else \
+        } else { \
+            PL_MAKE_MEM_UNDEFINED((void *)_p, nb); \
             _a->avail = _q; \
+        } \
         p = (void *)_p; \
         PL_ArenaCountAllocation(pool, nb); \
     PR_END_MACRO
 
 #define PL_ARENA_GROW(p, pool, size, incr) \
     PR_BEGIN_MACRO \
         PLArena *_a = (pool)->current; \
         PRUint32 _incr = PL_ARENA_ALIGN(pool, incr); \
         PRUword _p = _a->avail; \
         PRUword _q = _p + _incr; \
         if (_p == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
             _q <= _a->limit) { \
+            PL_MAKE_MEM_UNDEFINED((void *)((PRUword)(p) + size), incr); \
             _a->avail = _q; \
             PL_ArenaCountInplaceGrowth(pool, size, incr); \
         } else { \
             p = PL_ArenaGrow(pool, p, size, incr); \
         } \
         PL_ArenaCountGrowth(pool, size, incr); \
     PR_END_MACRO
 
 #define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail)
 #define PR_UPTRDIFF(p,q) ((PRUword)(p) - (PRUword)(q))
 
 #define PL_CLEAR_UNUSED_PATTERN(a, pattern) \
-	   (PR_ASSERT((a)->avail <= (a)->limit), \
-	   memset((void*)(a)->avail, (pattern), (a)->limit - (a)->avail))
+    PR_BEGIN_MACRO \
+        PR_ASSERT((a)->avail <= (a)->limit); \
+        PL_MAKE_MEM_UNDEFINED((void*)(a)->avail, (a)->limit - (a)->avail); \
+        memset((void*)(a)->avail, (pattern), (a)->limit - (a)->avail); \
+    PR_END_MACRO
 #ifdef DEBUG
 #define PL_FREE_PATTERN 0xDA
 #define PL_CLEAR_UNUSED(a) PL_CLEAR_UNUSED_PATTERN((a), PL_FREE_PATTERN)
-#define PL_CLEAR_ARENA(a)  memset((void*)(a), PL_FREE_PATTERN, \
-                           (a)->limit - (PRUword)(a))
+#define PL_CLEAR_ARENA(a) \
+    PR_BEGIN_MACRO \
+        PL_MAKE_MEM_UNDEFINED((void*)(a), (a)->limit - (PRUword)(a)); \
+        memset((void*)(a), PL_FREE_PATTERN, (a)->limit - (PRUword)(a)); \
+    PR_END_MACRO
 #else
 #define PL_CLEAR_UNUSED(a)
 #define PL_CLEAR_ARENA(a)
 #endif
 
 #define PL_ARENA_RELEASE(pool, mark) \
     PR_BEGIN_MACRO \
         char *_m = (char *)(mark); \
         PLArena *_a = (pool)->current; \
         if (PR_UPTRDIFF(_m, _a->base) <= PR_UPTRDIFF(_a->avail, _a->base)) { \
             _a->avail = (PRUword)PL_ARENA_ALIGN(pool, _m); \
             PL_CLEAR_UNUSED(_a); \
+            PL_MAKE_MEM_NOACCESS((void*)_a->avail, _a->limit - _a->avail); \
             PL_ArenaCountRetract(pool, _m); \
         } else { \
             PL_ArenaRelease(pool, _m); \
         } \
         PL_ArenaCountRelease(pool, _m); \
     PR_END_MACRO
 
 #ifdef PL_ARENAMETER
--- a/nsprpub/pkg/linux/Makefile.in
+++ b/nsprpub/pkg/linux/Makefile.in
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: Makefile.in,v 1.12 2012/03/06 13:13:40 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 
 MOD_DEPTH = ../..
 topsrcdir   = @top_srcdir@
 srcdir	    = @srcdir@
 VPATH	    = @srcdir@
 
 NAME        = sun-nspr
--- a/nsprpub/pkg/solaris/Makefile-devl.com
+++ b/nsprpub/pkg/solaris/Makefile-devl.com
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: Makefile-devl.com,v 1.4 2012/03/06 13:13:40 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 
 MACH = $(shell mach)
 
 PUBLISH_ROOT = $(DIST)
 ifeq ($(MOD_DEPTH),../..)
 ROOT = ROOT
 else
--- a/nsprpub/pkg/solaris/Makefile-devl.targ
+++ b/nsprpub/pkg/solaris/Makefile-devl.targ
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: Makefile-devl.targ,v 1.4 2012/03/06 13:13:40 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 
 include $(srcdir)/../proto64.mk
 
 pkginfo: pkginfo.tmpl ../awk_pkginfo
 	$(RM) $@; nawk -f ../awk_pkginfo $(srcdir)/$@.tmpl > $@
 
 pkg: $(PKGARCHIVE)
--- a/nsprpub/pkg/solaris/Makefile.com
+++ b/nsprpub/pkg/solaris/Makefile.com
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: Makefile.com,v 1.9 2012/03/06 13:13:40 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 
 MACH = $(shell mach)
 
 PUBLISH_ROOT = $(DIST)
 ifeq ($(MOD_DEPTH),../..)
 ROOT = ROOT
 else
--- a/nsprpub/pkg/solaris/Makefile.in
+++ b/nsprpub/pkg/solaris/Makefile.in
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: Makefile.in,v 1.4 2012/03/06 13:13:40 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 
 MOD_DEPTH = ../..
 topsrcdir   = @top_srcdir@
 srcdir	    = @srcdir@
 VPATH	    = @srcdir@
 
 include $(MOD_DEPTH)/config/autoconf.mk
--- a/nsprpub/pkg/solaris/Makefile.targ
+++ b/nsprpub/pkg/solaris/Makefile.targ
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: Makefile.targ,v 1.7 2012/03/06 13:13:40 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 
 include $(srcdir)/../proto64.mk
 
 pkginfo: pkginfo.tmpl ../awk_pkginfo
 	$(RM) $@; nawk -f ../awk_pkginfo $< > $@
 
 pkg: $(PKGARCHIVE) prototype_$(MACH)
--- a/nsprpub/pkg/solaris/SUNWpr/Makefile.in
+++ b/nsprpub/pkg/solaris/SUNWpr/Makefile.in
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: Makefile.in,v 1.3 2012/03/06 13:13:41 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 
 MOD_DEPTH = ../../..
 topsrcdir   = @top_srcdir@
 srcdir	    = @srcdir@
 VPATH	    = @srcdir@
 
 include $(MOD_DEPTH)/config/autoconf.mk
--- a/nsprpub/pkg/solaris/SUNWpr/depend
+++ b/nsprpub/pkg/solaris/SUNWpr/depend
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#	$Id: depend,v 1.4 2012/03/06 13:13:41 gerv%gerv.net Exp $
+#	$Id$
 #
 # This package information file defines software dependencies associated
 # with the pkg.  You can define three types of pkg dependencies with this file:
 #	 P indicates a prerequisite for installation
 #	 I indicates an incompatible package
 #	 R indicates a reverse dependency
 # <pkg.abbr> see pkginfo(4), PKG parameter
 # <name> see pkginfo(4), NAME parameter
--- a/nsprpub/pkg/solaris/SUNWpr/pkginfo.tmpl
+++ b/nsprpub/pkg/solaris/SUNWpr/pkginfo.tmpl
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: pkginfo.tmpl,v 1.4 2012/03/06 13:13:41 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 #
 # This required package information file describes characteristics of the
 # package, such as package abbreviation, full package name, package version,
 # and package architecture.
 #
 PKG="SUNWpr"
 NAME="Netscape Portable Runtime"
--- a/nsprpub/pkg/solaris/SUNWpr/prototype_com
+++ b/nsprpub/pkg/solaris/SUNWpr/prototype_com
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: prototype_com,v 1.5 2012/03/06 13:13:41 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 # This required package information file contains a list of package contents.
 # The 'pkgmk' command uses this file to identify the contents of a package
 # and their location on the development machine when building the package.
 # Can be created via a text editor or through use of the 'pkgproto' command.
 
 #!search <pathname pathname ...>	# where to find pkg objects
 #!include <filename>			# include another 'prototype' file
--- a/nsprpub/pkg/solaris/SUNWpr/prototype_i386
+++ b/nsprpub/pkg/solaris/SUNWpr/prototype_i386
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: prototype_i386,v 1.5 2012/03/06 13:13:41 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 # This required package information file contains a list of package contents.
 # The 'pkgmk' command uses this file to identify the contents of a package
 # and their location on the development machine when building the package.
 # Can be created via a text editor or through use of the 'pkgproto' command.
 
 #!search <pathname pathname ...>	# where to find pkg objects
 #!include <filename>			# include another 'prototype' file
--- a/nsprpub/pkg/solaris/SUNWpr/prototype_sparc
+++ b/nsprpub/pkg/solaris/SUNWpr/prototype_sparc
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: prototype_sparc,v 1.5 2012/03/06 13:13:41 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 # This required package information file contains a list of package contents.
 # The 'pkgmk' command uses this file to identify the contents of a package
 # and their location on the development machine when building the package.
 # Can be created via a text editor or through use of the 'pkgproto' command.
 
 #!search <pathname pathname ...>	# where to find pkg objects
 #!include <filename>			# include another 'prototype' file
old mode 100644
new mode 100755
--- a/nsprpub/pkg/solaris/SUNWprd/Makefile.in
+++ b/nsprpub/pkg/solaris/SUNWprd/Makefile.in
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: Makefile.in,v 1.4 2012/03/06 13:13:41 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 
 MOD_DEPTH = ../../..
 topsrcdir   = @top_srcdir@
 srcdir      = @srcdir@
 VPATH       = @srcdir@
 
 include $(MOD_DEPTH)/config/autoconf.mk
--- a/nsprpub/pkg/solaris/SUNWprd/depend
+++ b/nsprpub/pkg/solaris/SUNWprd/depend
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#	$Id: depend,v 1.4 2012/03/06 13:13:41 gerv%gerv.net Exp $
+#	$Id$
 #
 # This package information file defines software dependencies associated
 # with the pkg.  You can define three types of pkg dependencies with this file:
 #	 P indicates a prerequisite for installation
 #	 I indicates an incompatible package
 #	 R indicates a reverse dependency
 # <pkg.abbr> see pkginfo(4), PKG parameter
 # <name> see pkginfo(4), NAME parameter
--- a/nsprpub/pkg/solaris/SUNWprd/pkginfo.tmpl
+++ b/nsprpub/pkg/solaris/SUNWprd/pkginfo.tmpl
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: pkginfo.tmpl,v 1.4 2012/03/06 13:13:41 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 #
 # This required package information file describes characteristics of the
 # package, such as package abbreviation, full package name, package version,
 # and package architecture.
 #
 PKG="SUNWprd"
 NAME="Netscape Portable Runtime Development"
--- a/nsprpub/pkg/solaris/SUNWprd/prototype
+++ b/nsprpub/pkg/solaris/SUNWprd/prototype
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident  "$Id: prototype,v 1.7 2012/03/06 13:13:41 gerv%gerv.net Exp $"
+#ident  "$Id$"
 #
 # This required package information file contains a list of package contents.
 # The 'pkgmk' command uses this file to identify the contents of a package
 # and their location on the development machine when building the package.
 # Can be created via a text editor or through use of the 'pkgproto' command.
 
 #!search <pathname pathname ...>        # where to find pkg objects
 #!include <filename>                    # include another 'prototype' file
--- a/nsprpub/pkg/solaris/bld_awk_pkginfo.ksh
+++ b/nsprpub/pkg/solaris/bld_awk_pkginfo.ksh
@@ -2,17 +2,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident	"$Id: bld_awk_pkginfo.ksh,v 1.4 2012/03/06 13:13:40 gerv%gerv.net Exp $"
+#ident	"$Id$"
 #
 # Simple script which builds the awk_pkginfo awk script.  This awk script
 # is used to convert the pkginfo.tmpl files into pkginfo files
 # for the build.
 #
 
 usage()
 {
--- a/nsprpub/pkg/solaris/proto64.mk
+++ b/nsprpub/pkg/solaris/proto64.mk
@@ -1,17 +1,17 @@
 # 
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-#ident  "$Id: proto64.mk,v 1.4 2012/03/06 13:13:40 gerv%gerv.net Exp $"
+#ident  "$Id$"
 #
 
 ifeq ($(USE_64), 1)
   # Remove 64 tag
   sed_proto64='s/\#64\#//g'
 else
   # Strip 64 lines
   sed_proto64='/\#64\#/d'
--- a/nsprpub/pr/include/md/_win95.cfg
+++ b/nsprpub/pr/include/md/_win95.cfg
@@ -9,25 +9,19 @@
 #ifndef XP_PC
 #define XP_PC
 #endif
 
 #ifndef WIN32
 #define WIN32
 #endif
 
-#ifdef _WIN32_WCE
-#ifndef WINCE
-#define WINCE
-#endif
-#else
 #ifndef WIN95
 #define WIN95
 #endif
-#endif
 
 #define PR_AF_INET6 23  /* same as AF_INET6 */
 
 #if defined(_M_IX86) || defined(_X86_)
 
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
 
@@ -209,17 +203,17 @@
 
 #define PR_ALIGN_OF_SHORT   2
 #define PR_ALIGN_OF_INT     4
 #define PR_ALIGN_OF_LONG    4
 #define PR_ALIGN_OF_INT64   8
 #define PR_ALIGN_OF_FLOAT   4
 #define PR_ALIGN_OF_WORD    4
 #define PR_ALIGN_OF_DWORD   8
-#define PR_ALIGN_OF_DOUBLE  4
+#define PR_ALIGN_OF_DOUBLE  8
 #define PR_ALIGN_OF_POINTER 4
 
 #define PR_BYTES_PER_WORD_LOG2  2
 #define PR_BYTES_PER_DWORD_LOG2 3
 
 #else /* defined(_M_IX86) || defined(_X86_) */
 
 #error unknown processor architecture
--- a/nsprpub/pr/include/md/_win95.h
+++ b/nsprpub/pr/include/md/_win95.h
@@ -241,17 +241,16 @@ extern PRInt32 _MD_CloseFile(PROsfd osfd
 #define _MD_MKDIR                     _PR_MD_MKDIR      
 #define _MD_MAKE_DIR                  _PR_MD_MAKE_DIR
 #define _MD_RMDIR                     _PR_MD_RMDIR      
 #define _MD_LOCKFILE                  _PR_MD_LOCKFILE
 #define _MD_TLOCKFILE                 _PR_MD_TLOCKFILE
 #define _MD_UNLOCKFILE                _PR_MD_UNLOCKFILE
 
 /* --- UTF16 IO stuff --- */
-extern PRBool _pr_useUnicode;
 #ifdef MOZ_UNICODE
 #define _MD_OPEN_FILE_UTF16           _PR_MD_OPEN_FILE_UTF16
 #define _MD_OPEN_DIR_UTF16            _PR_MD_OPEN_DIR_UTF16
 #define _MD_READ_DIR_UTF16            _PR_MD_READ_DIR_UTF16
 #define _MD_CLOSE_DIR_UTF16           _PR_MD_CLOSE_DIR_UTF16
 #define _MD_GETFILEINFO64_UTF16       _PR_MD_GETFILEINFO64_UTF16
 #endif /* MOZ_UNICODE */
 
--- a/nsprpub/pr/include/prbit.h
+++ b/nsprpub/pr/include/prbit.h
@@ -4,18 +4,22 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef prbit_h___
 #define prbit_h___
 
 #include "prtypes.h"
 PR_BEGIN_EXTERN_C
 
-/* replace compare/jump/add/shift sequence with x86 BSF/BSR instruction */
-#if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64))
+/*
+** Replace compare/jump/add/shift sequence with compiler built-in/intrinsic
+** functions.
+*/
+#if defined(_WIN32) && (_MSC_VER >= 1300) && \
+    (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM))
   unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask);
   unsigned char _BitScanReverse(unsigned long * Index, unsigned long Mask);
 # pragma  intrinsic(_BitScanForward,_BitScanReverse)
   __forceinline static int __prBitScanForward32(unsigned int val)
   { 
     unsigned long idx;
     _BitScanForward(&idx, (unsigned long)val);
     return( (int)idx );
@@ -128,17 +132,17 @@ NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i
 ** To get MSVC to generate a rotate instruction, we have to use the _rotl
 ** or _rotr intrinsic and use a pragma to make it inline.
 **
 ** Note: MSVC in VS2005 will do an inline rotate instruction on the above
 ** construct.
 */
 
 #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \
-    defined(_M_X64))
+    defined(_M_X64) || defined(_M_ARM))
 #include <stdlib.h>
 #pragma intrinsic(_rotl, _rotr)
 #define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits)
 #define PR_ROTATE_RIGHT32(a, bits) _rotr(a, bits)
 #else
 #define PR_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits))))
 #define PR_ROTATE_RIGHT32(a, bits) (((a) >> (bits)) | ((a) << (32 - (bits))))
 #endif
--- a/nsprpub/pr/include/prinit.h
+++ b/nsprpub/pr/include/prinit.h
@@ -26,21 +26,21 @@ PR_BEGIN_EXTERN_C
 /*
 ** NSPR's version is used to determine the likelihood that the version you
 ** used to build your component is anywhere close to being compatible with
 ** what is in the underlying library.
 **
 ** The format of the version string is
 **     "<major version>.<minor version>[.<patch level>] [<Beta>]"
 */
-#define PR_VERSION  "4.9.6"
+#define PR_VERSION  "4.10 Beta"
 #define PR_VMAJOR   4
-#define PR_VMINOR   9
-#define PR_VPATCH   6
-#define PR_BETA     PR_FALSE
+#define PR_VMINOR   10
+#define PR_VPATCH   0
+#define PR_BETA     PR_TRUE
 
 /*
 ** PRVersionCheck
 **
 ** The basic signature of the function that is called to provide version
 ** checking. The result will be a boolean that indicates the likelihood
 ** that the underling library will perform as the caller expects.
 **
--- a/nsprpub/pr/include/prthread.h
+++ b/nsprpub/pr/include/prthread.h
@@ -136,16 +136,23 @@ NSPR_API(PRThread*) PR_GetCurrentThread(
 
 /*
 ** Get the priority of "thread".
 */
 NSPR_API(PRThreadPriority) PR_GetThreadPriority(const PRThread *thread);
 
 /*
 ** Change the priority of the "thread" to "priority".
+**
+** PR_SetThreadPriority works in a best-effort manner. On some platforms a
+** special privilege, such as root access, is required to change thread
+** priorities, especially to raise thread priorities. If the caller doesn't
+** have enough privileges to change thread priorites, the function has no
+** effect except causing a future PR_GetThreadPriority call to return
+** |priority|.
 */
 NSPR_API(void) PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority);
 
 /*
 ** Set the name of the current thread, which will be visible in a debugger
 ** and accessible via a call to PR_GetThreadName().
 */
 NSPR_API(PRStatus) PR_SetCurrentThreadName(const char *name);
--- a/nsprpub/pr/src/md/windows/ntsem.c
+++ b/nsprpub/pr/src/md/windows/ntsem.c
@@ -41,12 +41,10 @@ PRStatus
 _PR_MD_WAIT_SEM(_MDSemaphore *md)
 {
     return _PR_MD_TIMED_WAIT_SEM(md, PR_INTERVAL_NO_TIMEOUT);
 }
 
 void 
 _PR_MD_POST_SEM(_MDSemaphore *md)
 {
-    int old_count;
-
-    ReleaseSemaphore(md->sem, 1, &old_count);
+    ReleaseSemaphore(md->sem, 1, NULL);
 }
--- a/nsprpub/pr/src/md/windows/w95io.c
+++ b/nsprpub/pr/src/md/windows/w95io.c
@@ -11,207 +11,16 @@
 
 #include "primpl.h"
 #include <direct.h>
 #include <mbstring.h>
 #ifdef MOZ_UNICODE
 #include <wchar.h>
 #endif /* MOZ_UNICODE */
 
-#ifdef WINCE
-
-static HANDLE CreateFileA(LPCSTR lpFileName,
-                          DWORD dwDesiredAccess,
-                          DWORD dwShareMode,
-                          LPSECURITY_ATTRIBUTES lpSecurityAttributes,
-                          DWORD dwCreationDisposition,
-                          DWORD dwFlagsAndAttributes,
-                          HANDLE hTemplateFile)
-{
-    PRUnichar wFileName[MAX_PATH];
-    MultiByteToWideChar(CP_ACP, 0, lpFileName, -1, wFileName, MAX_PATH);
-    return CreateFileW(wFileName, dwDesiredAccess, dwShareMode,
-                       lpSecurityAttributes, dwCreationDisposition,
-                       dwFlagsAndAttributes, hTemplateFile);
-}
-
-/*
- * We seem to call FindFirstFileA and FindNextFileA just to get
- * the file names in a directory listing.  If so, we could define
- * a custom WIN32_FIND_DATAA structure with just the cFileName
- * member, and the CopyFindFileDataW2A function could just
- * copy/convert the cFileName member.
- */
-static void CopyFindFileDataW2A(LPWIN32_FIND_DATAW from,
-                                LPWIN32_FIND_DATAA to)
-{
-    /*
-     * WIN32_FIND_DATAA and WIN32_FIND_DATAW are slightly different.
-     * The dwReserved0, dwReserved1, and cAlternateFileName members
-     * exist only in WIN32_FIND_DATAA.  The dwOID member exists only
-     * in WIN32_FIND_DATAW.
-     */
-    to->dwFileAttributes = from->dwFileAttributes;
-    to->ftCreationTime = from->ftCreationTime;
-    to->ftLastAccessTime = from->ftLastAccessTime;
-    to->ftLastWriteTime = from->ftLastWriteTime;
-    to->nFileSizeHigh = from->nFileSizeHigh;
-    to->nFileSizeLow = from->nFileSizeLow;
-    to->dwReserved0 = 0;
-    to->dwReserved1 = 0;
-    WideCharToMultiByte(CP_ACP, 0, from->cFileName, -1,
-                        to->cFileName, MAX_PATH, NULL, NULL);
-    to->cAlternateFileName[0] = '\0';
-}
-
-static HANDLE FindFirstFileA(LPCSTR lpFileName,
-                             LPWIN32_FIND_DATAA lpFindFileData)
-{
-    PRUnichar wFileName[MAX_PATH];
-    HANDLE hFindFile;
-    WIN32_FIND_DATAW wFindFileData;
-    
-    MultiByteToWideChar(CP_ACP, 0, lpFileName, -1, wFileName, MAX_PATH);
-    hFindFile = FindFirstFileW(wFileName, &wFindFileData);
-    if (hFindFile != INVALID_HANDLE_VALUE) {
-        CopyFindFileDataW2A(&wFindFileData, lpFindFileData);
-    }
-    return hFindFile;
-}
-
-static BOOL FindNextFileA(HANDLE hFindFile,
-                          LPWIN32_FIND_DATAA lpFindFileData)
-{
-    WIN32_FIND_DATAW wFindFileData;
-    BOOL rv;
-
-    rv = FindNextFileW(hFindFile, &wFindFileData);
-    if (rv) {
-        CopyFindFileDataW2A(&wFindFileData, lpFindFileData);
-    }
-    return rv;
-}
-
-static BOOL GetFileAttributesExA(LPCSTR lpFileName,
-                                 GET_FILEEX_INFO_LEVELS fInfoLevelId,
-                                 LPVOID lpFileInformation)
-{
-    PRUnichar wFileName[MAX_PATH];
-    MultiByteToWideChar(CP_ACP, 0, lpFileName, -1, wFileName, MAX_PATH);
-    return GetFileAttributesExW(wFileName, fInfoLevelId, lpFileInformation);
-}
-
-static BOOL DeleteFileA(LPCSTR lpFileName)
-{
-    PRUnichar wFileName[MAX_PATH];
-    MultiByteToWideChar(CP_ACP, 0, lpFileName, -1, wFileName, MAX_PATH);
-    return DeleteFileW(wFileName);
-}
-
-static BOOL MoveFileA(LPCSTR from, LPCSTR to)
-{
-    PRUnichar wFrom[MAX_PATH];
-    PRUnichar wTo[MAX_PATH];
-    MultiByteToWideChar(CP_ACP, 0, from, -1, wFrom, MAX_PATH);
-    MultiByteToWideChar(CP_ACP, 0, to, -1, wTo, MAX_PATH);
-    return MoveFileW(wFrom, wTo);
-}
-
-static BOOL CreateDirectoryA(LPCSTR lpPathName,
-                             LPSECURITY_ATTRIBUTES lpSecurityAttributes)
-{
-    PRUnichar wPathName[MAX_PATH];
-    MultiByteToWideChar(CP_ACP, 0, lpPathName, -1, wPathName, MAX_PATH);
-    return CreateDirectoryW(wPathName, lpSecurityAttributes);
-}
-
-static BOOL RemoveDirectoryA(LPCSTR lpPathName)
-{
-    PRUnichar wPathName[MAX_PATH];
-    MultiByteToWideChar(CP_ACP, 0, lpPathName, -1, wPathName, MAX_PATH);
-    return RemoveDirectoryW(wPathName);
-}
-
-static long GetDriveType(const char *lpRootPathName)
-{
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return 0; // The drive type cannot be determined.
-}
-
-static DWORD GetFullPathName(const char *lpFileName,
-                             DWORD nBufferLength,
-                             const char *lpBuffer,
-                             const char **lpFilePart)
-{
-    // needs work dft
-    DWORD len = strlen(lpFileName);
-    if (len > nBufferLength)
-        return len;
-  
-    strncpy((char *)lpBuffer, lpFileName, len);
-    ((char *)lpBuffer)[len] = '\0';
-  
-    if (lpFilePart) {
-        char *sep = strrchr(lpBuffer, '\\');
-        if (sep) {
-            sep++; // pass the seperator
-            *lpFilePart = sep;
-        } else {
-            *lpFilePart = lpBuffer;
-        }
-    }
-    return len;
-}
-
-static BOOL LockFile(HANDLE hFile,
-                     DWORD dwFileOffsetLow,
-                     DWORD dwFileOffsetHigh,
-                     DWORD nNumberOfBytesToLockLow,
-                     DWORD nNumberOfBytesToLockHigh)
-{
-    OVERLAPPED overlapped = {0};
-    overlapped.Offset = dwFileOffsetLow;
-    overlapped.OffsetHigh = dwFileOffsetHigh;
-    return LockFileEx(hFile,
-                      LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY,
-                      0, // reserved
-                      nNumberOfBytesToLockLow,
-                      nNumberOfBytesToLockHigh, &overlapped);
-}
-
-static BOOL UnlockFile(HANDLE hFile,
-                       DWORD dwFileOffsetLow,
-                       DWORD dwFileOffsetHigh,
-                       DWORD nNumberOfBytesToUnlockLow,
-                       DWORD nNumberOfBytesToUnlockHigh)
-{
-    OVERLAPPED overlapped = {0};
-    overlapped.Offset = dwFileOffsetLow;
-    overlapped.OffsetHigh = dwFileOffsetHigh;
-    return UnlockFileEx(hFile,
-                        0, // reserved
-                        nNumberOfBytesToUnlockLow,
-                        nNumberOfBytesToUnlockHigh, &overlapped);
-}
-
-static unsigned char *_mbsdec(const unsigned char *string1,
-                              const unsigned char *string2)
-{
-    // needs work dft
-    return NULL;
-}
-
-static unsigned char *_mbsinc(const unsigned char *inCurrent)
-{
-    // needs work dft
-    return (unsigned char *)(inCurrent + 1);
-}
-
-#endif
-
 struct _MDLock               _pr_ioq_lock;
 
 /*
  * NSPR-to-NT access right mapping table for files.
  */
 static DWORD fileAccessTable[] = {
     FILE_GENERIC_READ,
     FILE_GENERIC_WRITE,
@@ -222,27 +31,16 @@ static DWORD fileAccessTable[] = {
  * NSPR-to-NT access right mapping table for directories.
  */
 static DWORD dirAccessTable[] = {
     FILE_GENERIC_READ,
     FILE_GENERIC_WRITE|FILE_DELETE_CHILD,
     FILE_GENERIC_EXECUTE
 };
 
-/* Windows CE has GetFileAttributesEx. */
-#ifndef WINCE
-typedef BOOL (WINAPI *GetFileAttributesExFn)(LPCTSTR,
-                                             GET_FILEEX_INFO_LEVELS,
-                                             LPVOID); 
-static GetFileAttributesExFn getFileAttributesEx;
-static void InitGetFileInfo(void);
-#endif
-
-static void InitUnicodeSupport(void);
-
 static PRBool IsPrevCharSlash(const char *str, const char *current);
 
 void
 _PR_MD_INIT_IO()
 {
     WORD WSAVersion = 0x0101;
     WSADATA WSAData;
     int err;
@@ -272,22 +70,16 @@ void
         rv = SystemTimeToFileTime(&systime, &filetime.ft);
         PR_ASSERT(0 != rv);
         PR_ASSERT(filetime.prt == _pr_filetime_offset);
     }
 #endif /* DEBUG */
 
     _PR_NT_InitSids();
 
-#ifndef WINCE
-    InitGetFileInfo();
-#endif
-
-    InitUnicodeSupport();
-
     _PR_MD_InitSockets();
 }
 
 PRStatus
 _PR_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
 {
     DWORD rv;
 
@@ -790,21 +582,16 @@ void
         PR_ASSERT((cmp / PR_USEC_PER_MSEC) == (*prtm / PR_USEC_PER_MSEC));
     }
 #endif /* DEBUG */
 }
 
 PRInt32
 _PR_MD_STAT(const char *fn, struct stat *info)
 {
-#ifdef WINCE
-    // needs work. dft
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return -1;
-#else
     PRInt32 rv;
 
     rv = _stat(fn, (struct _stat *)info);
     if (-1 == rv) {
         /*
          * Check for MSVC runtime library _stat() bug.
          * (It's really a bug in FindFirstFile().)
          * If a pathname ends in a backslash or slash,
@@ -826,17 +613,16 @@ PRInt32
             rv = _stat(newfn, (struct _stat *)info);
         }
     }
 
     if (-1 == rv) {
         _PR_MD_MAP_STAT_ERROR(errno);
     }
     return rv;
-#endif
 }
 
 #define _PR_IS_SLASH(ch) ((ch) == '/' || (ch) == '\\')
 
 static PRBool
 IsPrevCharSlash(const char *str, const char *current)
 {
     const char *prev;
@@ -930,144 +716,28 @@ IsRootDirectory(char *fn, size_t buflen)
         /* restore the 'fn' buffer */
         if (slashAdded) {
             *--p = '\0';
         }
     }
     return rv;
 }
 
-#ifndef WINCE
-/*
- * InitGetFileInfo --
- *
- * Called during IO init. Checks for the existence of the system function
- * GetFileAttributeEx, which when available is used in GETFILEINFO calls. 
- * If the routine exists, then the address of the routine is stored in the
- * variable getFileAttributesEx, which will be used to call the routine.
- */
-static void InitGetFileInfo(void)
-{
-    HMODULE module;
-    module = GetModuleHandle("Kernel32.dll");
-    if (!module) {
-        PR_LOG(_pr_io_lm, PR_LOG_DEBUG,
-                ("InitGetFileInfo: GetModuleHandle() failed: %d",
-                GetLastError()));
-        return;
-    }
-
-    getFileAttributesEx = (GetFileAttributesExFn)
-            GetProcAddress(module, "GetFileAttributesExA");
-}
-
-/*
- * If GetFileAttributeEx doesn't exist, we call FindFirstFile as a
- * fallback.
- */
-static BOOL
-GetFileAttributesExFB(const char *fn, WIN32_FIND_DATA *findFileData)
-{
-    HANDLE hFindFile;
-
-    /*
-     * FindFirstFile() expands wildcard characters.  So
-     * we make sure the pathname contains no wildcard.
-     */
-    if (NULL != _mbspbrk(fn, "?*")) {
-        SetLastError(ERROR_INVALID_NAME);
-        return FALSE;
-    }
-
-    hFindFile = FindFirstFile(fn, findFileData);
-    if (INVALID_HANDLE_VALUE == hFindFile) {
-        DWORD len;
-        char *filePart;
-        char pathbuf[MAX_PATH + 1];
-
-        /*
-         * FindFirstFile() does not work correctly on root directories.
-         * It also doesn't work correctly on a pathname that ends in a
-         * slash.  So we first check to see if the pathname specifies a
-         * root directory.  If not, and if the pathname ends in a slash,
-         * we remove the final slash and try again.
-         */
-
-        /*
-         * If the pathname does not contain ., \, and /, it cannot be
-         * a root directory or a pathname that ends in a slash.
-         */
-        if (NULL == _mbspbrk(fn, ".\\/")) {
-            return FALSE;
-        } 
-        len = GetFullPathName(fn, sizeof(pathbuf), pathbuf,
-                &filePart);
-        if (0 == len) {
-            return FALSE;
-        }
-        if (len > sizeof(pathbuf)) {
-            SetLastError(ERROR_FILENAME_EXCED_RANGE);
-            return FALSE;
-        }
-        if (IsRootDirectory(pathbuf, sizeof(pathbuf))) {
-            findFileData->dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
-            /* The file size doesn't have a meaning for directories. */
-            findFileData->nFileSizeHigh = 0;
-            findFileData->nFileSizeLow = 0;
-            /*
-             * For a directory, these timestamps all specify when the
-             * directory is created.  The creation time doesn't make
-             * sense for root directories, so we set it to (NSPR) time 0.
-             */
-            memcpy(&findFileData->ftCreationTime, &_pr_filetime_offset, 8);
-            findFileData->ftLastAccessTime = findFileData->ftCreationTime;
-            findFileData->ftLastWriteTime = findFileData->ftCreationTime;
-            return TRUE;
-        }
-        if (!IsPrevCharSlash(pathbuf, pathbuf + len)) {
-            return FALSE;
-        } else {
-            pathbuf[len - 1] = '\0';
-            hFindFile = FindFirstFile(pathbuf, findFileData);
-            if (INVALID_HANDLE_VALUE == hFindFile) {
-                return FALSE;
-            }
-        }
-    }
-
-    FindClose(hFindFile);
-    return TRUE;
-}
-#endif
-
 PRInt32
 _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info)
 {
-#ifdef WINCE
     WIN32_FILE_ATTRIBUTE_DATA findFileData;
-#else
-    WIN32_FIND_DATA findFileData;
-#endif
     BOOL rv;
     
     if (NULL == fn || '\0' == *fn) {
         PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
         return -1;
     }
 
-#ifdef WINCE
-    rv = GetFileAttributesExA(fn, GetFileExInfoStandard, &findFileData);
-#else
-    /* GetFileAttributesEx is supported on Win 2K and up. */
-    if (getFileAttributesEx) {
-        rv = getFileAttributesEx(fn, GetFileExInfoStandard, &findFileData);
-    } else {
-        rv = GetFileAttributesExFB(fn, &findFileData);
-    }
-#endif
+    rv = GetFileAttributesEx(fn, GetFileExInfoStandard, &findFileData);
     if (!rv) {
         _PR_MD_MAP_OPENDIR_ERROR(GetLastError());
         return -1;
     }
 
     if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
         info->type = PR_FILE_DIRECTORY;
     } else {
@@ -1145,65 +815,56 @@ PRInt32
         LL_L2I(info->size, info64.size);
     }
     return rv;
 }
 
 PRStatus
 _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable)
 {
-#ifdef WINCE
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return PR_FAILURE;
-#else
     BOOL rv;
 
     /*
      * The SetHandleInformation function fails with the
      * ERROR_CALL_NOT_IMPLEMENTED error on Win95.
      */
     rv = SetHandleInformation(
             (HANDLE)fd->secret->md.osfd,
             HANDLE_FLAG_INHERIT,
             inheritable ? HANDLE_FLAG_INHERIT : 0);
     if (0 == rv) {
         _PR_MD_MAP_DEFAULT_ERROR(GetLastError());
         return PR_FAILURE;
     }
     return PR_SUCCESS;
-#endif
 } 
 
 void
 _PR_MD_INIT_FD_INHERITABLE(PRFileDesc *fd, PRBool imported)
 {
     if (imported) {
         fd->secret->inheritable = _PR_TRI_UNKNOWN;
     } else {
         fd->secret->inheritable = _PR_TRI_FALSE;
     }
 }
 
 void
 _PR_MD_QUERY_FD_INHERITABLE(PRFileDesc *fd)
 {
-#ifdef WINCE
-    fd->secret->inheritable = _PR_TRI_FALSE;
-#else
     DWORD flags;
 
     PR_ASSERT(_PR_TRI_UNKNOWN == fd->secret->inheritable);
     if (GetHandleInformation((HANDLE)fd->secret->md.osfd, &flags)) {
         if (flags & HANDLE_FLAG_INHERIT) {
             fd->secret->inheritable = _PR_TRI_TRUE;
         } else {
             fd->secret->inheritable = _PR_TRI_FALSE;
         }
     }
-#endif
 }
 
 PRInt32
 _PR_MD_RENAME(const char *from, const char *to)
 {
     /* Does this work with dot-relative pathnames? */
     if (MoveFileA(from, to)) {
         return 0;
@@ -1211,20 +872,16 @@ PRInt32
 		_PR_MD_MAP_RENAME_ERROR(GetLastError());
         return -1;
     }
 }
 
 PRInt32
 _PR_MD_ACCESS(const char *name, PRAccessHow how)
 {
-#ifdef WINCE
-    PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
-    return -1;
-#else
 PRInt32 rv;
     switch (how) {
       case PR_ACCESS_WRITE_OK:
         rv = _access(name, 02);
 		break;
       case PR_ACCESS_READ_OK:
         rv = _access(name, 04);
 		break;
@@ -1233,17 +890,16 @@ PRInt32 rv;
 	  	break;
       default:
 		PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
 		return -1;
     }
 	if (rv < 0)
 		_PR_MD_MAP_ACCESS_ERROR(errno);
     return rv;
-#endif
 }
 
 PRInt32
 _PR_MD_MKDIR(const char *name, PRIntn mode)
 {
     /* XXXMB - how to translate the "mode"??? */
     if (CreateDirectoryA(name, NULL)) {
         return 0;
@@ -1359,50 +1015,16 @@ typedef BOOL (WINAPI *FindNextFileWFn) (
 static FindNextFileWFn findNextFileW = FindNextFileW;
 typedef DWORD (WINAPI *GetFullPathNameWFn) (LPCWSTR, DWORD, LPWSTR, LPWSTR *);
 static GetFullPathNameWFn getFullPathNameW = GetFullPathNameW;
 typedef UINT (WINAPI *GetDriveTypeWFn) (LPCWSTR);
 static GetDriveTypeWFn getDriveTypeW = GetDriveTypeW;
 
 #endif /* MOZ_UNICODE */
 
-PRBool _pr_useUnicode = PR_FALSE;
-
-static void InitUnicodeSupport(void)
-{
-#ifdef WINCE
-    /* The A functions don't even exist in Windows Mobile. */
-    _pr_useUnicode = PR_TRUE;
-#else
-    /*
-     * The W functions exist on Win9x as stubs that fail with the
-     * ERROR_CALL_NOT_IMPLEMENTED error.  We plan to emulate the
-     * MSLU W functions on Win9x in the future.
-     */
-
-    /* Find out if we are running on a Unicode enabled version of Windows */
-    OSVERSIONINFOA osvi = {0};
-
-    osvi.dwOSVersionInfoSize = sizeof(osvi);
-    if (GetVersionExA(&osvi)) {
-        _pr_useUnicode = (osvi.dwPlatformId >= VER_PLATFORM_WIN32_NT);
-    } else {
-        _pr_useUnicode = PR_FALSE;
-    }
-#ifdef DEBUG
-    /*
-     * In debug builds, allow explicit use of ANSI methods to simulate
-     * a Win9x environment for testing purposes.
-     */
-    if (getenv("WINAPI_USE_ANSI"))
-        _pr_useUnicode = PR_FALSE;
-#endif
-#endif
-}
-
 #ifdef MOZ_UNICODE
 
 /* ================ UTF16 Interfaces ================================ */
 static void FlipSlashesW(PRUnichar *cp, size_t len)
 {
     while (len-- > 0) {
         if (cp[0] == L'/') {
             cp[0] = L'\\';
--- a/nsprpub/pr/src/misc/prlong.c
+++ b/nsprpub/pr/src/misc/prlong.c
@@ -1,14 +1,14 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "primpl.h"
+#include "prlong.h"
 
 static PRInt64 ll_zero = LL_INIT( 0x00000000,0x00000000 );
 static PRInt64 ll_maxint = LL_INIT( 0x7fffffff, 0xffffffff );
 static PRInt64 ll_minint = LL_INIT( 0x80000000, 0x00000000 );
 static PRUint64 ll_maxuint = LL_INIT( 0xffffffff, 0xffffffff );
 
 PR_IMPLEMENT(PRInt64) LL_Zero(void) { return ll_zero; }
 PR_IMPLEMENT(PRInt64) LL_MaxInt(void) { return ll_maxint; }
--- a/nsprpub/pr/src/misc/prsystem.c
+++ b/nsprpub/pr/src/misc/prsystem.c
@@ -51,34 +51,16 @@
 #define MAX_LINE 512
 #endif
 
 #if defined(AIX)
 #include <cf.h>
 #include <sys/cfgodm.h>
 #endif
 
-#if defined(WIN32)
-/* This struct is not present in VC6 headers, so declare it here */
-typedef struct {
-    DWORD dwLength;
-    DWORD dwMemoryLoad;
-    DWORDLONG ullTotalPhys;
-    DWORDLONG ullAvailPhys;
-    DWORDLONG ullToalPageFile;
-    DWORDLONG ullAvailPageFile;
-    DWORDLONG ullTotalVirtual;
-    DWORDLONG ullAvailVirtual;
-    DWORDLONG ullAvailExtendedVirtual;
-} PR_MEMORYSTATUSEX;
-
-/* Typedef for dynamic lookup of GlobalMemoryStatusEx(). */
-typedef BOOL (WINAPI *GlobalMemoryStatusExFn)(PR_MEMORYSTATUSEX *);
-#endif
-
 PR_IMPLEMENT(char) PR_GetDirectorySeparator(void)
 {
     return PR_DIRECTORY_SEPARATOR;
 }  /* PR_GetDirectorySeparator */
 
 /*
 ** OBSOLETE -- the function name is misspelled.
 */
@@ -322,39 +304,20 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMem
                            HOST_BASIC_INFO,
                            (host_info_t) &hInfo,
                            &count);
     if (result == KERN_SUCCESS)
         bytes = hInfo.max_mem;
 
 #elif defined(WIN32)
 
-    /* Try to use the newer GlobalMemoryStatusEx API for Windows 2000+. */
-    GlobalMemoryStatusExFn globalMemory = (GlobalMemoryStatusExFn) NULL;
-    HMODULE module = GetModuleHandleW(L"kernel32.dll");
-
-    if (module) {
-        globalMemory = (GlobalMemoryStatusExFn)GetProcAddress(module, "GlobalMemoryStatusEx");
-
-        if (globalMemory) {
-            PR_MEMORYSTATUSEX memStat;
-            memStat.dwLength = sizeof(memStat);
-
-            if (globalMemory(&memStat))
-                bytes = memStat.ullTotalPhys;
-        }
-    }
-
-    if (!bytes) {
-        /* Fall back to the older API. */
-        MEMORYSTATUS memStat;
-        memset(&memStat, 0, sizeof(memStat));
-        GlobalMemoryStatus(&memStat);
-        bytes = memStat.dwTotalPhys;
-    }
+    MEMORYSTATUSEX memStat;
+    memStat.dwLength = sizeof(memStat);
+    if (GlobalMemoryStatusEx(&memStat))
+        bytes = memStat.ullTotalPhys;
 
 #elif defined(OS2)
 
     ULONG ulPhysMem;
     DosQuerySysInfo(QSV_TOTPHYSMEM,
                     QSV_TOTPHYSMEM,
                     &ulPhysMem,
                     sizeof(ulPhysMem));
--- a/nsprpub/pr/src/pthreads/ptthread.c
+++ b/nsprpub/pr/src/pthreads/ptthread.c
@@ -57,40 +57,46 @@ static struct _PT_Bookeeping
     PRInt32 minPrio, maxPrio;   /* range of scheduling priorities */
 #endif
 } pt_book = {0};
 
 static void _pt_thread_death(void *arg);
 static void _pt_thread_death_internal(void *arg, PRBool callDestructors);
 static void init_pthread_gc_support(void);
 
-#if defined(_PR_DCETHREADS) || \
-    defined(_POSIX_THREAD_PRIORITY_SCHEDULING) || \
-    defined(_PR_NICE_PRIORITY_SCHEDULING)
+#if defined(_PR_DCETHREADS) || defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
 static PRIntn pt_PriorityMap(PRThreadPriority pri)
 {
 #ifdef NTO
     /* This priority algorithm causes lots of problems on Neutrino
      * for now I have just hard coded everything to run at priority 10
      * until I can come up with a new algorithm.
      *     Jerry.Kirk@Nexwarecorp.com
      */
     return 10;
-#elif defined(_PR_NICE_PRIORITY_SCHEDULING)
-    /* This maps high priorities to low nice values:
-     * PR_PRIORITY_LOW     1
-     * PR_PRIORITY_NORMAL  0
-     * PR_PRIORITY_HIGH   -1
-     * PR_PRIORITY_URGENT -2 */
-    return 1 - pri;
 #else
     return pt_book.minPrio +
 	    pri * (pt_book.maxPrio - pt_book.minPrio) / PR_PRIORITY_LAST;
 #endif
 }
+#elif defined(_PR_NICE_PRIORITY_SCHEDULING)
+/*
+ * This functions maps higher priorities to lower nice values relative to the
+ * nice value specified in the |nice| parameter. The corresponding relative
+ * adjustments are:
+ *
+ * PR_PRIORITY_LOW    +1
+ * PR_PRIORITY_NORMAL  0
+ * PR_PRIORITY_HIGH   -1
+ * PR_PRIORITY_URGENT -2
+ */
+static int pt_RelativePriority(int nice, PRThreadPriority pri)
+{
+    return nice + (1 - pri);
+}
 #endif
 
 /*
 ** Initialize a stack for a native pthread thread
 */
 static void _PR_InitializeStack(PRThreadStack *ts)
 {
     if( ts && (ts->stackTop == 0) ) {
@@ -128,21 +134,28 @@ static void *_pt_root(void *arg)
      * they are writing the same value, this unprotected double
      * write should be safe.
      */
     thred->id = pthread_self();
 
 #ifdef _PR_NICE_PRIORITY_SCHEDULING
     /*
      * We need to know the kernel thread ID of each thread in order to
-     * set its priority hence we do it here instead of at creation time.
+     * set its nice value hence we do it here instead of at creation time.
      */
     tid = gettid();
+    errno = 0;
+    rv = getpriority(PRIO_PROCESS, 0);
 
-    rv = setpriority(PRIO_PROCESS, tid, pt_PriorityMap(thred->priority));
+    /* If we cannot read the main thread's nice value don't try to change the
+     * new thread's nice value. */
+    if (errno == 0) {
+        setpriority(PRIO_PROCESS, tid,
+                    pt_RelativePriority(rv, thred->priority));
+    }
 
     PR_Lock(pt_book.ml);
     thred->tid = tid;
     PR_NotifyAllCondVar(pt_book.cv);
     PR_Unlock(pt_book.ml);
 #endif
 
     /*
@@ -683,24 +696,32 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(
 			rv = -1;
     }
 #elif defined(_PR_NICE_PRIORITY_SCHEDULING)
     PR_Lock(pt_book.ml);
     while (thred->tid == 0)
         PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);
     PR_Unlock(pt_book.ml);
 
-    rv = setpriority(PRIO_PROCESS, thred->tid, pt_PriorityMap(newPri));
+    errno = 0;
+    rv = getpriority(PRIO_PROCESS, 0);
+
+    /* Do not proceed unless we know the main thread's nice value. */
+    if (errno == 0) {
+        rv = setpriority(PRIO_PROCESS, thred->tid,
+                         pt_RelativePriority(rv, newPri));
 
-    if (rv == -1 && errno == EPERM)
-    {
-        /* We don't set pt_schedpriv to EPERM because adjusting the nice
-         * value might be permitted for certain ranges but not others */
-        PR_LOG(_pr_thread_lm, PR_LOG_MIN,
-            ("PR_SetThreadPriority: no thread scheduling privilege"));
+        if (rv == -1)
+        {
+            /* We don't set pt_schedpriv to EPERM in case errno == EPERM
+             * because adjusting the nice value might be permitted for certain
+             * ranges but not for others. */
+            PR_LOG(_pr_thread_lm, PR_LOG_MIN,
+                ("PR_SetThreadPriority: no thread scheduling privilege"));
+        }
     }
 #endif
 
     thred->priority = newPri;
 }  /* PR_SetThreadPriority */
 
 PR_IMPLEMENT(PRStatus) PR_Interrupt(PRThread *thred)
 {
--- a/nsprpub/pr/tests/vercheck.c
+++ b/nsprpub/pr/tests/vercheck.c
@@ -15,49 +15,50 @@
  */
 
 #include "prinit.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 
 /*
- * This release (4.9.6) is backward compatible with the
+ * This release (4.10) is backward compatible with the
  * 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, 4.5.x, 4.6.x, 4.7.x,
- * 4.8.x, 4.9, 4.9.1, 4.9.2, 4.9.3, 4.9.4, and 4.9.5 releases.
+ * 4.8.x, and 4.9.x releases.
  * It, of course, is compatible with itself.
  */
 static char *compatible_version[] = {
     "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3",
     "4.2", "4.2.1", "4.2.2", "4.3", "4.4", "4.4.1",
     "4.5", "4.5.1",
     "4.6", "4.6.1", "4.6.2", "4.6.3", "4.6.4", "4.6.5",
     "4.6.6", "4.6.7", "4.6.8",
     "4.7", "4.7.1", "4.7.2", "4.7.3", "4.7.4", "4.7.5",
     "4.7.6",
     "4.8", "4.8.1", "4.8.2", "4.8.3", "4.8.4", "4.8.5",
     "4.8.6", "4.8.7", "4.8.8", "4.8.9",
     "4.9", "4.9.1", "4.9.2", "4.9.3", "4.9.4", "4.9.5",
+    "4.9.6",
     PR_VERSION
 };
 
 /*
  * This release is not backward compatible with the old
  * NSPR 2.1 and 3.x releases.
  *
  * Any release is incompatible with future releases and
  * patches.
  */
 static char *incompatible_version[] = {
     "2.1 19980529",
     "3.0", "3.0.1",
     "3.1", "3.1.1", "3.1.2", "3.1.3",
     "3.5", "3.5.1",
-    "4.9.7",
-    "4.10", "4.10.1",
+    "4.10.1",
+    "4.11", "4.11.1",
     "10.0", "11.1", "12.14.20"
 };
 
 int main(int argc, char **argv)
 {
     int idx;
     int num_compatible = sizeof(compatible_version) / sizeof(char *);
     int num_incompatible = sizeof(incompatible_version) / sizeof(char *);