зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1293329, land NSPR_4_13_BETA2, r=ted
This commit is contained in:
Родитель
491499da43
Коммит
02e277f76d
|
@ -1 +1 @@
|
|||
NSPR_4_12_RTM
|
||||
NSPR_4_13_BETA2
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
#!/usr/bin/python
|
||||
# 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/.
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
import shutil
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
from subprocess import check_call
|
||||
|
||||
prinit_h = "pr/include/prinit.h"
|
||||
f_conf = "configure"
|
||||
f_conf_in = "configure.in"
|
||||
|
||||
def check_call_noisy(cmd, *args, **kwargs):
|
||||
print "Executing command:", cmd
|
||||
check_call(cmd, *args, **kwargs)
|
||||
|
||||
o = OptionParser(usage="client.py [options] remove_beta | set_beta | print_library_versions | set_version_to_minor_release | set_version_to_patch_release | create_nspr_release_archive")
|
||||
|
||||
try:
|
||||
options, args = o.parse_args()
|
||||
action = args[0]
|
||||
except IndexError:
|
||||
o.print_help()
|
||||
sys.exit(2)
|
||||
|
||||
def exit_with_failure(what):
|
||||
print "failure: ", what
|
||||
sys.exit(2)
|
||||
|
||||
def check_files_exist():
|
||||
if (not os.path.exists(prinit_h)):
|
||||
exit_with_failure("cannot find expected header files, must run from inside NSPR hg directory")
|
||||
|
||||
def sed_inplace(sed_expression, filename):
|
||||
backup_file = filename + '.tmp'
|
||||
check_call_noisy(["sed", "-i.tmp", sed_expression, filename])
|
||||
os.remove(backup_file)
|
||||
|
||||
def toggle_beta_status(is_beta):
|
||||
check_files_exist()
|
||||
if (is_beta):
|
||||
print "adding Beta status to version numbers"
|
||||
sed_inplace('s/^\(#define *PR_VERSION *\"[0-9.]\+\)\" *$/\\1 Beta\"/', prinit_h)
|
||||
sed_inplace('s/^\(#define *PR_BETA *\)PR_FALSE *$/\\1PR_TRUE/', prinit_h)
|
||||
|
||||
else:
|
||||
print "removing Beta status from version numbers"
|
||||
sed_inplace('s/^\(#define *PR_VERSION *\"[0-9.]\+\) *Beta\" *$/\\1\"/', prinit_h)
|
||||
sed_inplace('s/^\(#define *PR_BETA *\)PR_TRUE *$/\\1PR_FALSE/', prinit_h)
|
||||
print "please run 'hg stat' and 'hg diff' to verify the files have been verified correctly"
|
||||
|
||||
def print_beta_versions():
|
||||
check_call_noisy(["egrep", "#define *PR_VERSION|#define *PR_BETA", prinit_h])
|
||||
|
||||
def remove_beta_status():
|
||||
print "--- removing beta flags. Existing versions were:"
|
||||
print_beta_versions()
|
||||
toggle_beta_status(False)
|
||||
print "--- finished modifications, new versions are:"
|
||||
print_beta_versions()
|
||||
|
||||
def set_beta_status():
|
||||
print "--- adding beta flags. Existing versions were:"
|
||||
print_beta_versions()
|
||||
toggle_beta_status(True)
|
||||
print "--- finished modifications, new versions are:"
|
||||
print_beta_versions()
|
||||
|
||||
def print_library_versions():
|
||||
check_files_exist()
|
||||
check_call_noisy(["egrep", "#define *PR_VERSION|#define PR_VMAJOR|#define *PR_VMINOR|#define *PR_VPATCH|#define *PR_BETA", prinit_h])
|
||||
|
||||
def ensure_arguments_after_action(how_many, usage):
|
||||
if (len(sys.argv) != (2+how_many)):
|
||||
exit_with_failure("incorrect number of arguments, expected parameters are:\n" + usage)
|
||||
|
||||
def set_major_versions(major):
|
||||
sed_inplace('s/^\(#define *PR_VMAJOR *\).*$/\\1' + major + '/', prinit_h)
|
||||
sed_inplace('s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=' + major + '/', f_conf)
|
||||
sed_inplace('s/^MOD_MAJOR_VERSION=.*$/MOD_MAJOR_VERSION=' + major + '/', f_conf_in)
|
||||
|
||||
def set_minor_versions(minor):
|
||||
sed_inplace('s/^\(#define *PR_VMINOR *\).*$/\\1' + minor + '/', prinit_h)
|
||||
sed_inplace('s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=' + minor + '/', f_conf)
|
||||
sed_inplace('s/^MOD_MINOR_VERSION=.*$/MOD_MINOR_VERSION=' + minor + '/', f_conf_in)
|
||||
|
||||
def set_patch_versions(patch):
|
||||
sed_inplace('s/^\(#define *PR_VPATCH *\).*$/\\1' + patch + '/', prinit_h)
|
||||
sed_inplace('s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=' + patch + '/', f_conf)
|
||||
sed_inplace('s/^MOD_PATCH_VERSION=.*$/MOD_PATCH_VERSION=' + patch + '/', f_conf_in)
|
||||
|
||||
def set_full_lib_versions(version):
|
||||
sed_inplace('s/^\(#define *PR_VERSION *\"\)\([0-9.]\+\)\(.*\)$/\\1' + version + '\\3/', prinit_h)
|
||||
|
||||
def set_all_lib_versions(version, major, minor, patch):
|
||||
set_full_lib_versions(version)
|
||||
set_major_versions(major)
|
||||
set_minor_versions(minor)
|
||||
set_patch_versions(patch)
|
||||
print
|
||||
print "==========================="
|
||||
print "======== ATTENTION ========"
|
||||
print
|
||||
print "You *MUST* manually edit file pr/tests/vercheck.c"
|
||||
print
|
||||
print "Edit two arrays, named compatible_version and incompatible_version"
|
||||
print "according to the new version you're adding."
|
||||
print
|
||||
print "======== ATTENTION ========"
|
||||
print "==========================="
|
||||
|
||||
def set_version_to_minor_release():
|
||||
ensure_arguments_after_action(2, "major_version minor_version")
|
||||
major = args[1].strip()
|
||||
minor = args[2].strip()
|
||||
version = major + '.' + minor
|
||||
patch = "0"
|
||||
set_all_lib_versions(version, major, minor, patch)
|
||||
|
||||
def set_version_to_patch_release():
|
||||
ensure_arguments_after_action(3, "major_version minor_version patch_release")
|
||||
major = args[1].strip()
|
||||
minor = args[2].strip()
|
||||
patch = args[3].strip()
|
||||
version = major + '.' + minor + '.' + patch
|
||||
set_all_lib_versions(version, major, minor, patch)
|
||||
|
||||
def create_nspr_release_archive():
|
||||
ensure_arguments_after_action(2, "nspr_release_version nspr_hg_release_tag")
|
||||
nsprrel = args[1].strip() #e.g. 4.10.9
|
||||
nsprreltag = args[2].strip() #e.g. NSPR_4_10_9_RTM
|
||||
|
||||
nspr_tar = "nspr-" + nsprrel + ".tar.gz"
|
||||
nspr_stagedir="../stage/v" + nsprrel + "/src"
|
||||
if (os.path.exists(nspr_stagedir)):
|
||||
exit_with_failure("nspr stage directory already exists: " + nspr_stagedir)
|
||||
|
||||
check_call_noisy(["mkdir", "-p", nspr_stagedir])
|
||||
check_call_noisy(["hg", "archive", "-r", nsprreltag, "--prefix=nspr-" + nsprrel + "/nspr",
|
||||
"../stage/v" + nsprrel + "/src/" + nspr_tar, "-X", ".hgtags"])
|
||||
print "changing to directory " + nspr_stagedir
|
||||
os.chdir(nspr_stagedir)
|
||||
|
||||
check_call("sha1sum " + nspr_tar + " > SHA1SUMS", shell=True)
|
||||
check_call("sha256sum " + nspr_tar + " > SHA256SUMS", shell=True)
|
||||
print "created directory " + nspr_stagedir + " with files:"
|
||||
check_call_noisy(["ls", "-l"])
|
||||
|
||||
if action in ('remove_beta'):
|
||||
remove_beta_status()
|
||||
|
||||
elif action in ('set_beta'):
|
||||
set_beta_status()
|
||||
|
||||
elif action in ('print_library_versions'):
|
||||
print_library_versions()
|
||||
|
||||
# x.y version number - 2 parameters
|
||||
elif action in ('set_version_to_minor_release'):
|
||||
set_version_to_minor_release()
|
||||
|
||||
# x.y.z version number - 3 parameters
|
||||
elif action in ('set_version_to_patch_release'):
|
||||
set_version_to_patch_release()
|
||||
|
||||
elif action in ('create_nspr_release_archive'):
|
||||
create_nspr_release_archive()
|
||||
|
||||
else:
|
||||
o.print_help()
|
||||
sys.exit(2)
|
||||
|
||||
sys.exit(0)
|
|
@ -10,4 +10,3 @@
|
|||
*/
|
||||
|
||||
#error "Do not include this header file."
|
||||
|
||||
|
|
|
@ -2488,7 +2488,7 @@ test -n "$target_alias" &&
|
|||
program_prefix=${target_alias}-
|
||||
|
||||
MOD_MAJOR_VERSION=4
|
||||
MOD_MINOR_VERSION=12
|
||||
MOD_MINOR_VERSION=13
|
||||
MOD_PATCH_VERSION=0
|
||||
NSPR_MODNAME=nspr20
|
||||
_HAVE_PTHREADS=
|
||||
|
|
|
@ -15,7 +15,7 @@ dnl ========================================================
|
|||
dnl = Defaults
|
||||
dnl ========================================================
|
||||
MOD_MAJOR_VERSION=4
|
||||
MOD_MINOR_VERSION=12
|
||||
MOD_MINOR_VERSION=13
|
||||
MOD_PATCH_VERSION=0
|
||||
NSPR_MODNAME=nspr20
|
||||
_HAVE_PTHREADS=
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#include "prlock.h"
|
||||
#include "prinit.h"
|
||||
|
||||
static PLArena *arena_freelist;
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
static PLArenaStats *arena_stats_list;
|
||||
|
||||
|
@ -29,49 +27,6 @@ static PLArenaStats *arena_stats_list;
|
|||
|
||||
#define PL_ARENA_DEFAULT_ALIGN sizeof(double)
|
||||
|
||||
static PRLock *arenaLock;
|
||||
static PRCallOnceType once;
|
||||
static const PRCallOnceType pristineCallOnce;
|
||||
|
||||
/*
|
||||
** InitializeArenas() -- Initialize arena operations.
|
||||
**
|
||||
** InitializeArenas() is called exactly once and only once from
|
||||
** LockArena(). This function creates the arena protection
|
||||
** lock: arenaLock.
|
||||
**
|
||||
** Note: If the arenaLock cannot be created, InitializeArenas()
|
||||
** fails quietly, returning only PR_FAILURE. This percolates up
|
||||
** to the application using the Arena API. He gets no arena
|
||||
** from PL_ArenaAllocate(). It's up to him to fail gracefully
|
||||
** or recover.
|
||||
**
|
||||
*/
|
||||
static PRStatus InitializeArenas( void )
|
||||
{
|
||||
PR_ASSERT( arenaLock == NULL );
|
||||
arenaLock = PR_NewLock();
|
||||
if ( arenaLock == NULL )
|
||||
return PR_FAILURE;
|
||||
else
|
||||
return PR_SUCCESS;
|
||||
} /* end ArenaInitialize() */
|
||||
|
||||
static PRStatus LockArena( void )
|
||||
{
|
||||
PRStatus rc = PR_CallOnce( &once, InitializeArenas );
|
||||
|
||||
if ( PR_FAILURE != rc )
|
||||
PR_Lock( arenaLock );
|
||||
return(rc);
|
||||
} /* end LockArena() */
|
||||
|
||||
static void UnlockArena( void )
|
||||
{
|
||||
PR_Unlock( arenaLock );
|
||||
return;
|
||||
} /* end UnlockArena() */
|
||||
|
||||
PR_IMPLEMENT(void) PL_InitArenaPool(
|
||||
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align)
|
||||
{
|
||||
|
@ -124,14 +79,7 @@ PR_IMPLEMENT(void) PL_InitArenaPool(
|
|||
** pool.
|
||||
**
|
||||
** First, try to satisfy the request from arenas starting at
|
||||
** pool->current.
|
||||
**
|
||||
** If there is not enough space in the arena pool->current, try
|
||||
** to claim an arena, on a first fit basis, from the global
|
||||
** freelist (arena_freelist).
|
||||
**
|
||||
** If no arena in arena_freelist is suitable, then try to
|
||||
** allocate a new arena from the heap.
|
||||
** pool->current. Then try to allocate a new arena from the heap.
|
||||
**
|
||||
** Returns: pointer to allocated space or NULL
|
||||
**
|
||||
|
@ -169,37 +117,6 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
|
|||
} while( NULL != (a = a->next) );
|
||||
}
|
||||
|
||||
/* attempt to allocate from arena_freelist */
|
||||
{
|
||||
PLArena *p; /* previous pointer, for unlinking from freelist */
|
||||
|
||||
/* lock the arena_freelist. Make access to the freelist MT-Safe */
|
||||
if ( PR_FAILURE == LockArena())
|
||||
return(0);
|
||||
|
||||
for ( a = arena_freelist, p = NULL; a != NULL ; p = a, a = a->next ) {
|
||||
if ( nb <= a->limit - a->base ) {
|
||||
if ( p == NULL )
|
||||
arena_freelist = a->next;
|
||||
else
|
||||
p->next = a->next;
|
||||
UnlockArena();
|
||||
a->avail = a->base;
|
||||
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;
|
||||
return(rp);
|
||||
}
|
||||
}
|
||||
UnlockArena();
|
||||
}
|
||||
|
||||
/* attempt to allocate from the heap */
|
||||
{
|
||||
PRUint32 sz = PR_MAX(pool->arenasize, nb);
|
||||
|
@ -246,10 +163,11 @@ PR_IMPLEMENT(void *) PL_ArenaGrow(
|
|||
return newp;
|
||||
}
|
||||
|
||||
static void ClearArenaList(PLArena *a, PRInt32 pattern)
|
||||
PR_IMPLEMENT(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern)
|
||||
{
|
||||
PLArena *a;
|
||||
|
||||
for (; a; a = a->next) {
|
||||
for (a = pool->first.next; a; a = a->next) {
|
||||
PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);
|
||||
a->avail = a->base;
|
||||
PL_CLEAR_UNUSED_PATTERN(a, pattern);
|
||||
|
@ -257,48 +175,25 @@ static void ClearArenaList(PLArena *a, PRInt32 pattern)
|
|||
}
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern)
|
||||
{
|
||||
ClearArenaList(pool->first.next, pattern);
|
||||
}
|
||||
|
||||
/*
|
||||
* Free tail arenas linked after head, which may not be the true list head.
|
||||
* Reset pool->current to point to head in case it pointed at a tail arena.
|
||||
*/
|
||||
static void FreeArenaList(PLArenaPool *pool, PLArena *head, PRBool reallyFree)
|
||||
static void FreeArenaList(PLArenaPool *pool, PLArena *head)
|
||||
{
|
||||
PLArena **ap, *a;
|
||||
|
||||
ap = &head->next;
|
||||
a = *ap;
|
||||
PLArena *a = head->next;
|
||||
if (!a)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
ClearArenaList(a, PL_FREE_PATTERN);
|
||||
#endif
|
||||
head->next = NULL;
|
||||
|
||||
if (reallyFree) {
|
||||
do {
|
||||
*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();
|
||||
}
|
||||
do {
|
||||
PLArena *tmp = a;
|
||||
a = a->next;
|
||||
PL_CLEAR_ARENA(tmp);
|
||||
PL_COUNT_ARENA(pool,--);
|
||||
PR_DELETE(tmp);
|
||||
} while (a);
|
||||
|
||||
pool->current = head;
|
||||
}
|
||||
|
@ -310,7 +205,7 @@ PR_IMPLEMENT(void) PL_ArenaRelease(PLArenaPool *pool, char *mark)
|
|||
for (a = &pool->first; a; a = a->next) {
|
||||
if (PR_UPTRDIFF(mark, a->base) <= PR_UPTRDIFF(a->avail, a->base)) {
|
||||
a->avail = (PRUword)PL_ARENA_ALIGN(pool, mark);
|
||||
FreeArenaList(pool, a, PR_FALSE);
|
||||
FreeArenaList(pool, a);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -318,13 +213,13 @@ PR_IMPLEMENT(void) PL_ArenaRelease(PLArenaPool *pool, char *mark)
|
|||
|
||||
PR_IMPLEMENT(void) PL_FreeArenaPool(PLArenaPool *pool)
|
||||
{
|
||||
FreeArenaList(pool, &pool->first, PR_FALSE);
|
||||
FreeArenaList(pool, &pool->first);
|
||||
COUNT(pool, ndeallocs);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_FinishArenaPool(PLArenaPool *pool)
|
||||
{
|
||||
FreeArenaList(pool, &pool->first, PR_TRUE);
|
||||
FreeArenaList(pool, &pool->first);
|
||||
#ifdef PL_ARENAMETER
|
||||
{
|
||||
PLArenaStats *stats, **statsp;
|
||||
|
@ -348,19 +243,6 @@ PR_IMPLEMENT(void) PL_CompactArenaPool(PLArenaPool *ap)
|
|||
|
||||
PR_IMPLEMENT(void) PL_ArenaFinish(void)
|
||||
{
|
||||
PLArena *a, *next;
|
||||
|
||||
for (a = arena_freelist; a; a = next) {
|
||||
next = a->next;
|
||||
PR_DELETE(a);
|
||||
}
|
||||
arena_freelist = NULL;
|
||||
|
||||
if (arenaLock) {
|
||||
PR_DestroyLock(arenaLock);
|
||||
arenaLock = NULL;
|
||||
}
|
||||
once = pristineCallOnce;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(size_t) PL_SizeOfArenaPoolExcludingPool(
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
* Also supports LIFO allocation (PL_ARENA_MARK/PL_ARENA_RELEASE).
|
||||
*/
|
||||
#include "prtypes.h"
|
||||
#include "plarenas.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
|
@ -47,6 +46,8 @@ struct PLArenaStats {
|
|||
};
|
||||
#endif
|
||||
|
||||
typedef struct PLArenaPool PLArenaPool;
|
||||
|
||||
struct PLArenaPool {
|
||||
PLArena first; /* first arena in pool list */
|
||||
PLArena *current; /* arena from which to allocate space */
|
||||
|
@ -225,6 +226,74 @@ PR_IMPORT(void) __asan_unpoison_memory_region(void const volatile *addr, size_t
|
|||
(a) = 0; \
|
||||
PR_END_MACRO
|
||||
|
||||
/*
|
||||
** Initialize an arena pool with the given name for debugging and metering,
|
||||
** with a minimum gross size per arena of size bytes. The net size per arena
|
||||
** is smaller than the gross size by a header of four pointers plus any
|
||||
** necessary padding for alignment.
|
||||
**
|
||||
** Note: choose a gross size that's a power of two to avoid the heap allocator
|
||||
** rounding the size up.
|
||||
**/
|
||||
PR_EXTERN(void) PL_InitArenaPool(
|
||||
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align);
|
||||
|
||||
/*
|
||||
** Finish using arenas, freeing all memory associated with them.
|
||||
** NOTE: this function is now a no-op. If you want to free a single
|
||||
** PLArenaPoolUse use PL_FreeArenaPool() or PL_FinishArenaPool().
|
||||
**/
|
||||
PR_EXTERN(void) PL_ArenaFinish(void);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool. The user may continue to allocate from pool
|
||||
** after calling this function. There is no need to call PL_InitArenaPool()
|
||||
** again unless PL_FinishArenaPool(pool) has been called.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool and finish using it altogether.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Compact all of the arenas in a pool so that no space is wasted.
|
||||
** NOT IMPLEMENTED. Do not use.
|
||||
**/
|
||||
PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Friend functions used by the PL_ARENA_*() macros.
|
||||
**
|
||||
** WARNING: do not call these functions directly. Always use the
|
||||
** PL_ARENA_*() macros.
|
||||
**/
|
||||
PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);
|
||||
|
||||
PR_EXTERN(void *) PL_ArenaGrow(
|
||||
PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
|
||||
|
||||
/*
|
||||
** memset contents of all arenas in pool to pattern
|
||||
*/
|
||||
PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern);
|
||||
|
||||
/*
|
||||
** A function like malloc_size() or malloc_usable_size() that measures the
|
||||
** size of a heap block.
|
||||
*/
|
||||
typedef size_t (*PLMallocSizeFn)(const void *ptr);
|
||||
|
||||
/*
|
||||
** Measure all memory used by a PLArenaPool, excluding the PLArenaPool
|
||||
** structure.
|
||||
*/
|
||||
PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool(
|
||||
const PLArenaPool *pool, PLMallocSizeFn mallocSizeOf);
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -3,79 +3,10 @@
|
|||
* 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/. */
|
||||
|
||||
#ifndef PLARENAS_H
|
||||
#define PLARENAS_H
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct PLArenaPool PLArenaPool;
|
||||
|
||||
/*
|
||||
** Initialize an arena pool with the given name for debugging and metering,
|
||||
** with a minimum gross size per arena of size bytes. The net size per arena
|
||||
** is smaller than the gross size by a header of four pointers plus any
|
||||
** necessary padding for alignment.
|
||||
**
|
||||
** Note: choose a gross size that's a power of two to avoid the heap allocator
|
||||
** rounding the size up.
|
||||
** PLArena-related declarations used to be split between plarenas.h and
|
||||
** plarena.h. That split wasn't useful, so now all the declarations are in
|
||||
** plarena.h. However, this file still exists so that any old code that
|
||||
** includes it will still work.
|
||||
**/
|
||||
PR_EXTERN(void) PL_InitArenaPool(
|
||||
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align);
|
||||
|
||||
/*
|
||||
** Finish using arenas, freeing all memory associated with them.
|
||||
**/
|
||||
PR_EXTERN(void) PL_ArenaFinish(void);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool. The user may continue to allocate from pool
|
||||
** after calling this function. There is no need to call PL_InitArenaPool()
|
||||
** again unless PL_FinishArenaPool(pool) has been called.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool and finish using it altogether.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Compact all of the arenas in a pool so that no space is wasted.
|
||||
** NOT IMPLEMENTED. Do not use.
|
||||
**/
|
||||
PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Friend functions used by the PL_ARENA_*() macros.
|
||||
**
|
||||
** WARNING: do not call these functions directly. Always use the
|
||||
** PL_ARENA_*() macros.
|
||||
**/
|
||||
PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);
|
||||
|
||||
PR_EXTERN(void *) PL_ArenaGrow(
|
||||
PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
|
||||
|
||||
/*
|
||||
** memset contents of all arenas in pool to pattern
|
||||
*/
|
||||
PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern);
|
||||
|
||||
/*
|
||||
** A function like malloc_size() or malloc_usable_size() that measures the
|
||||
** size of a heap block.
|
||||
*/
|
||||
typedef size_t (*PLMallocSizeFn)(const void *ptr);
|
||||
|
||||
/*
|
||||
** Measure all memory used by a PLArenaPool, excluding the PLArenaPool
|
||||
** structure.
|
||||
*/
|
||||
PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool(
|
||||
const PLArenaPool *pool, PLMallocSizeFn mallocSizeOf);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* PLARENAS_H */
|
||||
#include "plarena.h"
|
||||
|
|
|
@ -48,8 +48,10 @@ PL_strcasecmp(const char *a, const char *b)
|
|||
const unsigned char *ua = (const unsigned char *)a;
|
||||
const unsigned char *ub = (const unsigned char *)b;
|
||||
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
while( (uc[*ua] == uc[*ub]) && ('\0' != *a) )
|
||||
{
|
||||
|
@ -67,8 +69,10 @@ PL_strncasecmp(const char *a, const char *b, PRUint32 max)
|
|||
const unsigned char *ua = (const unsigned char *)a;
|
||||
const unsigned char *ub = (const unsigned char *)b;
|
||||
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
while( max && (uc[*ua] == uc[*ub]) && ('\0' != *a) )
|
||||
{
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strcmp(const char *a, const char *b)
|
||||
{
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
return (PRIntn)strcmp(a, b);
|
||||
}
|
||||
|
@ -18,8 +20,10 @@ PL_strcmp(const char *a, const char *b)
|
|||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strncmp(const char *a, const char *b, PRUint32 max)
|
||||
{
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
return (PRIntn)strncmp(a, b, (size_t)max);
|
||||
}
|
||||
|
|
|
@ -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.12"
|
||||
#define PR_VERSION "4.13 Beta"
|
||||
#define PR_VMAJOR 4
|
||||
#define PR_VMINOR 12
|
||||
#define PR_VMINOR 13
|
||||
#define PR_VPATCH 0
|
||||
#define PR_BETA PR_FALSE
|
||||
#define PR_BETA PR_TRUE
|
||||
|
||||
/*
|
||||
** PRVersionCheck
|
||||
|
|
|
@ -196,8 +196,8 @@ typedef enum PRSockOption
|
|||
PR_SockOpt_Linger, /* linger on close if data present */
|
||||
PR_SockOpt_Reuseaddr, /* allow local address reuse */
|
||||
PR_SockOpt_Keepalive, /* keep connections alive */
|
||||
PR_SockOpt_RecvBufferSize, /* send buffer size */
|
||||
PR_SockOpt_SendBufferSize, /* receive buffer size */
|
||||
PR_SockOpt_RecvBufferSize, /* receive buffer size */
|
||||
PR_SockOpt_SendBufferSize, /* send buffer size */
|
||||
|
||||
PR_SockOpt_IpTimeToLive, /* time to live */
|
||||
PR_SockOpt_IpTypeOfService, /* type of service and precedence */
|
||||
|
|
|
@ -11,21 +11,21 @@
|
|||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
** A locking mechanism, built on the existing PRLock definiion,
|
||||
** A locking mechanism, built on the existing PRLock definition,
|
||||
** is provided that will permit applications to define a Lock
|
||||
** Hierarchy (or Lock Ordering) schema. An application designed
|
||||
** using the Ordered Lock functions will terminate with a
|
||||
** diagnostic message when a lock inversion condition is
|
||||
** detected.
|
||||
**
|
||||
** The lock ordering detection is complile-time enabled only. in
|
||||
** The lock ordering detection is compile-time enabled only. In
|
||||
** optimized builds of NSPR, the Ordered Lock functions map
|
||||
** directly to PRLock functions, providing no lock order
|
||||
** detection.
|
||||
**
|
||||
** The Ordered Lock Facility is compiled in when DEBUG is defined at
|
||||
** compile time. Ordered Lock can be forced on in optimized builds by
|
||||
** defining FORCE_NSPR_ORDERED_LOCK at compile time. Both the
|
||||
** compile-time. Ordered Lock can be forced on in optimized builds by
|
||||
** defining FORCE_NSPR_ORDERED_LOCK at compile-time. Both the
|
||||
** application using Ordered Lock and NSPR must be compiled with the
|
||||
** facility enabled to achieve the desired results.
|
||||
**
|
||||
|
|
|
@ -461,7 +461,7 @@ static struct NumArg* BuildArgArray( const char *fmt, va_list ap, int* rv, struc
|
|||
if( c == '%' ) continue;
|
||||
|
||||
cn = 0;
|
||||
while( c && c != '$' ){ /* should imporve error check later */
|
||||
while( c && c != '$' ){ /* should improve error check later */
|
||||
cn = cn*10 + c - '0';
|
||||
c = *p++;
|
||||
}
|
||||
|
@ -745,7 +745,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
|
|||
if( nas != NULL ){
|
||||
/* the fmt contains the Numbered Arguments feature */
|
||||
i = 0;
|
||||
while( c && c != '$' ){ /* should imporve error check later */
|
||||
while( c && c != '$' ){ /* should improve error check later */
|
||||
i = ( i * 10 ) + ( c - '0' );
|
||||
c = *fmt++;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
#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 );
|
||||
static PRInt64 ll_zero = PR_INT64(0x0000000000000000);
|
||||
static PRInt64 ll_maxint = PR_INT64(0x7fffffffffffffff);
|
||||
static PRInt64 ll_minint = PR_INT64(0x8000000000000000);
|
||||
static PRUint64 ll_maxuint = PR_UINT64(0xffffffffffffffff);
|
||||
|
||||
PR_IMPLEMENT(PRInt64) LL_Zero(void) { return ll_zero; }
|
||||
PR_IMPLEMENT(PRInt64) LL_MaxInt(void) { return ll_maxint; }
|
||||
|
|
|
@ -43,8 +43,8 @@ int main(int argc, char **argv)
|
|||
"PR_SockOpt_Linger", /* linger on close if data present */
|
||||
"PR_SockOpt_Reuseaddr", /* allow local address reuse */
|
||||
"PR_SockOpt_Keepalive", /* keep connections alive */
|
||||
"PR_SockOpt_RecvBufferSize", /* send buffer size */
|
||||
"PR_SockOpt_SendBufferSize", /* receive buffer size */
|
||||
"PR_SockOpt_RecvBufferSize", /* receive buffer size */
|
||||
"PR_SockOpt_SendBufferSize", /* send buffer size */
|
||||
|
||||
"PR_SockOpt_IpTimeToLive", /* time to live */
|
||||
"PR_SockOpt_IpTypeOfService", /* type of service and precedence */
|
||||
|
|
|
@ -39,7 +39,7 @@ static char *compatible_version[] = {
|
|||
"4.9.6",
|
||||
"4.10", "4.10.1", "4.10.2", "4.10.3", "4.10.4",
|
||||
"4.10.5", "4.10.6", "4.10.7", "4.10.8", "4.10.9",
|
||||
"4.10.10", "4.11",
|
||||
"4.10.10", "4.11", "4.12",
|
||||
PR_VERSION
|
||||
};
|
||||
|
||||
|
@ -55,8 +55,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.11.1",
|
||||
"4.12.1",
|
||||
"4.13.1",
|
||||
"4.14", "4.14.1",
|
||||
"10.0", "11.1", "12.14.20"
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче