update nspr to NSPR_HEAD_20100330 to pick up support for android r=ted

--HG--
extra : rebase_source : 90577e9e3385b0d866e4860e0c6c89bfe382881e
This commit is contained in:
Brad Lassey 2010-03-30 15:23:44 -04:00
parent f5937dc35c
commit 43da54b9c6
20 changed files with 583 additions and 244 deletions

View file

@ -37,6 +37,8 @@ LIBPLC = @LIBPLC@
CROSS_COMPILE = @CROSS_COMPILE@ CROSS_COMPILE = @CROSS_COMPILE@
BUILD_OPT = @MOZ_OPTIMIZE@ BUILD_OPT = @MOZ_OPTIMIZE@
MOZ_DEBUG = @MOZ_DEBUG@
MOZ_DEBUG_SYMBOLS = @MOZ_DEBUG_SYMBOLS@
USE_CPLUS = @USE_CPLUS@ USE_CPLUS = @USE_CPLUS@
USE_IPV6 = @USE_IPV6@ USE_IPV6 = @USE_IPV6@

View file

@ -141,7 +141,7 @@ endif
ifndef TARGETS ifndef TARGETS
ifeq (,$(filter-out WINNT WINCE OS2,$(OS_ARCH))) ifeq (,$(filter-out WINNT WINCE OS2,$(OS_ARCH)))
TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
ifndef BUILD_OPT ifdef MOZ_DEBUG_SYMBOLS
ifdef MSC_VER ifdef MSC_VER
ifneq (,$(filter-out 1100 1200,$(MSC_VER))) ifneq (,$(filter-out 1100 1200,$(MSC_VER)))
TARGETS += $(SHARED_LIB_PDB) TARGETS += $(SHARED_LIB_PDB)

