Merged NSPR 4.0 release onto the main trunk. NSPRPUB_RELEASE_4_0_ON_MAIN_TRUNK
authorwtc%netscape.com
Fri, 03 Mar 2000 19:53:57 +0000
changeset 1218 dee3accd42500fa8e509d965322ebd2479874bda
parent 1216 8f70e0dbd9593a3d32ea785af7fc07f175a94681
child 1219 4faa2788fb1e9ce20222ceb4a206653657ed3882
push idunknown
push userunknown
push dateunknown
Merged NSPR 4.0 release onto the main trunk.
config/Linux.mk
pr/include/md/_aix32in6.cfg
pr/include/md/_aix64.cfg
pr/include/md/_beos.cfg
pr/include/md/_bsdi.cfg
pr/include/md/_darwin.cfg
pr/include/md/_freebsd.cfg
pr/include/md/_linux.h
pr/include/md/_netbsd.cfg
pr/include/md/_nto.cfg
pr/include/md/_openbsd.cfg
pr/include/md/_openvms.cfg
pr/include/md/_os2.cfg
pr/include/md/_rhapsody.cfg
pr/include/prio.h
pr/include/private/primpl.h
pr/src/misc/prnetdb.c
pr/tests/ipv6.c
--- a/config/Linux.mk
+++ b/config/Linux.mk
@@ -42,18 +42,16 @@ ifeq ($(CLASSIC_NSPR),1)
 IMPL_STRATEGY		= _EMU
 DEFINES			+= -D_PR_LOCAL_THREADS_ONLY
 else
 USE_PTHREADS		= 1
 IMPL_STRATEGY		= _PTH
 DEFINES			+= -D_REENTRANT
 endif
 
-USE_IPV6 = 1
-
 ifeq (86,$(findstring 86,$(OS_TEST)))
 CPU_ARCH		:= x86
 else
 ifeq (,$(filter-out armv4l sa110,$(OS_TEST)))
 CPU_ARCH		:= arm
 else
 CPU_ARCH		:= $(OS_TEST)
 endif
--- a/pr/include/md/_aix32in6.cfg
+++ b/pr/include/md/_aix32in6.cfg
@@ -68,19 +68,16 @@
 #define PR_ALIGN_OF_FLOAT   4
 #define PR_ALIGN_OF_DOUBLE  4
 #define PR_ALIGN_OF_POINTER 4
 
 #define	HAVE_LONG_LONG
 #undef	HAVE_ALIGNED_DOUBLES
 #undef	HAVE_ALIGNED_LONGLONGS
 
-#ifndef _PR_INET6
-#define _PR_INET6
-#endif
 #define PR_AF_INET6 24  /* same as AF_INET6 */
 
 #ifndef NO_NSPR_10_SUPPORT
 
 #define BYTES_PER_BYTE		PR_BYTES_PER_BYTE
 #define BYTES_PER_SHORT 	PR_BYTES_PER_SHORT
 #define BYTES_PER_INT 		PR_BYTES_PER_INT
 #define BYTES_PER_INT64		PR_BYTES_PER_INT64
--- a/pr/include/md/_aix64.cfg
+++ b/pr/include/md/_aix64.cfg
@@ -69,19 +69,16 @@
 #define PR_ALIGN_OF_FLOAT   4
 #define PR_ALIGN_OF_DOUBLE  4
 #define PR_ALIGN_OF_POINTER 8
 
 #define	HAVE_LONG_LONG
 #undef	HAVE_ALIGNED_DOUBLES
 #undef	HAVE_ALIGNED_LONGLONGS
 
-#ifndef _PR_INET6
-#define _PR_INET6
-#endif
 #define PR_AF_INET6 24  /* same as AF_INET6 */
 
 #ifndef NO_NSPR_10_SUPPORT
 
 #define BYTES_PER_BYTE		PR_BYTES_PER_BYTE
 #define BYTES_PER_SHORT 	PR_BYTES_PER_SHORT
 #define BYTES_PER_INT 		PR_BYTES_PER_INT
 #define BYTES_PER_INT64		PR_BYTES_PER_INT64
--- a/pr/include/md/_beos.cfg
+++ b/pr/include/md/_beos.cfg
@@ -22,16 +22,18 @@
 #define XP_BEOS
 #undef XP_UNIX
 #endif
 
 #ifndef BEOS
 #define BEOS
 #endif
 
+#define PR_AF_INET6 5  /* same as AF_INET6 */
+
 #ifdef __powerpc__
 #undef  IS_LITTLE_ENDIAN
 #define IS_BIG_ENDIAN 1
 #else
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
 #endif
 
