Import NSPR_4_7_2_BETA4.
authorWan-Teh Chang <wtc@google.com>
Sat, 11 Oct 2008 10:46:10 -0700
changeset 20313 16151b2231261ad5c80e292752fcd2c7043bbaf3
parent 20312 09fcb1bab6ebb3393ab648c608b855d0c646d2b2
child 20314 1d719b91762901ab5ba99662bb8bff52c3a2cc67
push id2798
push userwtc@google.com
push dateSat, 11 Oct 2008 17:46:16 +0000
treeherdermozilla-central@16151b223126 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1b2pre
Import NSPR_4_7_2_BETA4.
nsprpub/configure
nsprpub/pr/include/md/_linux.cfg
nsprpub/pr/include/md/_linux.h
nsprpub/pr/include/prinit.h
nsprpub/pr/src/md/unix/uxrng.c
nsprpub/pr/src/misc/prsystem.c
nsprpub/pr/src/misc/prtime.c
--- a/nsprpub/configure
+++ b/nsprpub/configure
@@ -6011,17 +6011,17 @@ trap 'rm -f $CONFIG_STATUS conftest*; ex
 # Protect against Makefile macro expansion.
 cat > conftest.defs <<\EOF
 s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
 s%[ 	`~#$^&*(){}\\|;'"<>?]%\\&%g
 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
 
 
 # Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
 
 echo creating $CONFIG_STATUS
 rm -f $CONFIG_STATUS
--- a/nsprpub/pr/include/md/_linux.cfg
+++ b/nsprpub/pr/include/md/_linux.cfg
@@ -326,16 +326,62 @@
 #define PR_ALIGN_OF_FLOAT   2
 #define PR_ALIGN_OF_DOUBLE  2
 #define PR_ALIGN_OF_POINTER 2
 #define PR_ALIGN_OF_WORD    2
 
 #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
 #define	IS_BIG_ENDIAN 1
 
 #define PR_BYTES_PER_BYTE   1
 #define PR_BYTES_PER_SHORT  2
 #define PR_BYTES_PER_INT    4
--- a/nsprpub/pr/include/md/_linux.h
+++ b/nsprpub/pr/include/md/_linux.h
@@ -58,16 +58,18 @@
 #elif defined(__alpha)
 #define _PR_SI_ARCHITECTURE "alpha"
 #elif defined(__ia64__)
 #define _PR_SI_ARCHITECTURE "ia64"
 #elif defined(__x86_64__)
 #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__)
 #define _PR_SI_ARCHITECTURE "x86"
 #elif defined(__mips__)
 #define _PR_SI_ARCHITECTURE "mips"
 #elif defined(__arm__)
 #define _PR_SI_ARCHITECTURE "arm"
--- a/nsprpub/pr/include/prinit.h
+++ b/nsprpub/pr/include/prinit.h
@@ -58,17 +58,17 @@ PR_BEGIN_EXTERN_C
 /*
 ** NSPR's version is used to determine the likelihood that the version you
 ** used to build your component is anywhere close to being compatible with
 ** what is in the underlying library.
 **
 ** The format of the version string is
 **     "<major version>.<minor version>[.<patch level>] [<Beta>]"
 */
-#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
 #define PR_BETA     PR_TRUE
 
 /*
 ** PRVersionCheck
 **
--- a/nsprpub/pr/src/md/unix/uxrng.c
+++ b/nsprpub/pr/src/md/unix/uxrng.c
@@ -140,49 +140,49 @@ GetHighResClock(void *buf, size_t maxbyt
 
 #elif (defined(LINUX) || defined(FREEBSD) || defined(__FreeBSD_kernel__) \
     || defined(NETBSD) || defined(__NetBSD_kernel__) || defined(OPENBSD) \
     || defined(SYMBIAN))
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
-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)
 
 static size_t
 GetHighResClock(void *buf, size_t maxbytes)
 {
     return 0;
--- a/nsprpub/pr/src/misc/prsystem.c
+++ b/nsprpub/pr/src/misc/prsystem.c
@@ -295,24 +295,24 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMem
     struct pst_static info;
     int result = pstat_getstatic(&info, sizeof(info), 1, 0);
     if (result == 1)
         bytes = (PRUint64) info.physical_memory * info.page_size;
 
 #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)
 
     /* Try to use the newer GlobalMemoryStatusEx API for Windows 2000+. */
     GlobalMemoryStatusExFn globalMemory = (GlobalMemoryStatusExFn) NULL;
     HMODULE module = GetModuleHandle("kernel32.dll");
 
     if (module) {
--- a/nsprpub/pr/src/misc/prtime.c
+++ b/nsprpub/pr/src/misc/prtime.c
@@ -1691,16 +1691,17 @@ PR_ParseTimeString(
  *     Format a time value into a buffer. Same semantics as strftime().
  *
  *-----------------------------------------------------------------------
  */
 
 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;
     a.tm_hour = tm->tm_hour;
     a.tm_mday = tm->tm_mday;
     a.tm_mon = tm->tm_month;
     a.tm_wday = tm->tm_wday;
     a.tm_year = tm->tm_year - 1900;
@@ -1714,17 +1715,26 @@ PR_FormatTime(char *buf, int buflen, con
 
 #if defined(SUNOS4) || (__GLIBC__ >= 2) || defined(XP_BEOS) \
         || defined(NETBSD) || defined(OPENBSD) || defined(FREEBSD) \
         || defined(DARWIN) || defined(SYMBIAN)
     a.tm_zone = NULL;
     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;
 }
 
 
 /*
  * The following string arrays and macros are used by PR_FormatTimeUSEnglish().
  */
 
 static const char* abbrevDays[] =