377
nsprpub/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -127,6 +127,71 @@ if test -n "$_WIN32_MSVC"; then
SKIP_LIBRARY_CHECKS=1 SKIP_LIBRARY_CHECKS=1
fi fi
dnl ========================================================
dnl = Android uses a very custom (hacky) toolchain; we need to do this
dnl = here, so that the compiler checks can succeed
dnl ========================================================
AC_ARG_WITH(android-ndk,
[ --with-android-ndk=DIR
location where the Android NDK can be found],
android_ndk=$withval)
AC_ARG_WITH(android-toolchain,
[ --with-android-toolchain=DIR
location of the android toolchain, default NDK/build/prebuilt/HOST/arm-eabi-4.4.0],
android_toolchain=$withval)
AC_ARG_WITH(android-platform,
[ --with-android-platform=DIR
location of platform dir, default NDK/build/platforms/android-5/arch-arm],
android_platform=$withval)
if test "$target" = "arm-android-eabi" ; then
if test -z "$android_ndk" ; then
AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
fi
if test -z "$android_toolchain" ; then
android_toolchain="$android_ndk"/build/prebuilt/`uname -s | tr "[[:upper:]]" "[[:lower:]]"`-x86/arm-eabi-4.4.0
fi
if test -z "$android_platform" ; then
android_platform="$android_ndk"/build/platforms/android-5/arch-arm
fi
dnl set up compilers
AS="$android_toolchain"/bin/arm-eabi-as
CC="$android_toolchain"/bin/arm-eabi-gcc
CXX="$android_toolchain"/bin/arm-eabi-g++
CPP="$android_toolchain"/bin/arm-eabi-cpp
LD="$android_toolchain"/bin/arm-eabi-ld
AR="$android_toolchain"/bin/arm-eabi-ar
RANLIB="$android_toolchain"/bin/arm-eabi-ranlib
STRIP="$android_toolchain"/bin/arm-eabi-strip
CPPFLAGS="-I$android_platform/usr/include $CPPFLAGS"
CFLAGS="-mandroid -I$android_platform/usr/include -msoft-float -fno-short-enums -fno-exceptions -march=armv5te -mthumb-interwork $CFLAGS"
CXXFLAGS="-mandroid -I$android_platform/usr/include -msoft-float -fpic -fno-short-enums -fno-exceptions -march=armv5te -mthumb-interwork -mthumb $CXXFLAGS"
LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform $LDFLAGS"
dnl prevent cross compile section from using these flags as host flags
if test -z "$HOST_CPPFLAGS" ; then
HOST_CPPFLAGS=" "
fi
if test -z "$HOST_CFLAGS" ; then
HOST_CFLAGS=" "
fi
if test -z "$HOST_CXXFLAGS" ; then
HOST_CXXFLAGS=" "
fi
if test -z "$HOST_LDFLAGS" ; then
HOST_LDFLAGS=" "
fi
AC_DEFINE(ANDROID)
fi
dnl ======================================================== dnl ========================================================
dnl = dnl =
dnl = Check options that may affect the compiler dnl = Check options that may affect the compiler
@ -181,10 +246,10 @@ AC_ARG_WITH(mozilla,
fi]) fi])
AC_ARG_ENABLE(optimize, AC_ARG_ENABLE(optimize,
[ --enable-optimize(=val) Enable code optimizations (val, ie. -O2) ], [ --enable-optimize[=OPT] Enable code optimizations (ie. -O2) ],
[ if test "$enableval" != "no"; then [ if test "$enableval" != "no"; then
MOZ_OPTIMIZE=1 MOZ_OPTIMIZE=1
if test -n "$enableval" && test "$enableval" != "yes"; then if test -n "$enableval" -a "$enableval" != "yes"; then
_OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'` _OPTIMIZE_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
_SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS _SAVE_OPTIMIZE_FLAGS=$_OPTIMIZE_FLAGS
fi fi
@ -193,17 +258,33 @@ AC_ARG_ENABLE(optimize,
fi ]) fi ])
AC_ARG_ENABLE(debug, AC_ARG_ENABLE(debug,
[ --disable-debug Do not compile in debugging symbols [ --enable-debug[=DBG] Enable debugging (using compiler flags DBG)],
--enable-debug(=val) Enable debugging (debug flags val)], [ if test "$enableval" != "no"; then
[ if test "$enableval" = "no"; then
MOZ_DEBUG=
else
MOZ_DEBUG=1 MOZ_DEBUG=1
if test -n "$enableval" && test "$enableval" != "yes"; then MOZ_DEBUG_SYMBOLS=1
if test -n "$enableval" -a "$enableval" != "yes"; then
_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'` _DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
_SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS _SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
fi fi
fi]) else
MOZ_DEBUG=
fi ],
MOZ_DEBUG=)
AC_ARG_ENABLE(debug-symbols,
[ --enable-debug-symbols[=DBG] Enable debugging symbols
(using compiler flags DBG)],
[ if test "$enableval" != "no"; then
MOZ_DEBUG_SYMBOLS=1
if test -n "$enableval" -a "$enableval" != "yes"; then
if test -z "$_SAVE_DEBUG_FLAGS"; then
_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
_SAVE_DEBUG_FLAGS=$_DEBUG_FLAGS
else
AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
fi
fi
fi ])
AC_ARG_ENABLE(win32-target, AC_ARG_ENABLE(win32-target,
[ --enable-win32-target=\$t [ --enable-win32-target=\$t
@ -1412,6 +1493,33 @@ tools are selected during the Xcode/Developer Tools installation.])
esac esac
;; ;;
arm-android-eabi)
if test -z "$USE_NSPR_THREADS"; then
USE_PTHREADS=1
IMPL_STRATEGY=_PTH
fi
AC_DEFINE(XP_UNIX)
AC_DEFINE(_GNU_SOURCE)
AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
AC_DEFINE(LINUX)
CFLAGS="$CFLAGS -Wall"
CXXFLAGS="$CXXFLAGS -Wall"
MDCPUCFG_H=_linux.cfg
PR_MD_CSRCS=linux.c
MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
DSO_CFLAGS=-fPIC
DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
_OPTIMIZE_FLAGS=-O2
_DEBUG_FLAGS="-g -fno-inline" # most people on linux use gcc/gdb, and that
# combo is not yet good at debugging inlined
# functions (even when using DWARF2 as the
# debugging format)
COMPILER_TAG=_glibc
CPU_ARCH=arm
CPU_ARCH_TAG=_arm
OS_TARGET=Android
;;
*-linux*|*-gnu*|*-k*bsd*-gnu) *-linux*|*-gnu*|*-k*bsd*-gnu)
if test -z "$USE_NSPR_THREADS"; then if test -z "$USE_NSPR_THREADS"; then
USE_PTHREADS=1 USE_PTHREADS=1
@ -1542,7 +1650,7 @@ tools are selected during the Xcode/Developer Tools installation.])
CFLAGS="$CFLAGS -W3 -nologo -GF -Gy" CFLAGS="$CFLAGS -W3 -nologo -GF -Gy"
DLLFLAGS="$DLLFLAGS -OUT:\"\$@\"" DLLFLAGS="$DLLFLAGS -OUT:\"\$@\""
_DEBUG_FLAGS=-Z7 _DEBUG_FLAGS=-Zi
_OPTIMIZE_FLAGS=-O2 _OPTIMIZE_FLAGS=-O2
if test -z "$MOZ_OPTIMIZE"; then if test -z "$MOZ_OPTIMIZE"; then
CFLAGS="$CFLAGS -Od" CFLAGS="$CFLAGS -Od"
@ -1560,18 +1668,15 @@ tools are selected during the Xcode/Developer Tools installation.])
DEFINES="$DEFINES -U_DEBUG" DEFINES="$DEFINES -U_DEBUG"
fi fi
if test -n "$MOZ_OPTIMIZE"; then
if test -n "$MOZ_DEBUG_SYMBOLS"; then if test -n "$MOZ_DEBUG_SYMBOLS"; then
_OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Zi" if test -n "$MOZ_OPTIMIZE"; then
DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF" DLLFLAGS="$DLLFLAGS -DEBUG -OPT:REF"
LDFLAGS="$LDFLAGS -DEBUG -OPT:REF" LDFLAGS="$LDFLAGS -DEBUG -OPT:REF"
fi else
fi
if test -n "$MOZ_DEBUG"; then
DLLFLAGS="$DLLFLAGS -DEBUG" DLLFLAGS="$DLLFLAGS -DEBUG"
LDFLAGS="$LDFLAGS -DEBUG" LDFLAGS="$LDFLAGS -DEBUG"
fi fi
fi
OS_DLLFLAGS="-nologo -DLL -SUBSYSTEM:WINDOWS" OS_DLLFLAGS="-nologo -DLL -SUBSYSTEM:WINDOWS"
if test "$MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then if test "$MSC_VER" -le "1200" -a -z "$MOZ_DEBUG_SYMBOLS"; then
@ -1666,7 +1771,7 @@ tools are selected during the Xcode/Developer Tools installation.])
LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)' LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
DLLFLAGS='-OUT:"$@"' DLLFLAGS='-OUT:"$@"'
if test -n "$MOZ_DEBUG_SYMBOLS" || test -n "$MOZ_DEBUG"; then if test -n "$MOZ_DEBUG_SYMBOLS"; then
OS_LDFLAGS='-DEBUG -DEBUGTYPE:CV' OS_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
OS_DLLFLAGS='-DEBUG -DEBUGTYPE:CV' OS_DLLFLAGS='-DEBUG -DEBUGTYPE:CV'
DSO_LDOPTS='-DEBUG -DEBUGTYPE:CV' DSO_LDOPTS='-DEBUG -DEBUGTYPE:CV'
@ -2726,7 +2831,7 @@ if test -n "$MOZ_OPTIMIZE"; then
CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS" CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS"
fi fi
if test -n "$MOZ_DEBUG_SYMBOLS" || test -n "$MOZ_DEBUG"; then if test -n "$MOZ_DEBUG_SYMBOLS"; then
CFLAGS="$CFLAGS $_DEBUG_FLAGS" CFLAGS="$CFLAGS $_DEBUG_FLAGS"
CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS" CXXFLAGS="$CXXFLAGS $_DEBUG_FLAGS"
fi fi
@ -2775,6 +2880,8 @@ AC_SUBST(MSC_VER)
AC_SUBST(CROSS_COMPILE) AC_SUBST(CROSS_COMPILE)
AC_SUBST(MOZ_OPTIMIZE) AC_SUBST(MOZ_OPTIMIZE)
AC_SUBST(MOZ_DEBUG)
AC_SUBST(MOZ_DEBUG_SYMBOLS)
AC_SUBST(USE_CPLUS) AC_SUBST(USE_CPLUS)
AC_SUBST(USE_IPV6) AC_SUBST(USE_IPV6)