--- a/pr/include/md/_bsdi.cfg
+++ b/pr/include/md/_bsdi.cfg
@@ -22,16 +22,18 @@
 #ifndef XP_UNIX
 #define XP_UNIX
 #endif
 
 #ifndef BSDI
 #define BSDI
 #endif
 
+#define PR_AF_INET6 24  /* same as AF_INET6 */
+
 #if defined(__i386__)
 
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
 #define HAVE_LONG_LONG
 #undef	HAVE_ALIGNED_DOUBLES
 #undef	HAVE_ALIGNED_LONGLONGS
 
--- a/pr/include/md/_darwin.cfg
+++ b/pr/include/md/_darwin.cfg
@@ -22,16 +22,18 @@
 #ifndef XP_UNIX
 #define XP_UNIX
 #endif
 
 #ifndef RHAPOSDY
 #define RHAPOSDY
 #endif
 
+#define PR_AF_INET6 30  /* same as AF_INET6 */
+
 #if defined(i386)
 #undef IS_BIG_ENDIAN
 #define  IS_LITTLE_ENDIAN 1
 #else
 #undef IS_LITTLE_ENDIAN
 #define  IS_BIG_ENDIAN 1
 #endif
 
--- a/pr/include/md/_freebsd.cfg
+++ b/pr/include/md/_freebsd.cfg
@@ -28,16 +28,18 @@
 #endif
 
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
 #define	HAVE_LONG_LONG
 #undef	HAVE_ALIGNED_DOUBLES
 #undef	HAVE_ALIGNED_LONGLONGS
 
+#define PR_AF_INET6 28  /* same as AF_INET6 */
+
 #if defined(__i386__)
 
 #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   4
 #define PR_BYTES_PER_FLOAT  4
--- a/pr/include/md/_linux.h
+++ b/pr/include/md/_linux.h
@@ -65,17 +65,18 @@
 #endif
 #undef _PR_USE_POLL
 #define _PR_STAT_HAS_ONLY_ST_ATIME
 #if defined(__alpha)
 #define _PR_HAVE_LARGE_OFF_T
 #else
 #define _PR_NO_LARGE_FILES
 #endif
-#ifdef _PR_INET6
+#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
+#define _PR_INET6
 #define _PR_HAVE_GETHOSTBYNAME2
 #define _PR_INET6_PROBE
 #endif
 #define _PR_HAVE_SYSV_SEMAPHORES
 #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
 
 #ifdef _PR_PTHREADS
 
@@ -92,21 +93,21 @@ extern void _MD_CleanupBeforeExit(void);
 
 #ifdef __powerpc__
 /*
  * PowerPC based MkLinux
  *
  * On the PowerPC, the new style jmp_buf isn't used until glibc
  * 2.1.
  */
-#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
+#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_GPR1]
 #else
 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__misc[0]
-#endif /* __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 */
+#endif /* glibc 2.1 or later */
 #define _MD_SET_FP(_t, val)
 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
 #define _MD_GET_FP_PTR(_t) ((void *) 0)
 /* aix = 64, macos = 70 */
 #define PR_NUM_GCREGS  64
 
 #elif defined(__alpha)
 /* Alpha based Linux */
--- a/pr/include/md/_netbsd.cfg
+++ b/pr/include/md/_netbsd.cfg
@@ -22,16 +22,18 @@
 #ifndef XP_UNIX
 #define XP_UNIX
 #endif
 
 #ifndef NETBSD
 #define NETBSD
 #endif
 
+#define PR_AF_INET6 24  /* same as AF_INET6 */
+
 #if defined(__i386__) || defined(__arm32__)
 
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
 #define	HAVE_LONG_LONG
 #undef	HAVE_ALIGNED_DOUBLES
 #undef	HAVE_ALIGNED_LONGLONGS
 
--- a/pr/include/md/_nto.cfg
+++ b/pr/include/md/_nto.cfg
@@ -22,16 +22,18 @@
 #ifndef XP_UNIX
 #define XP_UNIX
 #endif
 
 #ifndef NTO
 #define NTO
 #endif
 
+#define PR_AF_INET6 24  /* same as AF_INET6 */
+
 #ifdef __i386__
 
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
 
 #define PR_BYTES_PER_BYTE   1L
 #define PR_BYTES_PER_SHORT  2L
 #define PR_BYTES_PER_INT    4L
