Bug 865828 - Upgrade Mozilla 23 to NSPR 4.10, r=wtc

This commit is contained in:
Kai Engert 2013-04-25 22:06:51 +02:00
parent 334dac4952
commit 081d555a74
34 changed files with 187 additions and 504 deletions

View File

@ -1 +1 @@
NSPR_4_9_6_RTM
NSPR_4_10_BETA1

12
nsprpub/configure vendored
View File

@ -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 <<EOF
#define ANDROID_VERSION $android_version
EOF
;;
@ -1449,12 +1445,12 @@ echo "configure:1447: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS
#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

View File

@ -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

View File

@ -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();

View File

@ -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); \

View File

@ -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 = ../..

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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 = ../..

View File

@ -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

View File

@ -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 = ../../..

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

2
nsprpub/pkg/solaris/SUNWprd/Makefile.in Normal file → Executable file
View File

@ -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 = ../../..

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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 <stdlib.h>
#pragma intrinsic(_rotl, _rotr)
#define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits)

View File

@ -31,11 +31,11 @@ PR_BEGIN_EXTERN_C
** 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

View File

@ -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);

View File

@ -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);
}

View File

@ -16,197 +16,6 @@
#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;
/*
@ -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 ================================ */

View File

@ -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 );

View File

@ -56,24 +56,6 @@
#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;
@ -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)

View File

@ -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();
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;
@ -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

View File

@ -20,9 +20,9 @@
#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[] = {
@ -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"
};