From 2c5ff6c233f07f200f174b792db2cf3978542045 Mon Sep 17 00:00:00 2001 From: Wan-Teh Chang Date: Sat, 11 Oct 2008 10:46:10 -0700 Subject: [PATCH] Import NSPR_4_7_2_BETA4. --- nsprpub/configure | 2 +- nsprpub/pr/include/md/_linux.cfg | 46 ++++++++++++++++++++++++++++++++ nsprpub/pr/include/md/_linux.h | 2 ++ nsprpub/pr/include/prinit.h | 2 +- nsprpub/pr/src/md/unix/uxrng.c | 22 +++++++-------- nsprpub/pr/src/misc/prsystem.c | 4 +-- nsprpub/pr/src/misc/prtime.c | 12 ++++++++- 7 files changed, 74 insertions(+), 16 deletions(-) diff --git a/nsprpub/configure b/nsprpub/configure index 3d28c860ca4..65000d7401a 100755 --- a/nsprpub/configure +++ b/nsprpub/configure @@ -6016,7 +6016,7 @@ s%\[%\\&%g s%\]%\\&%g s%\$%$$%g EOF -DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' ' | tr '\015' ' '` rm -f conftest.defs diff --git a/nsprpub/pr/include/md/_linux.cfg b/nsprpub/pr/include/md/_linux.cfg index d02ab21f0c2..1999d3cf90f 100644 --- a/nsprpub/pr/include/md/_linux.cfg +++ b/nsprpub/pr/include/md/_linux.cfg @@ -331,6 +331,52 @@ #define PR_BYTES_PER_WORD_LOG2 2 #define PR_BYTES_PER_DWORD_LOG2 3 +#elif defined(__sparc__) && defined (__arch64__) + +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 +#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_INT64 8 +#define PR_ALIGN_OF_LONG 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(__sparc__) #undef IS_LITTLE_ENDIAN diff --git a/nsprpub/pr/include/md/_linux.h b/nsprpub/pr/include/md/_linux.h index 583997165af..33fc132537b 100644 --- a/nsprpub/pr/include/md/_linux.h +++ b/nsprpub/pr/include/md/_linux.h @@ -63,6 +63,8 @@ #define _PR_SI_ARCHITECTURE "x86-64" #elif defined(__mc68000__) #define _PR_SI_ARCHITECTURE "m68k" +#elif defined(__sparc__) && defined(__arch64__) +#define _PR_SI_ARCHITECTURE "sparc64" #elif defined(__sparc__) #define _PR_SI_ARCHITECTURE "sparc" #elif defined(__i386__) diff --git a/nsprpub/pr/include/prinit.h b/nsprpub/pr/include/prinit.h index 1ac35bcfc58..bc9eae57cf0 100644 --- a/nsprpub/pr/include/prinit.h +++ b/nsprpub/pr/include/prinit.h @@ -63,7 +63,7 @@ PR_BEGIN_EXTERN_C ** The format of the version string is ** ".[.] []" */ -#define PR_VERSION "4.7.2 Beta 3" +#define PR_VERSION "4.7.2 Beta 4" #define PR_VMAJOR 4 #define PR_VMINOR 7 #define PR_VPATCH 2 diff --git a/nsprpub/pr/src/md/unix/uxrng.c b/nsprpub/pr/src/md/unix/uxrng.c index a5355fdf9f9..86f0782514a 100644 --- a/nsprpub/pr/src/md/unix/uxrng.c +++ b/nsprpub/pr/src/md/unix/uxrng.c @@ -145,39 +145,39 @@ GetHighResClock(void *buf, size_t maxbytes) #include #include -static int fdDevRandom; -static PRCallOnceType coOpenDevRandom; +static int fdDevURandom; +static PRCallOnceType coOpenDevURandom; -static PRStatus OpenDevRandom( void ) +static PRStatus OpenDevURandom( void ) { - fdDevRandom = open( "/dev/random", O_RDONLY ); - return((-1 == fdDevRandom)? PR_FAILURE : PR_SUCCESS ); -} /* end OpenDevRandom() */ + fdDevURandom = open( "/dev/urandom", O_RDONLY ); + return((-1 == fdDevURandom)? PR_FAILURE : PR_SUCCESS ); +} /* end OpenDevURandom() */ -static size_t GetDevRandom( void *buf, size_t size ) +static size_t GetDevURandom( void *buf, size_t size ) { int bytesIn; int rc; - rc = PR_CallOnce( &coOpenDevRandom, OpenDevRandom ); + rc = PR_CallOnce( &coOpenDevURandom, OpenDevURandom ); if ( PR_FAILURE == rc ) { _PR_MD_MAP_OPEN_ERROR( errno ); return(0); } - bytesIn = read( fdDevRandom, buf, size ); + bytesIn = read( fdDevURandom, buf, size ); if ( -1 == bytesIn ) { _PR_MD_MAP_READ_ERROR( errno ); return(0); } return( bytesIn ); -} /* end GetDevRandom() */ +} /* end GetDevURandom() */ static size_t GetHighResClock(void *buf, size_t maxbytes) { - return(GetDevRandom( buf, maxbytes )); + return(GetDevURandom( buf, maxbytes )); } #elif defined(NCR) diff --git a/nsprpub/pr/src/misc/prsystem.c b/nsprpub/pr/src/misc/prsystem.c index 8ccdff84098..f3542a5024c 100644 --- a/nsprpub/pr/src/misc/prsystem.c +++ b/nsprpub/pr/src/misc/prsystem.c @@ -300,14 +300,14 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void) #elif defined(DARWIN) struct host_basic_info hInfo; - mach_msg_type_number_t count; + mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; int result = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t) &hInfo, &count); if (result == KERN_SUCCESS) - bytes = hInfo.memory_size; + bytes = hInfo.max_mem; #elif defined(WIN32) diff --git a/nsprpub/pr/src/misc/prtime.c b/nsprpub/pr/src/misc/prtime.c index 3ac27afa488..d73b08cdeae 100644 --- a/nsprpub/pr/src/misc/prtime.c +++ b/nsprpub/pr/src/misc/prtime.c @@ -1696,6 +1696,7 @@ PR_ParseTimeString( PR_IMPLEMENT(PRUint32) PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm) { + size_t rv; struct tm a; a.tm_sec = tm->tm_sec; a.tm_min = tm->tm_min; @@ -1719,7 +1720,16 @@ PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm) a.tm_gmtoff = tm->tm_params.tp_gmt_offset + tm->tm_params.tp_dst_offset; #endif - return strftime(buf, buflen, fmt, &a); + rv = strftime(buf, buflen, fmt, &a); + if (!rv && buf && buflen > 0) { + /* + * When strftime fails, the contents of buf are indeterminate. + * Some callers don't check the return value from this function, + * so store an empty string in buf in case they try to print it. + */ + buf[0] = '\0'; + } + return rv; }