View file

@ -256,6 +256,21 @@ PR_IMPLEMENT(void *) PL_ArenaGrow(
return newp; return newp;
} }
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);
}
}
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. * 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. * Reset pool->current to point to head in case it pointed at a tail arena.
@ -270,12 +285,7 @@ static void FreeArenaList(PLArenaPool *pool, PLArena *head, PRBool reallyFree)
return; return;
#ifdef DEBUG #ifdef DEBUG
do { ClearArenaList(a, PL_FREE_PATTERN);
PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);
a->avail = a->base;
PL_CLEAR_UNUSED(a);
} while ((a = a->next) != 0);
a = *ap;
#endif #endif
if (reallyFree) { if (reallyFree) {

View file

@ -138,11 +138,12 @@ struct PLArenaPool {
#define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail) #define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail)
#define PR_UPTRDIFF(p,q) ((PRUword)(p) - (PRUword)(q)) #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))
#ifdef DEBUG #ifdef DEBUG
#define PL_FREE_PATTERN 0xDA #define PL_FREE_PATTERN 0xDA
#define PL_CLEAR_UNUSED(a) (PR_ASSERT((a)->avail <= (a)->limit), \ #define PL_CLEAR_UNUSED(a) PL_CLEAR_UNUSED_PATTERN((a), PL_FREE_PATTERN)
memset((void*)(a)->avail, PL_FREE_PATTERN, \
(a)->limit - (a)->avail))
#define PL_CLEAR_ARENA(a) memset((void*)(a), PL_FREE_PATTERN, \ #define PL_CLEAR_ARENA(a) memset((void*)(a), PL_FREE_PATTERN, \
(a)->limit - (PRUword)(a)) (a)->limit - (PRUword)(a))
#else #else