--- a/pr/include/md/_openbsd.cfg
+++ b/pr/include/md/_openbsd.cfg
@@ -22,16 +22,18 @@
 #ifndef XP_UNIX
 #define XP_UNIX
 #endif
 
 #ifndef OPENBSD
 #define OPENBSD
 #endif
 
+#define PR_AF_INET6 24  /* same as AF_INET6 */
+
 #if defined(__i386__) || defined(__arm32__)
 
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
 #define	HAVE_LONG_LONG
 #undef	HAVE_ALIGNED_DOUBLES
 #undef	HAVE_ALIGNED_LONGLONGS
 
--- a/pr/include/md/_openvms.cfg
+++ b/pr/include/md/_openvms.cfg
@@ -31,16 +31,18 @@
 #undef  IS_BIG_ENDIAN
 #define	HAVE_LONG_LONG
 #define HAVE_ALIGNED_DOUBLES
 #define HAVE_ALIGNED_LONGLONGS
 #ifdef IS_64
 #undef IS_64
 #endif
 
+#define PR_AF_INET6 26  /* same as AF_INET6 */
+
 #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   4
 #define PR_BYTES_PER_FLOAT  4
 #define PR_BYTES_PER_DOUBLE 8
 #define PR_BYTES_PER_WORD   4
--- a/pr/include/md/_os2.cfg
+++ b/pr/include/md/_os2.cfg
@@ -34,16 +34,18 @@
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
 #ifdef NO_LONG_LONG
 #undef HAVE_LONG_LONG
 #else
 #define HAVE_LONG_LONG 1
 #endif
 
+#define PR_AF_INET6 24  /* same as AF_INET6 */
+
 #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   4
 #define PR_BYTES_PER_FLOAT  4
 #define PR_BYTES_PER_DOUBLE 8
 #define PR_BYTES_PER_WORD       4
--- a/pr/include/md/_rhapsody.cfg
+++ b/pr/include/md/_rhapsody.cfg
@@ -22,16 +22,18 @@
 #ifndef XP_UNIX
 #define XP_UNIX
 #endif
 
 #ifndef RHAPOSDY
 #define RHAPOSDY
 #endif
 
+#define PR_AF_INET6 30  /* same as AF_INET6 */
+
 #if defined(i386)
 #undef IS_BIG_ENDIAN
 #define  IS_LITTLE_ENDIAN 1
 #else
 #undef IS_LITTLE_ENDIAN
 #define  IS_BIG_ENDIAN 1
 #endif
 
--- a/pr/include/prio.h
+++ b/pr/include/prio.h
@@ -174,44 +174,16 @@ union PRNetAddr {
     struct {                            /* Unix domain socket address */
         PRUint16 family;                /* address family (AF_UNIX) */
         char path[104];                 /* null-terminated pathname */
     } local;
 #endif
 };
 
 /*
-** The PR_NETADDR_SIZE macro can only be called on a PRNetAddr union
-** whose 'family' field is set.  It returns the size of the union
-** member corresponding to the specified address family.
-*/
-
-#if defined(_PR_INET6)
-
-#define PR_NETADDR_SIZE(_addr) PR_NetAddrSize(_addr)
-
-#else
-
-#if defined(XP_UNIX)
-#define PR_NETADDR_SIZE(_addr) 					\
-        ((_addr)->raw.family == PR_AF_INET		\
-        ? sizeof((_addr)->inet)					\
-        : ((_addr)->raw.family == PR_AF_INET6	\
-        ? sizeof((_addr)->ipv6)					\
-        : sizeof((_addr)->local)))
-#else
-#define PR_NETADDR_SIZE(_addr) 					\
-        ((_addr)->raw.family == PR_AF_INET		\
-        ? sizeof((_addr)->inet)					\
-        : sizeof((_addr)->ipv6))
-#endif /* defined(XP_UNIX) */
-
-#endif /* defined(_PR_INET6) */
-
-/*
 ***************************************************************************
 ** PRSockOption
 **
 ** The file descriptors can have predefined options set after they file
 ** descriptor is created to change their behavior. Only the options in
 ** the following enumeration are supported.
 ***************************************************************************
 */
