From c7b630b00f0112c9600c1481eaebe8e8a7724fa9 Mon Sep 17 00:00:00 2001 From: cvs2hg Date: Thu, 8 Oct 2009 02:31:26 +0000 Subject: fixup commit for branch 'GECKO181_20100228_RELBRANCH' --- admin/repackage.sh | 8 +-- config/rules.mk | 11 ++-- configure | 86 ++++++++++++++++++++++---------- configure.in | 17 ++++++- lib/libc/include/plbase64.h | 10 ++++ lib/libc/src/base64.c | 30 +++++++++-- lib/libc/src/strlen.c | 5 +- pr/include/md/_darwin.h | 1 + pr/include/md/_linux.cfg | 7 +++ pr/include/md/_netbsd.cfg | 106 ++++++++++++++++++++++++++++++++++++--- pr/include/md/_netbsd.h | 12 ++--- pr/include/prinit.h | 6 +-- pr/include/prlong.h | 3 +- pr/include/prtypes.h | 8 ++- pr/src/linking/prlink.c | 16 ++---- pr/src/md/windows/ntinrval.c | 21 +------- pr/src/misc/Makefile.in | 4 +- pr/src/misc/prdtoa.c | 99 ++++++++++++++++++++---------------- pr/src/misc/prsystem.c | 43 ++++++++++++++-- pr/src/misc/prtime.c | 39 ++++++++++++--- pr/src/pthreads/ptio.c | 2 +- pr/src/pthreads/ptsynch.c | 2 +- pr/tests/Makefile.in | 1 + pr/tests/parsetm.c | 116 +++++++++++++++++++++++++++++++++++++++++++ pr/tests/runtests.pl | 1 + pr/tests/runtests.sh | 1 + pr/tests/vercheck.c | 8 +-- 27 files changed, 506 insertions(+), 157 deletions(-) create mode 100644 pr/tests/parsetm.c diff --git a/admin/repackage.sh b/admin/repackage.sh index 187279ef..53b75cf0 100755 --- a/admin/repackage.sh +++ b/admin/repackage.sh @@ -64,10 +64,10 @@ # # ------------------------------------------------------------------ -FROMTOP=/share/builds/components/nspr20/v4.7.4 -TOTOP=./v4.7.4 -NSPRDIR=nspr-4.7.4 -SOURCETAG=NSPR_4_7_4_RTM +FROMTOP=/share/builds/components/nspr20/v4.7.6 +TOTOP=./v4.7.6 +NSPRDIR=nspr-4.7.6 +SOURCETAG=NSPR_4_7_6_RTM # # enumerate Unix object directories on /s/b/c diff --git a/config/rules.mk b/config/rules.mk index e69b48b9..d2968b05 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -401,16 +401,17 @@ endif ifdef NEED_ABSOLUTE_PATH PWD := $(shell pwd) -abspath = $(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(PWD)/$(1))) +# The quotes allow absolute paths to contain spaces. +pr_abspath = "$(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(PWD)/$(1)))" endif $(OBJDIR)/%.$(OBJ_SUFFIX): %.cpp @$(MAKE_OBJDIR) ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) - $(CCC) -Fo$@ -c $(CCCFLAGS) $(call abspath,$<) + $(CCC) -Fo$@ -c $(CCCFLAGS) $(call pr_abspath,$<) else ifdef NEED_ABSOLUTE_PATH - $(CCC) -o $@ -c $(CCCFLAGS) $(call abspath,$<) + $(CCC) -o $@ -c $(CCCFLAGS) $(call pr_abspath,$<) else $(CCC) -o $@ -c $(CCCFLAGS) $< endif @@ -422,10 +423,10 @@ WCCFLAGS3 = $(subst -D,-d,$(WCCFLAGS2)) $(OBJDIR)/%.$(OBJ_SUFFIX): %.c @$(MAKE_OBJDIR) ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) - $(CC) -Fo$@ -c $(CFLAGS) $(call abspath,$<) + $(CC) -Fo$@ -c $(CFLAGS) $(call pr_abspath,$<) else ifdef NEED_ABSOLUTE_PATH - $(CC) -o $@ -c $(CFLAGS) $(call abspath,$<) + $(CC) -o $@ -c $(CFLAGS) $(call pr_abspath,$<) else $(CC) -o $@ -c $(CFLAGS) $< endif diff --git a/configure b/configure index af611e4f..e6ff00d3 100755 --- a/configure +++ b/configure @@ -689,7 +689,7 @@ test "$host_alias" != "$target_alias" && MOD_MAJOR_VERSION=4 MOD_MINOR_VERSION=7 -MOD_PATCH_VERSION=4 +MOD_PATCH_VERSION=6 NSPR_MODNAME=nspr20 _HAVE_PTHREADS= USE_PTHREADS= @@ -3344,10 +3344,6 @@ EOF cat >> confdefs.h <<\EOF #define HAVE_BSD_FLOCK 1 -EOF - - cat >> confdefs.h <<\EOF -#define HAVE_SOCKLEN_T 1 EOF CFLAGS="$CFLAGS -Wmost -fno-common" @@ -3454,6 +3450,42 @@ tools are selected during the Xcode/Developer Tools installation." 1>&2; exit 1; fi fi fi + + echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 +echo "configure:3456: checking for socklen_t" >&5 + if eval "test \"`echo '$''{'ac_cv_socklen_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < + #include +int main() { +socklen_t foo = 0; +; return 0; } +EOF +if { (eval echo configure:3469: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_socklen_t=true +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_socklen_t=false +fi +rm -f conftest* +fi + + if test "$ac_cv_socklen_t" = true ; then + cat >> confdefs.h <<\EOF +#define HAVE_SOCKLEN_T 1 +EOF + + echo "$ac_t""yes" 1>&6 + else + echo "$ac_t""no" 1>&6 + fi ;; *-dgux*) @@ -4503,17 +4535,17 @@ EOF _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000" ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6 -echo "configure:4507: checking for machine/builtins.h" >&5 +echo "configure:4539: checking for machine/builtins.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4517: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4549: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5043,7 +5075,7 @@ case $target in ;; *) echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:5047: checking for dlopen in -ldl" >&5 +echo "configure:5079: checking for dlopen in -ldl" >&5 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5051,7 +5083,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5079,17 +5111,17 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6 -echo "configure:5083: checking for dlfcn.h" >&5 +echo "configure:5115: checking for dlfcn.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5093: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5125: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5122,13 +5154,13 @@ esac if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:5126: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:5158: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext < Autoconf TIOCGETP @@ -5146,7 +5178,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < Autoconf TCGETA @@ -5170,12 +5202,12 @@ fi for ac_func in lchown strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5174: checking for $ac_func" >&5 +echo "configure:5206: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5239,7 +5271,7 @@ hpux*) if test -z "$GNU_CC"; then echo $ac_n "checking for +Olit support""... $ac_c" 1>&6 -echo "configure:5243: checking for +Olit support" >&5 +echo "configure:5275: checking for +Olit support" >&5 if eval "test \"`echo '$''{'ac_cv_hpux_usable_olit_option'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5278,7 +5310,7 @@ darwin*) *) echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:5282: checking for pthread_create in -lpthreads" >&5 +echo "configure:5314: checking for pthread_create in -lpthreads" >&5 echo " #include void *foo(void *v) { return v; } @@ -5300,7 +5332,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:5304: checking for pthread_create in -lpthread" >&5 +echo "configure:5336: checking for pthread_create in -lpthread" >&5 echo " #include void *foo(void *v) { return v; } @@ -5322,7 +5354,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:5326: checking for pthread_create in -lc_r" >&5 +echo "configure:5358: checking for pthread_create in -lc_r" >&5 echo " #include void *foo(void *v) { return v; } @@ -5344,7 +5376,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6 -echo "configure:5348: checking for pthread_create in -lc" >&5 +echo "configure:5380: checking for pthread_create in -lc" >&5 echo " #include void *foo(void *v) { return v; } @@ -5476,7 +5508,7 @@ if test -n "$USE_PTHREADS"; then rm -f conftest* ac_cv_have_dash_pthread=no echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6 -echo "configure:5480: checking whether ${CC-cc} accepts -pthread" >&5 +echo "configure:5512: checking whether ${CC-cc} accepts -pthread" >&5 echo 'int main() { return 0; }' | cat > conftest.c ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1 if test $? -eq 0; then @@ -5499,7 +5531,7 @@ echo "configure:5480: checking whether ${CC-cc} accepts -pthread" >&5 ac_cv_have_dash_pthreads=no if test "$ac_cv_have_dash_pthread" = "no"; then echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6 -echo "configure:5503: checking whether ${CC-cc} accepts -pthreads" >&5 +echo "configure:5535: checking whether ${CC-cc} accepts -pthreads" >&5 echo 'int main() { return 0; }' | cat > conftest.c ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1 if test $? -eq 0; then diff --git a/configure.in b/configure.in index e0dc3568..5c0ddf7e 100644 --- a/configure.in +++ b/configure.in @@ -50,7 +50,7 @@ dnl = Defaults dnl ======================================================== MOD_MAJOR_VERSION=4 MOD_MINOR_VERSION=7 -MOD_PATCH_VERSION=4 +MOD_PATCH_VERSION=6 NSPR_MODNAME=nspr20 _HAVE_PTHREADS= USE_PTHREADS= @@ -996,7 +996,6 @@ case "$target" in AC_DEFINE(XP_UNIX) AC_DEFINE(DARWIN) AC_DEFINE(HAVE_BSD_FLOCK) - AC_DEFINE(HAVE_SOCKLEN_T) CFLAGS="$CFLAGS -Wmost -fno-common" case "${target_cpu}" in i*86*) @@ -1143,6 +1142,20 @@ tools are selected during the Xcode/Developer Tools installation.]) fi fi fi + + AC_MSG_CHECKING(for socklen_t) + AC_CACHE_VAL(ac_cv_socklen_t, + [AC_TRY_COMPILE([#include + #include ], + [socklen_t foo = 0;], + [ac_cv_socklen_t=true], + [ac_cv_socklen_t=false])]) + if test "$ac_cv_socklen_t" = true ; then + AC_DEFINE(HAVE_SOCKLEN_T) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi ;; *-dgux*) diff --git a/lib/libc/include/plbase64.h b/lib/libc/include/plbase64.h index ac07e837..d21ff5d7 100644 --- a/lib/libc/include/plbase64.h +++ b/lib/libc/include/plbase64.h @@ -57,6 +57,10 @@ PR_BEGIN_EXTERN_C * be terminated with an extra null character. It is the caller's * responsibility to free the result when it is allocated. A null is returned * if the allocation fails. + * + * NOTE: when calculating ((srclen + 2)/3)*4), first ensure that + * srclen <= (PR_UINT32_MAX/4) * 3 + * to avoid PRUint32 overflow. */ PR_EXTERN(char *) @@ -83,6 +87,12 @@ PL_Base64Encode * result *will* be terminated with an extra null character. It is the * caller's responsibility to free the result when it is allocated. A null * is retuned if the allocation fails, or if the source is not well-coded. + * + * NOTE: when calculating (srclen * 3)/4, first ensure that + * srclen <= PR_UINT32_MAX/3 + * to avoid PRUint32 overflow. Alternatively, calculate + * (srclen/4) * 3 + ((srclen%4) * 3)/4 + * which is equivalent but doesn't overflow for any value of srclen. */ PR_EXTERN(char *) diff --git a/lib/libc/src/base64.c b/lib/libc/src/base64.c index 234d60d8..e3fd80d7 100644 --- a/lib/libc/src/base64.c +++ b/lib/libc/src/base64.c @@ -38,7 +38,8 @@ #include "plbase64.h" #include "prlog.h" /* For PR_NOT_REACHED */ #include "prmem.h" /* for malloc / PR_MALLOC */ -#include "plstr.h" /* for PL_strlen */ + +#include /* for strlen */ static unsigned char *base = (unsigned char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -150,12 +151,24 @@ PL_Base64Encode { if( 0 == srclen ) { - srclen = PL_strlen(src); + size_t len = strlen(src); + srclen = len; + /* Detect truncation. */ + if( srclen != len ) + { + return (char *)0; + } } if( (char *)0 == dest ) { - PRUint32 destlen = ((srclen + 2)/3) * 4; + PRUint32 destlen; + /* Ensure all PRUint32 values stay within range. */ + if( srclen > (PR_UINT32_MAX/4) * 3 ) + { + return (char *)0; + } + destlen = ((srclen + 2)/3) * 4; dest = (char *)PR_MALLOC(destlen + 1); if( (char *)0 == dest ) { @@ -383,7 +396,13 @@ PL_Base64Decode if( 0 == srclen ) { - srclen = PL_strlen(src); + size_t len = strlen(src); + srclen = len; + /* Detect truncation. */ + if( srclen != len ) + { + return (char *)0; + } } if( srclen && (0 == (srclen & 3)) ) @@ -403,7 +422,8 @@ PL_Base64Decode if( (char *)0 == dest ) { - PRUint32 destlen = ((srclen * 3) / 4); + /* The following computes ((srclen * 3) / 4) without overflow. */ + PRUint32 destlen = (srclen / 4) * 3 + ((srclen % 4) * 3) / 4; dest = (char *)PR_MALLOC(destlen + 1); if( (char *)0 == dest ) { diff --git a/lib/libc/src/strlen.c b/lib/libc/src/strlen.c index 6c476777..e03f7d25 100644 --- a/lib/libc/src/strlen.c +++ b/lib/libc/src/strlen.c @@ -53,7 +53,10 @@ PL_strlen(const char *str) * we don't have ultra long strings that overflow an int32 */ if( sizeof(PRUint32) < sizeof(size_t) ) - PR_ASSERT(l < 2147483647); + { + if( l > PR_INT32_MAX ) + PR_Assert("l <= PR_INT32_MAX", __FILE__, __LINE__); + } return (PRUint32)l; } diff --git a/pr/include/md/_darwin.h b/pr/include/md/_darwin.h index 0d4e6ce3..fc377984 100644 --- a/pr/include/md/_darwin.h +++ b/pr/include/md/_darwin.h @@ -72,6 +72,7 @@ #define _PR_HAVE_SOCKADDR_LEN #define _PR_STAT_HAS_ST_ATIMESPEC #define _PR_HAVE_LARGE_OFF_T +#define _PR_HAVE_SYSV_SEMAPHORES #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY #define _PR_INET6 diff --git a/pr/include/md/_linux.cfg b/pr/include/md/_linux.cfg index 1999d3cf..6629447e 100644 --- a/pr/include/md/_linux.cfg +++ b/pr/include/md/_linux.cfg @@ -521,8 +521,15 @@ #elif defined(__arm__) +#ifdef __ARMEB__ +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#elif defined(__ARMEL__) #define IS_LITTLE_ENDIAN 1 #undef IS_BIG_ENDIAN +#else +#error "Unknown ARM endianness." +#endif #define PR_BYTES_PER_BYTE 1 #define PR_BYTES_PER_SHORT 2 diff --git a/pr/include/md/_netbsd.cfg b/pr/include/md/_netbsd.cfg index cb4e6262..4a638382 100644 --- a/pr/include/md/_netbsd.cfg +++ b/pr/include/md/_netbsd.cfg @@ -52,7 +52,8 @@ #define HAVE_LONG_LONG #endif -#if defined(__i386__) || defined(__arm32__) || defined(__MIPSEL__) +#if defined(__i386__) || defined(__arm32__) || defined(__ARMEL__) || \ + defined(__MIPSEL__) #define IS_LITTLE_ENDIAN 1 #undef IS_BIG_ENDIAN @@ -97,12 +98,58 @@ #define PR_ALIGN_OF_DOUBLE 4 #define PR_ALIGN_OF_POINTER 4 -#elif defined(__sparc__) || defined(__MIPSEB__) +#elif defined(__sparc_v9__) -#undef IS_LITTLE_ENDIAN -#define IS_BIG_ENDIAN 1 -#define HAVE_ALIGNED_DOUBLES -#define HAVE_ALIGNED_LONGLONGS +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#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_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#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 + +#elif defined(__sparc__) || defined(__MIPSEB__) || defined(__ARMEB__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS #define PR_BYTES_PER_BYTE 1 #define PR_BYTES_PER_SHORT 2 @@ -188,6 +235,53 @@ #define PR_BYTES_PER_WORD_LOG2 3 #define PR_BYTES_PER_DWORD_LOG2 3 +#elif defined(__amd64__) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define HAVE_ALIGNED_DOUBLES +#define HAVE_ALIGNED_LONGLONGS +#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(__powerpc__) || defined(__m68k__) #undef IS_LITTLE_ENDIAN diff --git a/pr/include/md/_netbsd.h b/pr/include/md/_netbsd.h index db25bd89..bf57a4f5 100644 --- a/pr/include/md/_netbsd.h +++ b/pr/include/md/_netbsd.h @@ -47,6 +47,8 @@ #define _PR_SI_ARCHITECTURE "x86" #elif defined(__alpha__) #define _PR_SI_ARCHITECTURE "alpha" +#elif defined(__amd64__) +#define _PR_SI_ARCHITECTURE "amd64" #elif defined(__m68k__) #define _PR_SI_ARCHITECTURE "m68k" #elif defined(__powerpc__) @@ -92,12 +94,6 @@ #define _PR_INET6_PROBE #endif -#if __NetBSD_Version__ >= 106370000 -/* NetBSD 1.6ZK */ -#define _PR_HAVE_GETPROTO_R -#define _PR_HAVE_GETPROTO_R_INT -#endif - #define USE_SETJMP #ifndef _PR_PTHREADS @@ -243,6 +239,10 @@ struct _MDCPU { #endif /* ! _PR_PTHREADS */ +extern void _MD_EarlyInit(void); +extern PRIntervalTime _PR_UNIX_GetInterval(void); +extern PRIntervalTime _PR_UNIX_TicksPerSecond(void); + #define _MD_EARLY_INIT _MD_EarlyInit #define _MD_FINAL_INIT _PR_UnixInit #define _MD_GET_INTERVAL _PR_UNIX_GetInterval diff --git a/pr/include/prinit.h b/pr/include/prinit.h index 091900a2..50169700 100644 --- a/pr/include/prinit.h +++ b/pr/include/prinit.h @@ -63,11 +63,11 @@ PR_BEGIN_EXTERN_C ** The format of the version string is ** ".[.] []" */ -#define PR_VERSION "4.7.4 Beta" +#define PR_VERSION "4.7.6" #define PR_VMAJOR 4 #define PR_VMINOR 7 -#define PR_VPATCH 4 -#define PR_BETA PR_TRUE +#define PR_VPATCH 6 +#define PR_BETA PR_FALSE /* ** PRVersionCheck diff --git a/pr/include/prlong.h b/pr/include/prlong.h index 09b43217..42c5792e 100644 --- a/pr/include/prlong.h +++ b/pr/include/prlong.h @@ -77,7 +77,8 @@ NSPR_API(PRUint64) LL_MaxUint(void); #if defined(HAVE_LONG_LONG) -#if PR_BYTES_PER_LONG == 8 +/* Keep this in sync with prtypes.h. */ +#if PR_BYTES_PER_LONG == 8 && !defined(__APPLE__) #define LL_MAXINT 9223372036854775807L #define LL_MININT (-LL_MAXINT - 1L) #define LL_ZERO 0L diff --git a/pr/include/prtypes.h b/pr/include/prtypes.h index 66814841..67ee6082 100644 --- a/pr/include/prtypes.h +++ b/pr/include/prtypes.h @@ -387,7 +387,13 @@ typedef long PRInt32; ** the LL_ macros (see prlong.h). ************************************************************************/ #ifdef HAVE_LONG_LONG -#if PR_BYTES_PER_LONG == 8 +/* Keep this in sync with prlong.h. */ +/* + * On 64-bit Mac OS X, uint64 needs to be defined as unsigned long long to + * match uint64_t, otherwise our uint64 typedef conflicts with the uint64 + * typedef in cssmconfig.h, which CoreServices.h includes indirectly. + */ +#if PR_BYTES_PER_LONG == 8 && !defined(__APPLE__) typedef long PRInt64; typedef unsigned long PRUint64; #elif defined(WIN16) diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c index c2d2d731..016eadeb 100644 --- a/pr/src/linking/prlink.c +++ b/pr/src/linking/prlink.c @@ -223,15 +223,7 @@ static int pr_ConvertUTF16toUTF8(LPCWSTR wname, LPSTR name, int len); /************************************************************************/ #if !defined(USE_DLFCN) && !defined(HAVE_STRERROR) -static char* errStrBuf = NULL; #define ERR_STR_BUF_LENGTH 20 -static char* errno_string(PRIntn oserr) -{ - if (errStrBuf == NULL) - errStrBuf = PR_MALLOC(ERR_STR_BUF_LENGTH); - PR_snprintf(errStrBuf, ERR_STR_BUF_LENGTH, "error %d", oserr); - return errStrBuf; -} #endif static void DLLErrorInternal(PRIntn oserr) @@ -247,7 +239,9 @@ static void DLLErrorInternal(PRIntn oserr) #elif defined(HAVE_STRERROR) error = strerror(oserr); /* this should be okay */ #else - error = errno_string(oserr); + char errStrBuf[ERR_STR_BUF_LENGTH]; + PR_snprintf(errStrBuf, sizeof(errStrBuf), "error %d", oserr); + error = errStrBuf; #endif if (NULL != error) PR_SetErrorText(strlen(error), error); @@ -382,10 +376,6 @@ void _PR_ShutdownLinker(void) free(_pr_currentLibPath); _pr_currentLibPath = NULL; } - -#if !defined(USE_DLFCN) && !defined(HAVE_STRERROR) - PR_DELETE(errStrBuf); -#endif } #endif diff --git a/pr/src/md/windows/ntinrval.c b/pr/src/md/windows/ntinrval.c index f96c27b5..b8d85831 100644 --- a/pr/src/md/windows/ntinrval.c +++ b/pr/src/md/windows/ntinrval.c @@ -42,34 +42,15 @@ #include "primpl.h" -#ifdef WINCE -typedef DWORD (*IntervalFuncType)(void); -static IntervalFuncType intervalFunc; -#endif - void _PR_MD_INTERVAL_INIT() { -#ifdef WINCE - HMODULE mmtimerlib = LoadLibraryW(L"mmtimer.dll"); /* XXX leaked! */ - if (mmtimerlib) { - intervalFunc = (IntervalFuncType)GetProcAddress(mmtimerlib, - "timeGetTime"); - } else { - intervalFunc = &GetTickCount; - } -#endif } PRIntervalTime _PR_MD_GET_INTERVAL() { - /* milliseconds since system start */ -#ifdef WINCE - return (*intervalFunc)(); -#else - return timeGetTime(); -#endif + return timeGetTime(); /* milliseconds since system start */ } PRIntervalTime diff --git a/pr/src/misc/Makefile.in b/pr/src/misc/Makefile.in index 55791215..79dc59ed 100644 --- a/pr/src/misc/Makefile.in +++ b/pr/src/misc/Makefile.in @@ -94,9 +94,9 @@ ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) $(OBJDIR)/prdtoa.$(OBJ_SUFFIX): prdtoa.c @$(MAKE_OBJDIR) ifeq (,$(filter-out 1100 1200 1300 1310,$(MSC_VER))) - $(CC) -Fo$@ -c $(CFLAGS) -Op $(call abspath,$<) + $(CC) -Fo$@ -c $(CFLAGS) -Op $(call pr_abspath,$<) else - $(CC) -Fo$@ -c $(CFLAGS) -fp:precise $(call abspath,$<) + $(CC) -Fo$@ -c $(CFLAGS) -fp:precise $(call pr_abspath,$<) endif endif diff --git a/pr/src/misc/prdtoa.c b/pr/src/misc/prdtoa.c index dd3134fa..1ec52daf 100644 --- a/pr/src/misc/prdtoa.c +++ b/pr/src/misc/prdtoa.c @@ -175,7 +175,12 @@ void _PR_CleanupDtoa(void) * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) * if memory is available and otherwise does something you deem * appropriate. If MALLOC is undefined, malloc will be invoked - * directly -- and assumed always to succeed. + * directly -- and assumed always to succeed. Similarly, if you + * want something other than the system's free() to be called to + * recycle memory acquired from MALLOC, #define FREE to be the + * name of the alternate routine. (FREE or free is only called in + * pathological cases, e.g., in a dtoa call after a dtoa return in + * mode 3 with thousands of digits requested.) * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making * memory allocations from a private pool of memory when possible. * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes, @@ -217,11 +222,6 @@ void _PR_CleanupDtoa(void) * floating-point numbers and flushes underflows to zero rather * than implementing gradual underflow, then you must also #define * Sudden_Underflow. - * #define YES_ALIAS to permit aliasing certain double values with - * arrays of ULongs. This leads to slightly better code with - * some compilers and was always used prior to 19990916, but it - * is not strictly legal and can cause trouble with aggressively - * optimizing compilers (e.g., gcc 2.95.1 under -O2). * #define USE_LOCALE to use the current locale's decimal_point value. * #define SET_INEXACT if IEEE arithmetic is being used and extra * computation should be done to set the inexact flag when the @@ -358,24 +358,13 @@ Exactly one of IEEE_8087, IEEE_MC68k, IEEE_ARM, VAX, or IBM should be defined. typedef union { double d; ULong L[2]; } U; -#ifdef YES_ALIAS -#define dval(x) x +#define dval(x) (x).d #ifdef IEEE_8087 -#define word0(x) ((ULong *)&x)[1] -#define word1(x) ((ULong *)&x)[0] +#define word0(x) (x).L[1] +#define word1(x) (x).L[0] #else -#define word0(x) ((ULong *)&x)[0] -#define word1(x) ((ULong *)&x)[1] -#endif -#else -#ifdef IEEE_8087 -#define word0(x) ((U*)&x)->L[1] -#define word1(x) ((U*)&x)->L[0] -#else -#define word0(x) ((U*)&x)->L[0] -#define word1(x) ((U*)&x)->L[1] -#endif -#define dval(x) ((U*)&x)->d +#define word0(x) (x).L[0] +#define word1(x) (x).L[1] #endif /* The following definition of Storeinc is appropriate for MIPS processors. @@ -559,7 +548,7 @@ extern double rnd_prod(double, double), rnd_quot(double, double); #define FREE_DTOA_LOCK(n) /*nothing*/ #endif -#define Kmax 15 +#define Kmax 7 struct Bigint { @@ -587,9 +576,10 @@ Balloc #endif ACQUIRE_DTOA_LOCK(0); - if (rv = freelist[k]) { + /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */ + /* but this case seems very unlikely. */ + if (k <= Kmax && (rv = freelist[k])) freelist[k] = rv->next; - } else { x = 1 << k; #ifdef Omit_Private_Memory @@ -597,7 +587,7 @@ Balloc #else len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) /sizeof(double); - if (pmem_next - private_mem + len <= PRIVATE_mem) { + if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) { rv = (Bigint*)pmem_next; pmem_next += len; } @@ -621,10 +611,18 @@ Bfree #endif { if (v) { - ACQUIRE_DTOA_LOCK(0); - v->next = freelist[v->k]; - freelist[v->k] = v; - FREE_DTOA_LOCK(0); + if (v->k > Kmax) +#ifdef FREE + FREE((void*)v); +#else + free((void*)v); +#endif + else { + ACQUIRE_DTOA_LOCK(0); + v->next = freelist[v->k]; + freelist[v->k] = v; + FREE_DTOA_LOCK(0); + } } } @@ -1184,14 +1182,15 @@ diff static double ulp #ifdef KR_headers - (x) double x; + (dx) double dx; #else - (double x) + (double dx) #endif { register Long L; - double a; + U x, a; + dval(x) = dx; L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; #ifndef Avoid_Underflow #ifndef Sudden_Underflow @@ -1233,7 +1232,7 @@ b2d { ULong *xa, *xa0, w, y, z; int k; - double d; + U d; #ifdef VAX ULong d0, d1; #else @@ -1296,11 +1295,12 @@ b2d static Bigint * d2b #ifdef KR_headers - (d, e, bits) double d; int *e, *bits; + (dd, e, bits) double dd; int *e, *bits; #else - (double d, int *e, int *bits) + (double dd, int *e, int *bits) #endif { + U d; Bigint *b; int de, k; ULong *x, y, z; @@ -1309,6 +1309,10 @@ d2b #endif #ifdef VAX ULong d0, d1; +#endif + + dval(d) = dd; +#ifdef VAX d0 = word0(d) >> 16 | word0(d) << 16; d1 = word1(d) >> 16 | word1(d) << 16; #else @@ -1439,7 +1443,7 @@ ratio (Bigint *a, Bigint *b) #endif { - double da, db; + U da, db; int k, ka, kb; dval(da) = b2d(a, &ka); @@ -1613,7 +1617,8 @@ PR_strtod int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; CONST char *s, *s0, *s1; - double aadj, aadj1, adj, rv, rv0; + double aadj, aadj1, adj; + U aadj2, rv, rv0; Long L; ULong y, z; Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; @@ -2376,7 +2381,9 @@ PR_strtod aadj = z; aadj1 = dsign ? aadj : -aadj; } - word0(aadj1) += (2*P+1)*Exp_msk1 - y; + dval(aadj2) = aadj1; + word0(aadj2) += (2*P+1)*Exp_msk1 - y; + aadj1 = dval(aadj2); } adj = aadj1 * ulp(dval(rv)); dval(rv) += adj; @@ -2711,10 +2718,10 @@ freedtoa(char *s) static char * dtoa #ifdef KR_headers - (d, mode, ndigits, decpt, sign, rve) - double d; int mode, ndigits, *decpt, *sign; char **rve; + (dd, mode, ndigits, decpt, sign, rve) + double dd; int mode, ndigits, *decpt, *sign; char **rve; #else - (double d, int mode, int ndigits, int *decpt, int *sign, char **rve) + (double dd, int mode, int ndigits, int *decpt, int *sign, char **rve) #endif { /* Arguments ndigits, decpt, sign are similar to those @@ -2760,7 +2767,8 @@ dtoa ULong x; #endif Bigint *b, *b1, *delta, *mlo, *mhi, *S; - double d2, ds, eps; + U d, d2, eps; + double ds; char *s, *s0; #ifdef Honor_FLT_ROUNDS int rounding; @@ -2776,6 +2784,7 @@ dtoa } #endif + dval(d) = dd; if (word0(d) & Sign_bit) { /* set sign for everything, including 0's and NaNs */ *sign = 1; @@ -3435,13 +3444,15 @@ PR_dtoa(PRFloat64 d, PRIntn mode, PRIntn ndigits, ** '+' or '-' after the 'e' in scientific notation */ PR_IMPLEMENT(void) -PR_cnvtf(char *buf,int bufsz, int prcsn,double fval) +PR_cnvtf(char *buf, int bufsz, int prcsn, double dfval) { PRIntn decpt, sign, numdigits; char *num, *nump; char *bufp = buf; char *endnum; + U fval; + dval(fval) = dfval; /* If anything fails, we store an empty string in 'buf' */ num = (char*)PR_MALLOC(bufsz); if (num == NULL) { diff --git a/pr/src/misc/prsystem.c b/pr/src/misc/prsystem.c index f3542a50..2810e6af 100644 --- a/pr/src/misc/prsystem.c +++ b/pr/src/misc/prsystem.c @@ -269,6 +269,36 @@ PR_IMPLEMENT(PRInt32) PR_GetNumberOfProcessors( void ) return(numCpus); } /* end PR_GetNumberOfProcessors() */ +#ifdef DARWIN + +/* + * Manually define the host_basic_info structure in Mac OS X 10.4 or later + * so that we can compile against Mac OS X 10.2 and 10.3 SDKs. + */ + +#pragma pack(4) + +struct host_basic_info_new { + integer_t max_cpus; + integer_t avail_cpus; + natural_t memory_size; + cpu_type_t cpu_type; + cpu_subtype_t cpu_subtype; + /*cpu_threadtype_t*/ integer_t cpu_threadtype; + integer_t physical_cpu; + integer_t physical_cpu_max; + integer_t logical_cpu; + integer_t logical_cpu_max; + uint64_t max_mem; +}; + +#pragma pack() + +#define HOST_BASIC_INFO_NEW_COUNT ((mach_msg_type_number_t) \ + (sizeof(struct host_basic_info_new)/sizeof(integer_t))) + +#endif /* DARWIN */ + /* ** PR_GetPhysicalMemorySize() ** @@ -299,15 +329,20 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void) #elif defined(DARWIN) - struct host_basic_info hInfo; - mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; + struct host_basic_info_new hInfo; + mach_msg_type_number_t count = HOST_BASIC_INFO_NEW_COUNT; int result = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t) &hInfo, &count); - if (result == KERN_SUCCESS) - bytes = hInfo.max_mem; + if (result == KERN_SUCCESS) { + if (count >= HOST_BASIC_INFO_NEW_COUNT) { + bytes = hInfo.max_mem; + } else { + bytes = hInfo.memory_size; + } + } #elif defined(WIN32) diff --git a/pr/src/misc/prtime.c b/pr/src/misc/prtime.c index 5f05d5ef..42ab815b 100644 --- a/pr/src/misc/prtime.c +++ b/pr/src/misc/prtime.c @@ -50,10 +50,8 @@ #include #include - -#ifdef XP_MAC +#include /* for EINVAL */ #include -#endif /* * The COUNT_LEAPS macro counts the number of leap years passed by @@ -519,8 +517,6 @@ PR_NormalizeTime(PRExplodedTime *time, PRTimeParamFn params) *------------------------------------------------------------------------- */ -#include - #if defined(HAVE_INT_LOCALTIME_R) /* @@ -1573,6 +1569,12 @@ PR_ParseTimeStringToExplodedTime( result->tm_year = year; if (dotw != TT_UNKNOWN) result->tm_wday = (((int)dotw) - ((int)TT_SUN)); + /* + * Mainly to compute wday and yday, but normalized time is also required + * by the check below that works around a Visual C++ 2005 mktime problem. + */ + PR_NormalizeTime(result, PR_GMTParameters); + /* The remaining work is to set the gmt and dst offsets in tm_params. */ if (zone == TT_UNKNOWN && default_to_gmt) { @@ -1622,7 +1624,32 @@ PR_ParseTimeStringToExplodedTime( date you are handing it is in daylight savings mode or not; and if you're wrong, it will "fix" it for you. */ localTime.tm_isdst = -1; + +#if _MSC_VER == 1400 /* 1400 = Visual C++ 2005 (8.0) */ + /* + * mktime will return (time_t) -1 if the input is a date + * after 23:59:59, December 31, 3000, US Pacific Time (not + * UTC as documented): + * http://msdn.microsoft.com/en-us/library/d1y53h2a(VS.80).aspx + * But if the year is 3001, mktime also invokes the invalid + * parameter handler, causing the application to crash. This + * problem has been reported in + * http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=266036. + * We avoid this crash by not calling mktime if the date is + * out of range. To use a simple test that works in any time + * zone, we consider year 3000 out of range as well. (See + * bug 480740.) + */ + if (result->tm_year >= 3000) { + /* Emulate what mktime would have done. */ + errno = EINVAL; + secs = (time_t) -1; + } else { + secs = mktime(&localTime); + } +#else secs = mktime(&localTime); +#endif if (secs != (time_t) -1) { PRTime usecs64; @@ -1644,8 +1671,6 @@ PR_ParseTimeStringToExplodedTime( + 1440 * (localTime.tm_mday - 2); } - /* mainly to compute wday and yday */ - PR_NormalizeTime(result, PR_GMTParameters); result->tm_params.tp_gmt_offset = zone_offset * 60; result->tm_params.tp_dst_offset = dst_offset * 60; diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c index bd38d670..a78a62d2 100644 --- a/pr/src/pthreads/ptio.c +++ b/pr/src/pthreads/ptio.c @@ -1018,7 +1018,7 @@ static PRBool pt_hpux_sendfile_cont(pt_Continuation *op, PRInt16 revents) if (count < hdtrl[0].iov_len) { /* header not sent */ - hdtrl[0].iov_base = ((char *) hdtrl[0].iov_len) + count; + hdtrl[0].iov_base = ((char *) hdtrl[0].iov_base) + count; hdtrl[0].iov_len -= count; } else if (count < (hdtrl[0].iov_len + op->arg3.file_spec.nbytes)) { diff --git a/pr/src/pthreads/ptsynch.c b/pr/src/pthreads/ptsynch.c index 93b54880..eb2040b6 100644 --- a/pr/src/pthreads/ptsynch.c +++ b/pr/src/pthreads/ptsynch.c @@ -812,7 +812,7 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name) */ #if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) \ || defined(FREEBSD) || defined(OPENBSD) || defined(BSDI) \ - || defined(SYMBIAN) + || defined(DARWIN) || defined(SYMBIAN) /* union semun is defined by including */ #else /* according to X/OPEN we have to define it ourselves */ diff --git a/pr/tests/Makefile.in b/pr/tests/Makefile.in index c55acf23..d1bbc011 100644 --- a/pr/tests/Makefile.in +++ b/pr/tests/Makefile.in @@ -125,6 +125,7 @@ CSRCS = \ op_nofil.c \ openfile.c \ parent.c \ + parsetm.c \ peek.c \ perf.c \ pipeping.c \ diff --git a/pr/tests/parsetm.c b/pr/tests/parsetm.c new file mode 100644 index 00000000..24148286 --- /dev/null +++ b/pr/tests/parsetm.c @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape Portable Runtime (NSPR). + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * This test program should eventually become a full-blown test for + * PR_ParseTimeString. Right now it just verifies that PR_ParseTimeString + * doesn't crash on an out-of-range time string (bug 480740). + */ + +#include "prtime.h" + +#include +#include +#include +#include + +PRBool debug_mode = PR_TRUE; + +static char *dayOfWeek[] = + { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "???" }; +static char *month[] = + { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "???" }; + +static void PrintExplodedTime(const PRExplodedTime *et) { + PRInt32 totalOffset; + PRInt32 hourOffset, minOffset; + const char *sign; + + /* Print day of the week, month, day, hour, minute, and second */ + if (debug_mode) printf("%s %s %ld %02ld:%02ld:%02ld ", + dayOfWeek[et->tm_wday], month[et->tm_month], et->tm_mday, + et->tm_hour, et->tm_min, et->tm_sec); + + /* Print time zone */ + totalOffset = et->tm_params.tp_gmt_offset + et->tm_params.tp_dst_offset; + if (totalOffset == 0) { + if (debug_mode) printf("UTC "); + } else { + sign = "+"; + if (totalOffset < 0) { + totalOffset = -totalOffset; + sign = "-"; + } + hourOffset = totalOffset / 3600; + minOffset = (totalOffset % 3600) / 60; + if (debug_mode) + printf("%s%02ld%02ld ", sign, hourOffset, minOffset); + } + + /* Print year */ + if (debug_mode) printf("%hd", et->tm_year); +} + +int main(int argc, char **argv) +{ + PRTime ct; + PRExplodedTime et; + PRStatus rv; + char *sp1 = "Sat, 1 Jan 3001 00:00:00"; /* no time zone */ + char *sp2 = "Fri, 31 Dec 3000 23:59:60"; /* no time zone, not normalized */ + +#if _MSC_VER >= 1400 + /* Run this test in the US Pacific Time timezone. */ + _putenv_s("TZ", "PST8PDT"); + _tzset(); +#endif + + rv = PR_ParseTimeString(sp1, PR_FALSE, &ct); + printf("rv = %d\n", rv); + PR_ExplodeTime(ct, PR_GMTParameters, &et); + PrintExplodedTime(&et); + printf("\n"); + + rv = PR_ParseTimeString(sp2, PR_FALSE, &ct); + printf("rv = %d\n", rv); + PR_ExplodeTime(ct, PR_GMTParameters, &et); + PrintExplodedTime(&et); + printf("\n"); + + return 0; +} diff --git a/pr/tests/runtests.pl b/pr/tests/runtests.pl index 08088877..912c6301 100755 --- a/pr/tests/runtests.pl +++ b/pr/tests/runtests.pl @@ -333,6 +333,7 @@ $prog = shift; # Program to test "op_filok", "op_nofil", "parent", +"parsetm", "peek", "perf", "pipeping", diff --git a/pr/tests/runtests.sh b/pr/tests/runtests.sh index f9149481..a31b261e 100755 --- a/pr/tests/runtests.sh +++ b/pr/tests/runtests.sh @@ -161,6 +161,7 @@ op_filnf op_filok op_nofil parent +parsetm peek perf pipeping diff --git a/pr/tests/vercheck.c b/pr/tests/vercheck.c index 488ee574..84ddbe05 100644 --- a/pr/tests/vercheck.c +++ b/pr/tests/vercheck.c @@ -52,10 +52,10 @@ #include /* - * This release (4.7.4) is backward compatible with the + * This release (4.7.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, - * 4.7.1, 4.7.2, and 4.7.3 releases. It, of course, is - * compatible with itself. + * 4.7.1, 4.7.2, 4.7.3, 4.7.4, and 4.7.5 releases. It, + * of course, is compatible with itself. */ static char *compatible_version[] = { "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3", @@ -63,7 +63,7 @@ static char *compatible_version[] = { "4.5", "4.5.1", "4.6", "4.6.1", "4.6.2", "4.6.3", "4.6.4", "4.6.5", "4.6.6", "4.6.7", "4.6.8", - "4.7", "4.7.1", "4.7.2", "4.7.3", PR_VERSION + "4.7", "4.7.1", "4.7.2", "4.7.3", "4.7.4", "4.7.5", PR_VERSION }; /* -- cgit v1.2.1