View file

@ -108,6 +108,11 @@ PR_EXTERN(void *) PL_ArenaGrow(
PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark); 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);
PR_END_EXTERN_C PR_END_EXTERN_C
#endif /* defined(PLARENAS_H) */ #endif /* defined(PLARENAS_H) */

View file

@ -81,3 +81,8 @@ libVersionPoint;
PL_HashTableLookupConst; PL_HashTableLookupConst;
PL_HashTableRawLookupConst; PL_HashTableRawLookupConst;
;+} NSPR_4.0; ;+} NSPR_4.0;
;+
;+NSPR_4.8.5 {
;+ global:
PL_ClearArenaPool;
;+} NSPR_4.1;

View file

@ -100,6 +100,9 @@
*/ */
#define HAVE_DLL #define HAVE_DLL
#define USE_DLFCN #define USE_DLFCN
#if defined(ANDROID)
#define NO_DLOPEN_NULL
#endif
#ifdef __FreeBSD_kernel__ #ifdef __FreeBSD_kernel__
#define _PR_HAVE_SOCKADDR_LEN #define _PR_HAVE_SOCKADDR_LEN
@ -277,8 +280,10 @@ static inline PRInt32 _MD_ATOMIC_SET(PRInt32 *ptr, PRInt32 nv)
#define _PR_HAVE_GETADDRINFO #define _PR_HAVE_GETADDRINFO
#define _PR_INET6_PROBE #define _PR_INET6_PROBE
#endif #endif
#ifndef ANDROID
#define _PR_HAVE_SYSV_SEMAPHORES #define _PR_HAVE_SYSV_SEMAPHORES
#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
#endif
#if (__GLIBC__ >= 2) && defined(_PR_PTHREADS) #if (__GLIBC__ >= 2) && defined(_PR_PTHREADS)
#define _PR_HAVE_GETHOST_R #define _PR_HAVE_GETHOST_R
#define _PR_HAVE_GETHOST_R_INT #define _PR_HAVE_GETHOST_R_INT

View file

@ -41,6 +41,33 @@
#include "prtypes.h" #include "prtypes.h"
PR_BEGIN_EXTERN_C 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))
unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask);
unsigned char _BitScanReverse(unsigned long * Index, unsigned long Mask);
# pragma intrinsic(_BitScanForward,_BitScanReverse)
__forceinline static int __prBitScanForward32(unsigned int val)
{
unsigned long idx;
_BitScanForward(&idx, (unsigned long)val);
return( (int)idx );
}
__forceinline static int __prBitScanReverse32(unsigned int val)
{
unsigned long idx;
_BitScanReverse(&idx, (unsigned long)val);
return( (int)(31-idx) );
}
# define pr_bitscan_ctz32(val) __prBitScanForward32(val)
# define pr_bitscan_clz32(val) __prBitScanReverse32(val)
# define PR_HAVE_BUILTIN_BITSCAN32
#elif ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && \
(defined(__i386__) || defined(__x86_64__))
# define pr_bitscan_ctz32(val) __builtin_ctz(val)
# define pr_bitscan_clz32(val) __builtin_clz(val)
# define PR_HAVE_BUILTIN_BITSCAN32
#endif /* MSVC || GCC */
/* /*
** A prbitmap_t is a long integer that can be used for bitmaps ** A prbitmap_t is a long integer that can be used for bitmaps
*/ */
@ -67,6 +94,13 @@ NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i);
** Macro version of PR_CeilingLog2: Compute the log of the least power of ** Macro version of PR_CeilingLog2: Compute the log of the least power of
** 2 greater than or equal to _n. The result is returned in _log2. ** 2 greater than or equal to _n. The result is returned in _log2.
*/ */
#ifdef PR_HAVE_BUILTIN_BITSCAN32
#define PR_CEILING_LOG2(_log2,_n) \
PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \
(_log2) = (j_ <= 1 ? 0 : 32 - pr_bitscan_clz32(j_ - 1)); \
PR_END_MACRO
#else
#define PR_CEILING_LOG2(_log2,_n) \ #define PR_CEILING_LOG2(_log2,_n) \
PR_BEGIN_MACRO \ PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \ PRUint32 j_ = (PRUint32)(_n); \
@ -84,6 +118,7 @@ NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i);
if ((j_) >> 1) \ if ((j_) >> 1) \
(_log2) += 1; \ (_log2) += 1; \
PR_END_MACRO PR_END_MACRO
#endif /* PR_HAVE_BUILTIN_BITSCAN32 */
/* /*
** Macro version of PR_FloorLog2: Compute the log of the greatest power of ** Macro version of PR_FloorLog2: Compute the log of the greatest power of
@ -91,6 +126,13 @@ NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i);
** **
** This is equivalent to finding the highest set bit in the word. ** This is equivalent to finding the highest set bit in the word.
*/ */
#ifdef PR_HAVE_BUILTIN_BITSCAN32
#define PR_FLOOR_LOG2(_log2,_n) \
PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \
(_log2) = 31 - pr_bitscan_clz32((j_) | 1); \
PR_END_MACRO
#else
#define PR_FLOOR_LOG2(_log2,_n) \ #define PR_FLOOR_LOG2(_log2,_n) \
PR_BEGIN_MACRO \ PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \ PRUint32 j_ = (PRUint32)(_n); \
@ -106,6 +148,7 @@ NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i);
if ((j_) >> 1) \ if ((j_) >> 1) \
(_log2) += 1; \ (_log2) += 1; \
PR_END_MACRO PR_END_MACRO
#endif /* PR_HAVE_BUILTIN_BITSCAN32 */
/* /*
** Macros for rotate left and right. The argument 'a' must be an unsigned ** Macros for rotate left and right. The argument 'a' must be an unsigned

View file

@ -248,14 +248,6 @@ NSPR_API(void) PR_Assert(const char *s, const char *file, PRIntn ln);
#endif /* defined(DEBUG) || defined(FORCE_PR_ASSERT) */ #endif /* defined(DEBUG) || defined(FORCE_PR_ASSERT) */
/*
** Compile-time assert. "condition" must be a constant expression.
** The macro can be used only in places where an "extern" declaration is
** allowed.
*/
#define PR_STATIC_ASSERT(condition) \
extern void pr_static_assert(int arg[(condition) ? 1 : -1])
PR_END_EXTERN_C PR_END_EXTERN_C
#endif /* prlog_h___ */ #endif /* prlog_h___ */