@@ -1103,18 +1075,16 @@ NSPR_API(PRStatus) PR_MakeDir(const char
  *        If successful, will return a status of PR_SUCCESS. Otherwise
  *        a value of PR_FAILURE. The reason for the failure may be re-
  *        trieved using PR_GetError().
  **************************************************************************
  */
 
 NSPR_API(PRStatus) PR_RmDir(const char *name);
 
-NSPR_API(PRUintn) PR_NetAddrSize(const PRNetAddr* addr);
-
 /*
  *************************************************************************
  * FUNCTION: PR_NewUDPSocket
  * DESCRIPTION:
  *     Create a new UDP socket.
  * INPUTS:
  *     None
  * OUTPUTS:
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1263,16 +1263,46 @@ extern void _PR_Putfd(PRFileDesc *fd);
 extern PRIntn _PR_InvalidInt(void);
 extern PRInt16 _PR_InvalidInt16(void);
 extern PRInt64 _PR_InvalidInt64(void);
 extern PRStatus _PR_InvalidStatus(void);
 extern PRFileDesc *_PR_InvalidDesc(void);
 
 extern PRIOMethods _pr_faulty_methods;
 
+/*
+** The PR_NETADDR_SIZE macro can only be called on a PRNetAddr union
+** whose 'family' field is set.  It returns the size of the union
+** member corresponding to the specified address family.
+*/
+
+extern PRUintn _PR_NetAddrSize(const PRNetAddr* addr);
+
+#if defined(_PR_INET6)
+
+#define PR_NETADDR_SIZE(_addr) _PR_NetAddrSize(_addr)
+
+#else
+
+#if defined(XP_UNIX)
+#define PR_NETADDR_SIZE(_addr) 					\
+        ((_addr)->raw.family == PR_AF_INET		\
+        ? sizeof((_addr)->inet)					\
+        : ((_addr)->raw.family == PR_AF_INET6	\
+        ? sizeof((_addr)->ipv6)					\
+        : sizeof((_addr)->local)))
+#else
+#define PR_NETADDR_SIZE(_addr) 					\
+        ((_addr)->raw.family == PR_AF_INET		\
+        ? sizeof((_addr)->inet)					\
+        : sizeof((_addr)->ipv6))
+#endif /* defined(XP_UNIX) */
+
+#endif /* defined(_PR_INET6) */
+
 extern PRStatus _PR_MapOptionName(
     PRSockOption optname, PRInt32 *level, PRInt32 *name);
 extern void _PR_InitThreads(
     PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);
 
 struct PRLock {
 #if defined(_PR_PTHREADS)
     pthread_mutex_t mutex;          /* the underlying lock */
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -858,17 +858,17 @@ PR_IMPLEMENT(PRStatus) PR_GetProtoByNumb
         }
 		PR_Unlock(_getproto_lock);
 	}
 #endif  /* all that crap */
     return rv;
 
 }
 
-PR_IMPLEMENT(PRUintn) PR_NetAddrSize(const PRNetAddr* addr)
+PRUintn _PR_NetAddrSize(const PRNetAddr* addr)
 {
     PRUintn addrsize;
 
     /*
      * RFC 2553 added a new field (sin6_scope_id) to
      * struct sockaddr_in6.  PRNetAddr's ipv6 member has a
      * scope_id field to match the new field.  In order to
      * work with older implementations supporting RFC 2133,
@@ -885,17 +885,17 @@ PR_IMPLEMENT(PRUintn) PR_NetAddrSize(con
 #endif
 #if defined(XP_UNIX)
     else if (AF_UNIX == addr->raw.family)
         addrsize = sizeof(addr->local);
 #endif
     else addrsize = 0;
 
     return addrsize;
-}  /* PR_NetAddrSize */
+}  /* _PR_NetAddrSize */
 
 PR_IMPLEMENT(PRIntn) PR_EnumerateHostEnt(
     PRIntn enumIndex, const PRHostEnt *hostEnt, PRUint16 port, PRNetAddr *address)
 {
     void *addr = hostEnt->h_addr_list[enumIndex++];
     memset(address, 0, sizeof(PRNetAddr));
     if (NULL == addr) enumIndex = 0;
     else
--- a/pr/tests/ipv6.c
+++ b/pr/tests/ipv6.c
@@ -11,25 +11,16 @@
  * NPL.
  * 
  * The Initial Developer of this code under the NPL is Netscape
  * Communications Corporation.  Portions created by Netscape are
  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  * Reserved.
  */
 
-#ifdef XP_BEOS
-#include <stdio.h>
-int main()
-{
-    printf( "BeOS does not support IPv6\n" );
-    return 0;
-}
-#else
-
 #include "prio.h"
 #include "prenv.h"
 #include "prmem.h"
 #include "prlink.h"
 #include "prsystem.h"
 #include "prnetdb.h"
 #include "prprf.h"
 #include "prvrsion.h"
@@ -40,55 +31,58 @@ int main()
 
 #include <string.h>
 
 #define DNS_BUFFER 100
 #define ADDR_BUFFER 100
 #define HOST_BUFFER 1024
 #define PROTO_BUFFER 1500
 
+#define NETADDR_SIZE(addr) \
+    (PR_AF_INET == (addr)->raw.family ? \
+    sizeof((addr)->inet) : sizeof((addr)->ipv6))
+
 static PRFileDesc *err = NULL;
 
 static void Help(void)
 {
     PR_fprintf(err, "Usage: [-V] [-h]\n");
     PR_fprintf(err, "\t<nul>    Name of host to lookup          (default: self)\n");
     PR_fprintf(err, "\t-V       Display runtime version info    (default: FALSE)\n");
     PR_fprintf(err, "\t-h       This message and nothing else\n");
 }  /* Help */
 
 static void DumpAddr(const PRNetAddr* address, const char *msg)
 {
     PRUint32 *word = (PRUint32*)address;
     PRUint32 addr_len = sizeof(PRNetAddr);
-    PR_fprintf(err, "%s[%d]\t", msg, PR_NETADDR_SIZE(address));
+    PR_fprintf(err, "%s[%d]\t", msg, NETADDR_SIZE(address));
     while (addr_len > 0)
     {
         PR_fprintf(err, " %08x", *word++);
         addr_len -= sizeof(PRUint32);
     }
     PR_fprintf(err, "\n");
 }  /* DumpAddr */
 
 static PRStatus PrintAddress(const PRNetAddr* address)
 {
     PRNetAddr translation;
     char buffer[ADDR_BUFFER];
     PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer));
