Skip to content

Commit

Permalink
Bug 807883: Update NSPR to NSPR 4.9.6 Beta 1 to pick up the new
Browse files Browse the repository at this point in the history
PL_SizeOfArenaPoolExcludingPool function. Also include the fixes
for bug 782214, bug 812085, bug 827271.
  • Loading branch information
wantehchang committed Feb 11, 2013
1 parent 4db9ef7 commit d17c161
Show file tree
Hide file tree
Showing 13 changed files with 294 additions and 132 deletions.
2 changes: 1 addition & 1 deletion nsprpub/TAG-INFO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NSPR_4_9_5_RTM
NSPR_4_9_6_BETA1
1 change: 1 addition & 0 deletions nsprpub/config/prdepend.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
*/

#error "Do not include this header file."

237 changes: 122 additions & 115 deletions nsprpub/configure

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions nsprpub/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dnl = Defaults
dnl ========================================================
MOD_MAJOR_VERSION=4
MOD_MINOR_VERSION=9
MOD_PATCH_VERSION=5
MOD_PATCH_VERSION=6
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
USE_PTHREADS=
Expand Down Expand Up @@ -111,11 +111,20 @@ AC_ARG_WITH(android-toolchain,
location of the Android toolchain],
android_toolchain=$withval)

dnl The default android_version is different for each target cpu.
case "$target_cpu" in
arm)
android_version=5
;;
i?86|mipsel)
android_version=9
;;
esac

AC_ARG_WITH(android-version,
[ --with-android-version=VER
Android platform version, default 5],
android_version=$withval,
android_version=5)
Android platform version, default 5 for arm, 9 for x86/mips],
android_version=$withval)

AC_ARG_WITH(android-platform,
[ --with-android-platform=DIR
Expand Down
16 changes: 16 additions & 0 deletions nsprpub/lib/ds/plarena.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,22 @@ PR_IMPLEMENT(void) PL_ArenaFinish(void)
once = pristineCallOnce;
}

PR_IMPLEMENT(size_t) PL_SizeOfArenaPoolExcludingPool(
PLArenaPool *pool, PLMallocSizeFn mallocSizeOf)
{
/*
* The first PLArena is within |pool|, so don't measure it. Subsequent
* PLArenas are separate and must measured.
*/
size_t size = 0;
PLArena *arena = pool->first.next;
while (arena) {
size += mallocSizeOf(arena);
arena = arena->next;
}
return size;
}

#ifdef PL_ARENAMETER
PR_IMPLEMENT(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb)
{
Expand Down
13 changes: 13 additions & 0 deletions nsprpub/lib/ds/plarenas.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
*/
PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern);

/*
** A function like malloc_size() or malloc_usable_size() that returns the
** size of a heap block.
*/
typedef size_t (*PLMallocSizeFn)(const void *ptr);

/*
** Return all memory used by a PLArenaPool, excluding the PLArenaPool
** structure.
*/
PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool(
PLArenaPool *pool, PLMallocSizeFn mallocSizeOf);

PR_END_EXTERN_C

#endif /* PLARENAS_H */
4 changes: 4 additions & 0 deletions nsprpub/lib/ds/plds.def
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ PL_HashTableRawLookupConst;
;+ global:
PL_ClearArenaPool;
;+} NSPR_4.1;
;+NSPR_4.9.6 {
;+ global:
PL_SizeOfArenaPoolExcludingPool;
;+} NSPR_4.8.5;
53 changes: 53 additions & 0 deletions nsprpub/pr/include/md/_linux.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,59 @@
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3

#elif defined(__aarch64__)

#ifdef __AARCH64EB__
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#elif defined(__AARCH64EL__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#else
#error "Unknown Aarch64 endianness."
#endif
#define IS_64

#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8

#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64

#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6

#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8

#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3

#elif defined(__hppa__)

#undef IS_LITTLE_ENDIAN
Expand Down
8 changes: 7 additions & 1 deletion nsprpub/pr/include/md/_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#define _PR_SI_ARCHITECTURE "mips"
#elif defined(__arm__)
#define _PR_SI_ARCHITECTURE "arm"
#elif defined(__aarch64__)
#define _PR_SI_ARCHITECTURE "aarch64"
#elif defined(__hppa__)
#define _PR_SI_ARCHITECTURE "hppa"
#elif defined(__s390x__)
Expand All @@ -63,6 +65,10 @@
#define _MD_DEFAULT_STACK_SIZE 65536L
#define _MD_MMAP_FLAGS MAP_PRIVATE

#if defined(__aarch64__)
#define _MD_MINIMUM_STACK_SIZE 0x20000
#endif

#undef HAVE_STACK_GROWING_UP

/*
Expand Down Expand Up @@ -186,7 +192,7 @@ extern PRInt32 _PR_ppc_AtomicSet(PRInt32 *val, PRInt32 newval);
})
#endif

#if defined(__arm__)
#if defined(__arm__) || defined(__aarch64__)
#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
/* Use GCC built-in functions */
#define _PR_HAVE_ATOMIC_OPS
Expand Down
6 changes: 3 additions & 3 deletions nsprpub/pr/include/md/_win95.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ extern PROsfd _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,