View file

@ -519,6 +519,14 @@ typedef unsigned long PRUword;
/********* ????????????? End Fix me ?????????????????????????????? *****/ /********* ????????????? End Fix me ?????????????????????????????? *****/
#endif /* NO_NSPR_10_SUPPORT */ #endif /* NO_NSPR_10_SUPPORT */
/*
** Compile-time assert. "condition" must be a constant expression.
** The macro can be used only in places where an "extern" declaration is
** allowed.
*/
#define PR_STATIC_ASSERT(condition) \
extern void pr_static_assert(int arg[(condition) ? 1 : -1])
PR_END_EXTERN_C PR_END_EXTERN_C
#endif /* prtypes_h___ */ #endif /* prtypes_h___ */

View file

@ -198,7 +198,7 @@ void _PR_InitLinker(void)
#elif defined(XP_UNIX) #elif defined(XP_UNIX)
#ifdef HAVE_DLL #ifdef HAVE_DLL
#ifdef USE_DLFCN #if defined(USE_DLFCN) && !defined(NO_DLOPEN_NULL)
h = dlopen(0, RTLD_LAZY); h = dlopen(0, RTLD_LAZY);
if (!h) { if (!h) {
char *error; char *error;
@ -214,8 +214,8 @@ void _PR_InitLinker(void)
#elif defined(USE_HPSHL) #elif defined(USE_HPSHL)
h = NULL; h = NULL;
/* don't abort with this NULL */ /* don't abort with this NULL */
#elif defined(USE_MACH_DYLD) #elif defined(USE_MACH_DYLD) || defined(NO_DLOPEN_NULL)
h = NULL; /* XXXX toshok */ h = NULL; /* XXXX toshok */ /* XXXX vlad */
#else #else
#error no dll strategy #error no dll strategy
#endif /* USE_DLFCN */ #endif /* USE_DLFCN */
@ -1354,7 +1354,7 @@ PR_LoadStaticLibrary(const char *name, const PRStaticLinkTable *slt)
PR_IMPLEMENT(char *) PR_IMPLEMENT(char *)
PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr) PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr)
{ {
#if defined(USE_DLFCN) && (defined(SOLARIS) || defined(FREEBSD) \ #if defined(USE_DLFCN) && !defined(ANDROID) && (defined(SOLARIS) || defined(FREEBSD) \
|| defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \ || defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
|| defined(DARWIN)) || defined(DARWIN))
Dl_info dli; Dl_info dli;

View file

@ -117,7 +117,7 @@ _PR_DestroyZones(void)
#ifdef HAVE_DLL #ifdef HAVE_DLL
#ifdef USE_DLFCN #if defined(USE_DLFCN) && !defined(NO_DLOPEN_NULL)
#include <dlfcn.h> #include <dlfcn.h>
@ -150,7 +150,7 @@ pr_FindSymbolInProg(const char *name)
return sym; return sym;
} }
#elif defined(USE_MACH_DYLD) #elif defined(USE_MACH_DYLD) || defined(NO_DLOPEN_NULL)
static void * static void *
pr_FindSymbolInProg(const char *name) pr_FindSymbolInProg(const char *name)