-    memset(&translation, 0, sizeof(PRNetAddr));
     if (PR_FAILURE == rv) PL_FPrintError(err, "PR_NetAddrToString");
     else
     {
         PR_fprintf(err, "\t%s\n", buffer);
         memset(&translation, 0, sizeof(translation));
         rv = PR_StringToNetAddr(buffer, &translation);
         if (PR_FAILURE == rv) PL_FPrintError(err, "PR_StringToNetAddr");
         else
         {
-            PRSize addr_len = PR_NETADDR_SIZE(address);
+            PRSize addr_len = NETADDR_SIZE(address);
             if (0 != memcmp(address, &translation, addr_len))
             {
                 PR_fprintf(err, "Address translations do not match\n");
                 DumpAddr(address, "original");
                 DumpAddr(&translation, "translate");
                 rv = PR_FAILURE;
             }
         }
@@ -97,17 +91,16 @@ static PRStatus PrintAddress(const PRNet
 }  /* PrintAddress */
 
 PRIntn main(PRIntn argc, char **argv)
 {
     PRStatus rv;
     PLOptStatus os;
     PRHostEnt host;
     PRProtoEnt proto;
-    PRBool ipv6 = PR_FALSE;
     const char *name = NULL;
     PRBool failed = PR_FALSE, version = PR_FALSE;
     PLOptState *opt = PL_CreateOptState(argc, argv, "Vh");
 
     err = PR_GetSpecialFD(PR_StandardError);
 
     while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
     {
@@ -125,22 +118,20 @@ PRIntn main(PRIntn argc, char **argv)
             Help();  /* so give him an earful */
             return 2;  /* but not a lot else */
         }
     }
     PL_DestroyOptState(opt);
 
     if (version)
     {
-#if defined(XP_UNIX) || defined(XP_OS2)
-#define NSPR_LIB "nspr21"
-#elif defined(WIN32)
-#define NSPR_LIB "libnspr21"
+#if defined(WINNT)
+#define NSPR_LIB "libnspr4"
 #else
-#error "Architecture not supported"
+#define NSPR_LIB "nspr4"
 #endif
         const PRVersionDescription *version_info;
         char *nspr_path = PR_GetEnv("LD_LIBRARY_PATH");
         char *nspr_name = PR_GetLibraryName(nspr_path, NSPR_LIB);
         PRLibrary *runtime = PR_LoadLibrary(nspr_name);
         if (NULL == runtime)
             PL_FPrintError(err, "PR_LoadLibrary");
         else
@@ -231,10 +222,8 @@ PRIntn main(PRIntn argc, char **argv)
         ** Get Proto by name/number
         */
         rv = PR_GetProtoByName("tcp", &buffer[1], sizeof(buffer) - 1, &proto);
         rv = PR_GetProtoByNumber(6, &buffer[3], sizeof(buffer) - 3, &proto);
     }
 
     return (failed) ? 1 : 0;
 }
-
-#endif /* XP_BEOS */