diff --git a/nsprpub/TAG-INFO b/nsprpub/TAG-INFO index d26f36a53c50d..46b44f36c3eb3 100644 --- a/nsprpub/TAG-INFO +++ b/nsprpub/TAG-INFO @@ -1 +1 @@ -NSPR_4_9_6_RTM +NSPR_4_10_BETA1 diff --git a/nsprpub/configure b/nsprpub/configure index b06997fa19a96..369a529b9d81c 100755 --- a/nsprpub/configure +++ b/nsprpub/configure @@ -735,8 +735,8 @@ test "$host_alias" != "$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= @@ -1017,10 +1017,6 @@ echo "configure:961: checking for android platform directory" >&5 cat >> confdefs.h <<\EOF #define ANDROID 1 -EOF - - cat >> confdefs.h <&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 diff --git a/nsprpub/configure.in b/nsprpub/configure.in index 71e9b856316dd..59598c05b79a2 100644 --- a/nsprpub/configure.in +++ b/nsprpub/configure.in @@ -14,8 +14,8 @@ 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= @@ -271,7 +271,6 @@ case "$target" in fi AC_DEFINE(ANDROID) - AC_DEFINE_UNQUOTED(ANDROID_VERSION, $android_version) ;; esac fi @@ -593,9 +592,9 @@ if test "$target" != "$host" -o -n "$CROSS_COMPILE"; then 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 @@ -2553,8 +2552,8 @@ case $target in ;; *) 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 diff --git a/nsprpub/lib/ds/plarena.c b/nsprpub/lib/ds/plarena.c index 4053195145355..211dd671ccff1 100644 --- a/nsprpub/lib/ds/plarena.c +++ b/nsprpub/lib/ds/plarena.c @@ -157,6 +157,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb) pool->current = a; rp = (char *)a->avail; a->avail += nb; + PL_MAKE_MEM_UNDEFINED(rp, nb); return rp; } } while( NULL != (a = a->next) ); @@ -187,6 +188,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb) pool->current = a; if ( NULL == pool->first.next ) pool->first.next = a; + PL_MAKE_MEM_UNDEFINED(rp, nb); return(rp); } } @@ -201,6 +203,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb) 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 @@ -212,6 +215,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb) pool->first.next = a; PL_COUNT_ARENA(pool,++); COUNT(pool, nmallocs); + PL_MAKE_MEM_UNDEFINED(rp, nb); return(rp); } } @@ -237,7 +241,8 @@ 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); } } @@ -273,6 +278,8 @@ static void FreeArenaList(PLArenaPool *pool, PLArena *head, PRBool reallyFree) } 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(); diff --git a/nsprpub/lib/ds/plarena.h b/nsprpub/lib/ds/plarena.h index 4d54cc4616bde..c4974304453fe 100644 --- a/nsprpub/lib/ds/plarena.h +++ b/nsprpub/lib/ds/plarena.h @@ -57,6 +57,68 @@ struct PLArenaPool { #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 @@ -78,10 +140,12 @@ struct PLArenaPool { 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 @@ -94,6 +158,7 @@ struct PLArenaPool { 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 { \ @@ -106,13 +171,19 @@ struct PLArenaPool { #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) @@ -125,6 +196,7 @@ struct PLArenaPool { 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); \ diff --git a/nsprpub/pkg/linux/Makefile.in b/nsprpub/pkg/linux/Makefile.in index 9d51bcca741d7..63fa75030a8ec 100644 --- a/nsprpub/pkg/linux/Makefile.in +++ b/nsprpub/pkg/linux/Makefile.in @@ -6,7 +6,7 @@ # 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 = ../.. diff --git a/nsprpub/pkg/solaris/Makefile-devl.com b/nsprpub/pkg/solaris/Makefile-devl.com index 4a6366a377ac8..86eab396259dd 100755 --- a/nsprpub/pkg/solaris/Makefile-devl.com +++ b/nsprpub/pkg/solaris/Makefile-devl.com @@ -6,7 +6,7 @@ # 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) diff --git a/nsprpub/pkg/solaris/Makefile-devl.targ b/nsprpub/pkg/solaris/Makefile-devl.targ index 32e14d31383a9..210b501c1d1c5 100755 --- a/nsprpub/pkg/solaris/Makefile-devl.targ +++ b/nsprpub/pkg/solaris/Makefile-devl.targ @@ -6,7 +6,7 @@ # 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 diff --git a/nsprpub/pkg/solaris/Makefile.com b/nsprpub/pkg/solaris/Makefile.com index 7515fcb0343d4..d4da88752f072 100644 --- a/nsprpub/pkg/solaris/Makefile.com +++ b/nsprpub/pkg/solaris/Makefile.com @@ -6,7 +6,7 @@ # 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) diff --git a/nsprpub/pkg/solaris/Makefile.in b/nsprpub/pkg/solaris/Makefile.in index cdd6f1acf27c4..b34a23aafe8fe 100644 --- a/nsprpub/pkg/solaris/Makefile.in +++ b/nsprpub/pkg/solaris/Makefile.in @@ -6,7 +6,7 @@ # 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 = ../.. diff --git a/nsprpub/pkg/solaris/Makefile.targ b/nsprpub/pkg/solaris/Makefile.targ index 5212ccd34cc32..742ee932a9b4c 100644 --- a/nsprpub/pkg/solaris/Makefile.targ +++ b/nsprpub/pkg/solaris/Makefile.targ @@ -6,7 +6,7 @@ # 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 diff --git a/nsprpub/pkg/solaris/SUNWpr/Makefile.in b/nsprpub/pkg/solaris/SUNWpr/Makefile.in index b07142f661be9..9fe1f0abd0a80 100644 --- a/nsprpub/pkg/solaris/SUNWpr/Makefile.in +++ b/nsprpub/pkg/solaris/SUNWpr/Makefile.in @@ -6,7 +6,7 @@ # 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 = ../../.. diff --git a/nsprpub/pkg/solaris/SUNWpr/depend b/nsprpub/pkg/solaris/SUNWpr/depend index 473cda5466485..4dd09c5aa78a5 100644 --- a/nsprpub/pkg/solaris/SUNWpr/depend +++ b/nsprpub/pkg/solaris/SUNWpr/depend @@ -6,7 +6,7 @@ # 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: diff --git a/nsprpub/pkg/solaris/SUNWpr/pkginfo.tmpl b/nsprpub/pkg/solaris/SUNWpr/pkginfo.tmpl index 8ceec7ca0f979..3c1a107bd8d8c 100644 --- a/nsprpub/pkg/solaris/SUNWpr/pkginfo.tmpl +++ b/nsprpub/pkg/solaris/SUNWpr/pkginfo.tmpl @@ -6,7 +6,7 @@ # 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 diff --git a/nsprpub/pkg/solaris/SUNWpr/prototype_com b/nsprpub/pkg/solaris/SUNWpr/prototype_com index 65fedbafb437b..4b994eac2f9a1 100644 --- a/nsprpub/pkg/solaris/SUNWpr/prototype_com +++ b/nsprpub/pkg/solaris/SUNWpr/prototype_com @@ -6,7 +6,7 @@ # 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 diff --git a/nsprpub/pkg/solaris/SUNWpr/prototype_i386 b/nsprpub/pkg/solaris/SUNWpr/prototype_i386 index 09d49a9adc2d4..e2f7a2f0386f6 100644 --- a/nsprpub/pkg/solaris/SUNWpr/prototype_i386 +++ b/nsprpub/pkg/solaris/SUNWpr/prototype_i386 @@ -6,7 +6,7 @@ # 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 diff --git a/nsprpub/pkg/solaris/SUNWpr/prototype_sparc b/nsprpub/pkg/solaris/SUNWpr/prototype_sparc index a92b61be5437f..aae5f184852bd 100644 --- a/nsprpub/pkg/solaris/SUNWpr/prototype_sparc +++ b/nsprpub/pkg/solaris/SUNWpr/prototype_sparc @@ -6,7 +6,7 @@ # 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 diff --git a/nsprpub/pkg/solaris/SUNWprd/Makefile.in b/nsprpub/pkg/solaris/SUNWprd/Makefile.in old mode 100644 new mode 100755 index b6f1222412131..0cb4c289e8ee5 --- a/nsprpub/pkg/solaris/SUNWprd/Makefile.in +++ b/nsprpub/pkg/solaris/SUNWprd/Makefile.in @@ -6,7 +6,7 @@ # 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 = ../../.. diff --git a/nsprpub/pkg/solaris/SUNWprd/depend b/nsprpub/pkg/solaris/SUNWprd/depend index 8d4b1ff1e6199..2415c54103fe1 100755 --- a/nsprpub/pkg/solaris/SUNWprd/depend +++ b/nsprpub/pkg/solaris/SUNWprd/depend @@ -6,7 +6,7 @@ # 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: diff --git a/nsprpub/pkg/solaris/SUNWprd/pkginfo.tmpl b/nsprpub/pkg/solaris/SUNWprd/pkginfo.tmpl index 8b3d6afd71c31..5003122ab81ee 100755 --- a/nsprpub/pkg/solaris/SUNWprd/pkginfo.tmpl +++ b/nsprpub/pkg/solaris/SUNWprd/pkginfo.tmpl @@ -6,7 +6,7 @@ # 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 diff --git a/nsprpub/pkg/solaris/SUNWprd/prototype b/nsprpub/pkg/solaris/SUNWprd/prototype index 4f645b698a1dd..44f52bab208de 100755 --- a/nsprpub/pkg/solaris/SUNWprd/prototype +++ b/nsprpub/pkg/solaris/SUNWprd/prototype @@ -6,7 +6,7 @@ # 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 diff --git a/nsprpub/pkg/solaris/bld_awk_pkginfo.ksh b/nsprpub/pkg/solaris/bld_awk_pkginfo.ksh index 260044bf22c19..67f1df7e858b6 100644 --- a/nsprpub/pkg/solaris/bld_awk_pkginfo.ksh +++ b/nsprpub/pkg/solaris/bld_awk_pkginfo.ksh @@ -7,7 +7,7 @@ # 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 diff --git a/nsprpub/pkg/solaris/proto64.mk b/nsprpub/pkg/solaris/proto64.mk index 7d97e188c3948..69bb1fc8f1a34 100644 --- a/nsprpub/pkg/solaris/proto64.mk +++ b/nsprpub/pkg/solaris/proto64.mk @@ -6,7 +6,7 @@ # 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) diff --git a/nsprpub/pr/include/md/_win95.cfg b/nsprpub/pr/include/md/_win95.cfg index 77d1828716743..1e693cc68ca40 100644 --- a/nsprpub/pr/include/md/_win95.cfg +++ b/nsprpub/pr/include/md/_win95.cfg @@ -14,15 +14,9 @@ #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 */ @@ -214,7 +208,7 @@ #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 diff --git a/nsprpub/pr/include/md/_win95.h b/nsprpub/pr/include/md/_win95.h index 3db340e3de49f..b008c13237cd6 100644 --- a/nsprpub/pr/include/md/_win95.h +++ b/nsprpub/pr/include/md/_win95.h @@ -246,7 +246,6 @@ extern PRInt32 _MD_CloseFile(PROsfd osfd); #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 diff --git a/nsprpub/pr/include/prbit.h b/nsprpub/pr/include/prbit.h index f0a51d016c56e..de8375088b48e 100644 --- a/nsprpub/pr/include/prbit.h +++ b/nsprpub/pr/include/prbit.h @@ -9,8 +9,12 @@ #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) @@ -133,7 +137,7 @@ NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i); */ #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \ - defined(_M_X64)) + defined(_M_X64) || defined(_M_ARM)) #include #pragma intrinsic(_rotl, _rotr) #define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits) diff --git a/nsprpub/pr/include/prinit.h b/nsprpub/pr/include/prinit.h index 5506bd04a1db3..ca6df2d5f8918 100644 --- a/nsprpub/pr/include/prinit.h +++ b/nsprpub/pr/include/prinit.h @@ -31,11 +31,11 @@ PR_BEGIN_EXTERN_C ** The format of the version string is ** ".[.] []" */ -#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 diff --git a/nsprpub/pr/include/prthread.h b/nsprpub/pr/include/prthread.h index 708c889c74b9f..f8b28a62d64c8 100644 --- a/nsprpub/pr/include/prthread.h +++ b/nsprpub/pr/include/prthread.h @@ -141,6 +141,13 @@ 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); diff --git a/nsprpub/pr/src/md/windows/ntsem.c b/nsprpub/pr/src/md/windows/ntsem.c index cc71fe30f1256..f36a145a91d7a 100644 --- a/nsprpub/pr/src/md/windows/ntsem.c +++ b/nsprpub/pr/src/md/windows/ntsem.c @@ -46,7 +46,5 @@ _PR_MD_WAIT_SEM(_MDSemaphore *md) void _PR_MD_POST_SEM(_MDSemaphore *md) { - int old_count; - - ReleaseSemaphore(md->sem, 1, &old_count); + ReleaseSemaphore(md->sem, 1, NULL); } diff --git a/nsprpub/pr/src/md/windows/w95io.c b/nsprpub/pr/src/md/windows/w95io.c index dad08f2569448..824b6fff7a359 100644 --- a/nsprpub/pr/src/md/windows/w95io.c +++ b/nsprpub/pr/src/md/windows/w95io.c @@ -16,197 +16,6 @@ #include #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; /* @@ -227,17 +36,6 @@ static DWORD dirAccessTable[] = { 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 @@ -277,12 +75,6 @@ _PR_MD_INIT_IO() _PR_NT_InitSids(); -#ifndef WINCE - InitGetFileInfo(); -#endif - - InitUnicodeSupport(); - _PR_MD_InitSockets(); } @@ -795,11 +587,6 @@ _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm) 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); @@ -831,7 +618,6 @@ _PR_MD_STAT(const char *fn, struct stat *info) _PR_MD_MAP_STAT_ERROR(errno); } return rv; -#endif } #define _PR_IS_SLASH(ch) ((ch) == '/' || (ch) == '\\') @@ -935,117 +721,10 @@ IsRootDirectory(char *fn, size_t buflen) 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) { @@ -1053,16 +732,7 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info) 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; @@ -1150,10 +820,6 @@ _PR_MD_GETOPENFILEINFO(const PRFileDesc *fd, PRFileInfo *info) 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; /* @@ -1169,7 +835,6 @@ _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable) return PR_FAILURE; } return PR_SUCCESS; -#endif } void @@ -1185,9 +850,6 @@ _PR_MD_INIT_FD_INHERITABLE(PRFileDesc *fd, PRBool imported) 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); @@ -1198,7 +860,6 @@ _PR_MD_QUERY_FD_INHERITABLE(PRFileDesc *fd) fd->secret->inheritable = _PR_TRI_FALSE; } } -#endif } PRInt32 @@ -1216,10 +877,6 @@ _PR_MD_RENAME(const char *from, const char *to) 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: @@ -1238,7 +895,6 @@ PRInt32 rv; if (rv < 0) _PR_MD_MAP_ACCESS_ERROR(errno); return rv; -#endif } PRInt32 @@ -1364,40 +1020,6 @@ 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 ================================ */ diff --git a/nsprpub/pr/src/misc/prlong.c b/nsprpub/pr/src/misc/prlong.c index 630b2a8668436..701d0812d78ed 100644 --- a/nsprpub/pr/src/misc/prlong.c +++ b/nsprpub/pr/src/misc/prlong.c @@ -3,7 +3,7 @@ * 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 ); diff --git a/nsprpub/pr/src/misc/prsystem.c b/nsprpub/pr/src/misc/prsystem.c index f79d5884c1105..9579fcc931f1c 100644 --- a/nsprpub/pr/src/misc/prsystem.c +++ b/nsprpub/pr/src/misc/prsystem.c @@ -56,24 +56,6 @@ #include #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; @@ -327,29 +309,10 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void) #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) diff --git a/nsprpub/pr/src/pthreads/ptthread.c b/nsprpub/pr/src/pthreads/ptthread.c index abc27603261b5..8a87c14fba899 100644 --- a/nsprpub/pr/src/pthreads/ptthread.c +++ b/nsprpub/pr/src/pthreads/ptthread.c @@ -62,9 +62,7 @@ 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 @@ -74,18 +72,26 @@ static PRIntn pt_PriorityMap(PRThreadPriority pri) * 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 /* @@ -133,11 +139,18 @@ static void *_pt_root(void *arg) #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(); - - rv = setpriority(PRIO_PROCESS, tid, pt_PriorityMap(thred->priority)); + errno = 0; + rv = getpriority(PRIO_PROCESS, 0); + + /* 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; @@ -688,14 +701,22 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri 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); - 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")); + /* 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) + { + /* 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 diff --git a/nsprpub/pr/tests/vercheck.c b/nsprpub/pr/tests/vercheck.c index 3ba852e0aed28..8b98d87a88c21 100644 --- a/nsprpub/pr/tests/vercheck.c +++ b/nsprpub/pr/tests/vercheck.c @@ -20,9 +20,9 @@ #include /* - * 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[] = { @@ -36,6 +36,7 @@ static char *compatible_version[] = { "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 }; @@ -51,8 +52,8 @@ static char *incompatible_version[] = { "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" };