View file

@ -46,6 +46,7 @@
#endif #endif
#include "primpl.h" #include "primpl.h"
#include "prbit.h"
#define MULTIPLE_THREADS #define MULTIPLE_THREADS
#define ACQUIRE_DTOA_LOCK(n) PR_Lock(dtoa_lock[n]) #define ACQUIRE_DTOA_LOCK(n) PR_Lock(dtoa_lock[n])
@ -742,6 +743,9 @@ hi0bits
(register ULong x) (register ULong x)
#endif #endif
{ {
#ifdef PR_HAVE_BUILTIN_BITSCAN32
return( (!x) ? 32 : pr_bitscan_clz32(x) );
#else
register int k = 0; register int k = 0;
if (!(x & 0xffff0000)) { if (!(x & 0xffff0000)) {
@ -766,6 +770,7 @@ hi0bits
return 32; return 32;
} }
return k; return k;
#endif /* PR_HAVE_BUILTIN_BITSCAN32 */
} }
static int static int
@ -776,6 +781,15 @@ lo0bits
(ULong *y) (ULong *y)
#endif #endif
{ {
#ifdef PR_HAVE_BUILTIN_BITSCAN32
int k;
ULong x = *y;
if (x>1)
*y = ( x >> (k = pr_bitscan_ctz32(x)) );
else
k = ((x ^ 1) << 5);
#else
register int k; register int k;
register ULong x = *y; register ULong x = *y;
@ -813,6 +827,7 @@ lo0bits
return 32; return 32;
} }
*y = x; *y = x;
#endif /* PR_HAVE_BUILTIN_BITSCAN32 */
return k; return k;
} }

View file

@ -42,20 +42,8 @@
*/ */
PR_IMPLEMENT(PRIntn) PR_CeilingLog2(PRUint32 n) PR_IMPLEMENT(PRIntn) PR_CeilingLog2(PRUint32 n)
{ {
PRIntn log2 = 0; PRIntn log2;
PR_CEILING_LOG2(log2, n);
if (n & (n-1))
log2++;
if (n >> 16)
log2 += 16, n >>= 16;
if (n >> 8)
log2 += 8, n >>= 8;
if (n >> 4)
log2 += 4, n >>= 4;
if (n >> 2)
log2 += 2, n >>= 2;
if (n >> 1)
log2++;
return log2; return log2;
} }
@ -65,17 +53,7 @@ PR_IMPLEMENT(PRIntn) PR_CeilingLog2(PRUint32 n)
*/ */
PR_IMPLEMENT(PRIntn) PR_FloorLog2(PRUint32 n) PR_IMPLEMENT(PRIntn) PR_FloorLog2(PRUint32 n)
{ {
PRIntn log2 = 0; PRIntn log2;
PR_FLOOR_LOG2(log2, n);
if (n >> 16)
log2 += 16, n >>= 16;
if (n >> 8)
log2 += 8, n >>= 8;
if (n >> 4)
log2 += 4, n >>= 4;
if (n >> 2)
log2 += 2, n >>= 2;
if (n >> 1)
log2++;
return log2; return log2;
} }

View file