/* --- Lock stuff --- */
#define _PR_LOCK _MD_LOCK
#define _PR_UNLOCK _MD_UNLOCK
#define _PR_UNLOCK _MD_UNLOCK

#define _MD_NEW_LOCK(lock) (InitializeCriticalSection(&((lock)->mutex)),(lock)->notified.length=0,(lock)->notified.link=NULL,PR_SUCCESS)
#define _MD_NEW_LOCK _PR_MD_NEW_LOCK
#define _MD_FREE_LOCK(lock) DeleteCriticalSection(&((lock)->mutex))
#define _MD_LOCK(lock) EnterCriticalSection(&((lock)->mutex))
#define _MD_TEST_AND_LOCK(lock) (EnterCriticalSection(&((lock)->mutex)),0)
Expand Down Expand Up @@ -499,7 +499,7 @@ extern DWORD _pr_currentCPUIndex;
#define _PR_UnlockSched() 0

/* --- Initialization stuff --- */
#define _MD_INIT_LOCKS()
#define _MD_INIT_LOCKS _PR_MD_INIT_LOCKS

/* --- Stack stuff --- */
#define _MD_INIT_STACK(stack, redzone)
Expand Down
6 changes: 3 additions & 3 deletions nsprpub/pr/include/prinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.5"
#define PR_VERSION "4.9.6 Beta"
#define PR_VMAJOR 4
#define PR_VMINOR 9
#define PR_VPATCH 5
#define PR_BETA PR_FALSE
#define PR_VPATCH 6
#define PR_BETA PR_TRUE

/*
** PRVersionCheck
Expand Down
54 changes: 53 additions & 1 deletion nsprpub/pr/src/md/windows/w95cv.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,64 @@ void _PR_MD_NOTIFYALL_CV(_MDCVar *cv, _MDLock *lock)
return;
}

typedef BOOL (WINAPI *INITIALIZECRITICALSECTIONEX)(
CRITICAL_SECTION *lpCriticalSection,
DWORD dwSpinCount,
DWORD Flags);

static INITIALIZECRITICALSECTIONEX sInitializeCriticalSectionEx;

void _PR_MD_INIT_LOCKS(void)
{
/*
* Starting with Windows Vista, every CRITICAL_SECTION allocates an extra
* RTL_CRITICAL_SECTION_DEBUG object. Unfortunately, this debug object is
* not reclaimed by DeleteCriticalSection(), causing an apparent memory
* leak. This is a debugging "feature", not a bug. If we are running on
* Vista or later, use InitializeCriticalSectionEx() to allocate
* CRITICAL_SECTIONs without debug objects.
*/
HMODULE hKernel32 = GetModuleHandle("kernel32.dll");
PR_ASSERT(hKernel32);
PR_ASSERT(!sInitializeCriticalSectionEx);
sInitializeCriticalSectionEx = (INITIALIZECRITICALSECTIONEX)
GetProcAddress(hKernel32, "InitializeCriticalSectionEx");
}

/*
* By default, CRITICAL_SECTIONs are initialized with a spin count of 0.
* Joe Duffy's "Concurrent Programming on Windows" book suggests 1500 is
* a "reasonable starting point". On single-processor systems, the spin
* count is ignored and the critical section spin count is set to 0.
*/
#define LOCK_SPIN_COUNT 1500

PRStatus _PR_MD_NEW_LOCK(_MDLock *lock)
{
CRITICAL_SECTION *cs = &lock->mutex;
BOOL ok;

if (sInitializeCriticalSectionEx) {
ok = sInitializeCriticalSectionEx(cs, LOCK_SPIN_COUNT,
CRITICAL_SECTION_NO_DEBUG_INFO);
} else {
ok = InitializeCriticalSectionAndSpinCount(cs, LOCK_SPIN_COUNT);
}
if (!ok) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
return PR_FAILURE;
}

lock->notified.length = 0;
lock->notified.link = NULL;
return PR_SUCCESS;
}

void _PR_MD_UNLOCK(_MDLock *lock)
{
if (0 != lock->notified.length) {
md_UnlockAndPostNotifies(lock, NULL, NULL);
} else {
LeaveCriticalSection(&lock->mutex);
}
return;
}
9 changes: 5 additions & 4 deletions nsprpub/pr/tests/vercheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include <stdlib.h>

/*
* This release (4.9.5) is backward compatible with the
* This release (4.9.6) 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, and 4.9.4 releases.
* 4.8.x, 4.9, 4.9.1, 4.9.2, 4.9.3, 4.9.4, and 4.9.5 releases.
* It, of course, is compatible with itself.
*/
static char *compatible_version[] = {
Expand All @@ -35,7 +35,8 @@ static char *compatible_version[] = {
"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", PR_VERSION
"4.9", "4.9.1", "4.9.2", "4.9.3", "4.9.4", "4.9.5",
PR_VERSION
};

/*
Expand All @@ -50,7 +51,7 @@ 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.6",
"4.9.7",
"4.10", "4.10.1",
"10.0", "11.1", "12.14.20"
};
Expand Down

0 comments on commit d17c161

Please sign in to comment.