@ -95,7 +95,8 @@ PRLock *_pr_dnsLock = NULL;
#if defined(SOLARIS) || (defined(BSDI) && defined(_REENTRANT)) \ #if defined(SOLARIS) || (defined(BSDI) && defined(_REENTRANT)) \
|| (defined(LINUX) && defined(_REENTRANT) \ || (defined(LINUX) && defined(_REENTRANT) \
&& !(defined(__GLIBC__) && __GLIBC__ >= 2)) && !(defined(__GLIBC__) && __GLIBC__ >= 2)) \
&& !defined(ANDROID)
#define _PR_HAVE_GETPROTO_R #define _PR_HAVE_GETPROTO_R
#define _PR_HAVE_GETPROTO_R_POINTER #define _PR_HAVE_GETPROTO_R_POINTER
#endif #endif
@ -1185,6 +1186,16 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr(
* any usable implementation. * any usable implementation.
*/ */
#if defined(ANDROID)
/* Android's Bionic libc system includes prototypes for these in netdb.h,
* but doesn't actually include implementations. It uses the 5-arg form,
* so these functions end up not matching the prototype. So just rename
* them if not found.
*/
#define getprotobyname_r _pr_getprotobyname_r
#define getprotobynumber_r _pr_getprotobynumber_r
#endif
static struct protoent *getprotobyname_r(const char* name) static struct protoent *getprotobyname_r(const char* name)
{ {
return getprotobyname(name); return getprotobyname(name);

View file

@ -1728,7 +1728,7 @@ PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm)
#if defined(SUNOS4) || (__GLIBC__ >= 2) || defined(XP_BEOS) \ #if defined(SUNOS4) || (__GLIBC__ >= 2) || defined(XP_BEOS) \
|| defined(NETBSD) || defined(OPENBSD) || defined(FREEBSD) \ || defined(NETBSD) || defined(OPENBSD) || defined(FREEBSD) \
|| defined(DARWIN) || defined(SYMBIAN) || defined(DARWIN) || defined(SYMBIAN) || defined(ANDROID)
a.tm_zone = NULL; a.tm_zone = NULL;
a.tm_gmtoff = tm->tm_params.tp_gmt_offset + a.tm_gmtoff = tm->tm_params.tp_gmt_offset +
tm->tm_params.tp_dst_offset; tm->tm_params.tp_dst_offset;

View file

@ -196,7 +196,7 @@ PR_IMPLEMENT(void) PR_DestroyLock(PRLock *lock)
memset(lock, 0xaf, sizeof(PRLock)); memset(lock, 0xaf, sizeof(PRLock));
pt_debug.locks_destroyed += 1; pt_debug.locks_destroyed += 1;
#endif #endif
PR_DELETE(lock); PR_Free(lock);
} /* PR_DestroyLock */ } /* PR_DestroyLock */
PR_IMPLEMENT(void) PR_Lock(PRLock *lock) PR_IMPLEMENT(void) PR_Lock(PRLock *lock)
@ -374,7 +374,7 @@ PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar *cvar)
memset(cvar, 0xaf, sizeof(PRCondVar)); memset(cvar, 0xaf, sizeof(PRCondVar));
pt_debug.cvars_destroyed += 1; pt_debug.cvars_destroyed += 1;
#endif #endif
PR_DELETE(cvar); PR_Free(cvar);
} }
} /* PR_DestroyCondVar */ } /* PR_DestroyCondVar */
@ -463,6 +463,7 @@ PR_IMPLEMENT(PRMonitor*) PR_NewMonitor(void)
{ {
PRMonitor *mon; PRMonitor *mon;
PRCondVar *cvar; PRCondVar *cvar;
int rv;
if (!_pr_initialized) _PR_ImplicitInitialization(); if (!_pr_initialized) _PR_ImplicitInitialization();
@ -473,11 +474,22 @@ PR_IMPLEMENT(PRMonitor*) PR_NewMonitor(void)
return NULL; return NULL;
} }
mon = PR_NEWZAP(PRMonitor); mon = PR_NEWZAP(PRMonitor);
if (mon != NULL) if (mon == NULL)
{ {
int rv; PR_Free(cvar);
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
return NULL;
}
rv = _PT_PTHREAD_MUTEX_INIT(mon->lock.mutex, _pt_mattr); rv = _PT_PTHREAD_MUTEX_INIT(mon->lock.mutex, _pt_mattr);
PR_ASSERT(0 == rv); PR_ASSERT(0 == rv);
if (0 != rv)
{
PR_Free(mon);
PR_Free(cvar);
PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);
return NULL;
}
_PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner); _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner);
@ -488,10 +500,11 @@ PR_IMPLEMENT(PRMonitor*) PR_NewMonitor(void)
mon->cvar->lock = &mon->lock; mon->cvar->lock = &mon->lock;
if (0 != rv) if (0 != rv)
{ {
PR_DELETE(mon); pthread_mutex_destroy(&mon->lock.mutex);
PR_DELETE(cvar); PR_Free(mon);
mon = NULL; PR_Free(cvar);
} PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, 0);
return NULL;
} }
return mon; return mon;
} /* PR_NewMonitor */ } /* PR_NewMonitor */
@ -513,7 +526,7 @@ PR_IMPLEMENT(void) PR_DestroyMonitor(PRMonitor *mon)
#if defined(DEBUG) #if defined(DEBUG)
memset(mon, 0xaf, sizeof(PRMonitor)); memset(mon, 0xaf, sizeof(PRMonitor));
#endif #endif
PR_DELETE(mon); PR_Free(mon);
} /* PR_DestroyMonitor */ } /* PR_DestroyMonitor */
@ -674,7 +687,7 @@ PR_IMPLEMENT(void) PR_DestroySem(PRSemaphore *semaphore)
"PR_DestroySem", "locks & condition variables"); "PR_DestroySem", "locks & condition variables");
PR_DestroyLock(semaphore->cvar->lock); PR_DestroyLock(semaphore->cvar->lock);
PR_DestroyCondVar(semaphore->cvar); PR_DestroyCondVar(semaphore->cvar);
PR_DELETE(semaphore); PR_Free(semaphore);
} /* PR_DestroySem */ } /* PR_DestroySem */
PR_IMPLEMENT(PRSemaphore*) PR_NewSem(PRUintn value) PR_IMPLEMENT(PRSemaphore*) PR_NewSem(PRUintn value)
@ -700,7 +713,7 @@ PR_IMPLEMENT(PRSemaphore*) PR_NewSem(PRUintn value)
} }
PR_DestroyLock(lock); PR_DestroyLock(lock);
} }
PR_DELETE(semaphore); PR_Free(semaphore);
} }
return NULL; return NULL;
} }
@ -757,7 +770,7 @@ PR_IMPLEMENT(PRSem *) PR_OpenSemaphore(
if ((sem_t *) -1 == sem->sem) if ((sem_t *) -1 == sem->sem)
{ {
_PR_MD_MAP_DEFAULT_ERROR(errno); _PR_MD_MAP_DEFAULT_ERROR(errno);
PR_DELETE(sem); PR_Free(sem);
return NULL; return NULL;
} }
return sem; return sem;
@ -796,7 +809,7 @@ PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem *sem)
_PR_MD_MAP_DEFAULT_ERROR(errno); _PR_MD_MAP_DEFAULT_ERROR(errno);
return PR_FAILURE; return PR_FAILURE;
} }
PR_DELETE(sem); PR_Free(sem);
return PR_SUCCESS; return PR_SUCCESS;
} }
@ -907,7 +920,7 @@ PR_IMPLEMENT(PRSem *) PR_OpenSemaphore(
if (semctl(sem->semid, 0, SETVAL, arg) == -1) if (semctl(sem->semid, 0, SETVAL, arg) == -1)
{ {
_PR_MD_MAP_DEFAULT_ERROR(errno); _PR_MD_MAP_DEFAULT_ERROR(errno);
PR_DELETE(sem); PR_Free(sem);
return NULL; return NULL;
} }
/* call semop to set sem_otime to nonzero */ /* call semop to set sem_otime to nonzero */
@ -917,7 +930,7 @@ PR_IMPLEMENT(PRSem *) PR_OpenSemaphore(
if (semop(sem->semid, &sop, 1) == -1) if (semop(sem->semid, &sop, 1) == -1)
{ {
_PR_MD_MAP_DEFAULT_ERROR(errno); _PR_MD_MAP_DEFAULT_ERROR(errno);
PR_DELETE(sem); PR_Free(sem);
return NULL; return NULL;
} }
return sem; return sem;
@ -926,7 +939,7 @@ PR_IMPLEMENT(PRSem *) PR_OpenSemaphore(
if (errno != EEXIST || flags & PR_SEM_EXCL) if (errno != EEXIST || flags & PR_SEM_EXCL)
{ {
_PR_MD_MAP_DEFAULT_ERROR(errno); _PR_MD_MAP_DEFAULT_ERROR(errno);
PR_DELETE(sem); PR_Free(sem);
return NULL; return NULL;
} }
} }
@ -935,7 +948,7 @@ PR_IMPLEMENT(PRSem *) PR_OpenSemaphore(
if (sem->semid == -1) if (sem->semid == -1)
{ {
_PR_MD_MAP_DEFAULT_ERROR(errno); _PR_MD_MAP_DEFAULT_ERROR(errno);
PR_DELETE(sem); PR_Free(sem);
return NULL; return NULL;
} }
for (i = 0; i < MAX_TRIES; i++) for (i = 0; i < MAX_TRIES; i++)
@ -948,7 +961,7 @@ PR_IMPLEMENT(PRSem *) PR_OpenSemaphore(
if (i == MAX_TRIES) if (i == MAX_TRIES)
{ {
PR_SetError(PR_IO_TIMEOUT_ERROR, 0); PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
PR_DELETE(sem); PR_Free(sem);
return NULL; return NULL;
} }
return sem; return sem;
@ -986,7 +999,7 @@ PR_IMPLEMENT(PRStatus) PR_PostSemaphore(PRSem *sem)
PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem *sem) PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem *sem)
{ {
PR_DELETE(sem); PR_Free(sem);
return PR_SUCCESS; return PR_SUCCESS;
} }
@ -1112,7 +1125,7 @@ PR_IMPLEMENT(void) PRP_DestroyNakedCondVar(PRCondVar *cvar)
#if defined(DEBUG) #if defined(DEBUG)
memset(cvar, 0xaf, sizeof(PRCondVar)); memset(cvar, 0xaf, sizeof(PRCondVar));
#endif #endif
PR_DELETE(cvar); PR_Free(cvar);
} /* PRP_DestroyNakedCondVar */ } /* PRP_DestroyNakedCondVar */
PR_IMPLEMENT(PRStatus) PRP_NakedWait( PR_IMPLEMENT(PRStatus) PRP_NakedWait(

View file

@ -450,6 +450,11 @@ LIBPTHREAD = -ldce
endif endif
endif endif
ifeq ($(OS_TARGET),Android)
LDOPTS=$(OS_LDFLAGS)
LIBPTHREAD=
XCFLAGS=${OS_CFLAGS}
endif
##################################################### #####################################################
# #