#239663 NSPRPUB_PRE_4_2_CLIENT_BRANCH
authormkaply%us.ibm.com
Mon, 19 Apr 2004 16:28:00 +0000
branchNSPRPUB_PRE_4_2_CLIENT_BRANCH
changeset 3090 746d6f50054486cf644cd4cd27245912d993f91f
parent 3089 27c9b3e4e7123ad561dd9f64ee92ab77820517ba
child 3093 ac7a25dd4c559708474451bb4774a34a2bafde0e
push idunknown
push userunknown
push dateunknown
bugs239663
#239663 r=mkaply, sr=blizzard (platform specific) OS/2 only - bring back VACPP support for NSPR and DBM mainly so VACPP can still be used with NSS
config/rules.mk
configure.in
pr/include/md/_os2.h
pr/include/md/_os2_errors.h
pr/include/prio.h
pr/include/private/primpl.h
pr/include/prtypes.h
pr/src/io/prsocket.c
pr/src/md/os2/os2_errors.c
pr/src/md/os2/os2sock.c
pr/src/md/os2/os2thred.c
pr/src/misc/prnetdb.c
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -373,21 +373,26 @@ ifeq ($(OS_ARCH),SunOS)
 	sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@
 endif
 ifeq ($(OS_ARCH),OS2)
 	echo LIBRARY $(LIBRARY_NAME)$(LIBRARY_VERSION) INITINSTANCE TERMINSTANCE > $@
 	echo PROTMODE >> $@
 	echo CODE    LOADONCALL MOVEABLE DISCARDABLE >> $@
 	echo DATA    PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@
 	echo EXPORTS >> $@
+ifeq ($(MOZ_OS2_TOOLS),VACPP)
+	grep -v ';+' $< | grep -v ';-' | \
+	sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' >> $@
+else
 	grep -v ';+' $< | grep -v ';-' | \
 	sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,\([\t ]*\),\1_,' | \
 	awk 'BEGIN {ord=1;} { print($$0 " @" ord " RESIDENTNAME"); ord++;}'	>> $@
 	$(ADD_TO_DEF_FILE)
 endif
+endif
 
 #
 # Translate source filenames to absolute paths. This is required for
 # debuggers under Windows and OS/2 to find source files automatically.
 #
 
 ifeq ($(OS_ARCH),OS2)
 NEED_ABSOLUTE_PATH = 1
--- a/configure.in
+++ b/configure.in
@@ -1784,16 +1784,18 @@ mips-sony-newsos*)
     PR_MD_CSRCS=unixware.c
     DSO_LDOPTS=-G
     CPU_ARCH=x86
     ;;
 
 *-os2*)
     AC_DEFINE(XP_OS2)
     AC_DEFINE(XP_PC)
+    AC_DEFINE(BSD_SELECT)
+    AC_DEFINE(TCPV40HDRS)
     LIB_SUFFIX=lib
     DLL_SUFFIX=dll
     RC=rc.exe
     PR_MD_ARCH_DIR=os2
     PROG_SUFFIX=.exe
     NSINSTALL=nsinstall
     MDCPUCFG_H=_os2.cfg
     RESOLVE_LINK_SYMBOLS=1
--- a/pr/include/md/_os2.h
+++ b/pr/include/md/_os2.h
@@ -237,19 +237,16 @@ extern PRInt32 _MD_CloseFile(PRInt32 osf
 #define _MD_MAKE_DIR                  (_PR_MD_MKDIR)
 #define _MD_RMDIR                     (_PR_MD_RMDIR)
 #define _MD_LOCKFILE                  (_PR_MD_LOCKFILE)
 #define _MD_TLOCKFILE                 (_PR_MD_TLOCKFILE)
 #define _MD_UNLOCKFILE                (_PR_MD_UNLOCKFILE)
 
 /* --- Socket IO stuff --- */
 
-#define TCPV40HDRS
-#define BSD_SELECT
-
 /* The ones that don't map directly may need to be re-visited... */
 #ifdef XP_OS2_VACPP
 #define EPIPE                     EBADF
 #define EIO                       ECONNREFUSED
 #endif
 #define _MD_EACCES                EACCES
 #define _MD_EADDRINUSE            EADDRINUSE
 #define _MD_EADDRNOTAVAIL         EADDRNOTAVAIL
@@ -281,17 +278,21 @@ extern void _MD_MakeNonblock(PRFileDesc 
 #define _MD_INIT_FD_INHERITABLE       (_PR_MD_INIT_FD_INHERITABLE)
 #define _MD_QUERY_FD_INHERITABLE      (_PR_MD_QUERY_FD_INHERITABLE)
 #define _MD_SHUTDOWN                  (_PR_MD_SHUTDOWN)
 #define _MD_LISTEN                    _PR_MD_LISTEN
 extern PRInt32 _MD_CloseSocket(PRInt32 osfd);
 #define _MD_CLOSE_SOCKET              _MD_CloseSocket
 #define _MD_SENDTO                    (_PR_MD_SENDTO)
 #define _MD_RECVFROM                  (_PR_MD_RECVFROM)
+#ifdef XP_OS2_VACPP
+#define _MD_SOCKETPAIR(s, type, proto, sv) -1
+#else
 #define _MD_SOCKETPAIR                (_PR_MD_SOCKETPAIR)
+#endif
 #define _MD_GETSOCKNAME               (_PR_MD_GETSOCKNAME)
 #define _MD_GETPEERNAME               (_PR_MD_GETPEERNAME)
 #define _MD_GETSOCKOPT                (_PR_MD_GETSOCKOPT)
 #define _MD_SETSOCKOPT                (_PR_MD_SETSOCKOPT)
 
 #define _MD_FSYNC                     _PR_MD_FSYNC
 #define _MD_SET_FD_INHERITABLE        (_PR_MD_SET_FD_INHERITABLE)
 
--- a/pr/include/md/_os2_errors.h
+++ b/pr/include/md/_os2_errors.h
@@ -122,18 +122,20 @@ NSPR_API(void) _MD_os2_map_bind_error(PR
 #define	_PR_MD_MAP_BIND_ERROR	_MD_os2_map_bind_error
 
 NSPR_API(void) _MD_os2_map_listen_error(PRInt32 err);
 #define	_PR_MD_MAP_LISTEN_ERROR	_MD_os2_map_listen_error
 
 NSPR_API(void) _MD_os2_map_shutdown_error(PRInt32 err);
 #define	_PR_MD_MAP_SHUTDOWN_ERROR	_MD_os2_map_shutdown_error
 
+#ifndef XP_OS2_VACPP
 NSPR_API(void) _MD_os2_map_socketpair_error(int err);
 #define	_PR_MD_MAP_SOCKETPAIR_ERROR	_MD_os2_map_socketpair_error
+#endif
 
 NSPR_API(void) _MD_os2_map_getsockname_error(PRInt32 err);
 #define	_PR_MD_MAP_GETSOCKNAME_ERROR	_MD_os2_map_getsockname_error
 
 NSPR_API(void) _MD_os2_map_getpeername_error(PRInt32 err);
 #define	_PR_MD_MAP_GETPEERNAME_ERROR	_MD_os2_map_getpeername_error
 
 NSPR_API(void) _MD_os2_map_getsockopt_error(PRInt32 err);
--- a/pr/include/prio.h
+++ b/pr/include/prio.h
@@ -189,17 +189,17 @@ union PRNetAddr {
     } inet;
     struct {
         PRUint16 family;                /* address family (AF_INET6) */
         PRUint16 port;                  /* port number */
         PRUint32 flowinfo;              /* routing information */
         PRIPv6Addr ip;                  /* the actual 128 bits of address */
         PRUint32 scope_id;              /* set of interfaces for a scope */
     } ipv6;
-#if defined(XP_UNIX) || defined(XP_OS2)
+#if defined(XP_UNIX) || defined(XP_OS2_EMX)
     struct {                            /* Unix domain socket address */
         PRUint16 family;                /* address family (AF_UNIX) */
 #ifdef XP_OS2
         char path[108];                 /* null-terminated pathname */
                                         /* bind fails if size is not 108. */
 #else
         char path[104];                 /* null-terminated pathname */
 #endif
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1390,33 +1390,33 @@ extern PRUintn _PR_NetAddrSize(const PRN
 ** EINVAL.
 **
 ** To pass the correct socket address length to socket
 ** functions, define the macro _PR_HAVE_MD_SOCKADDR_IN6 and
 ** define struct _md_sockaddr_in6 to be isomorphic to
 ** struct sockaddr_in6.
 */
 
-#if defined(XP_UNIX) || defined(XP_OS2)
+#if defined(XP_UNIX) || defined(XP_OS2_EMX)
 #define PR_NETADDR_SIZE(_addr) 					\
         ((_addr)->raw.family == PR_AF_INET		\
         ? sizeof((_addr)->inet)					\
         : ((_addr)->raw.family == PR_AF_INET6	\
         ? sizeof(struct _md_sockaddr_in6)		\
         : sizeof((_addr)->local)))
 #else
 #define PR_NETADDR_SIZE(_addr) 					\
         ((_addr)->raw.family == PR_AF_INET		\
         ? sizeof((_addr)->inet)					\
         : sizeof(struct _md_sockaddr_in6)
 #endif /* defined(XP_UNIX) */
 
 #else
 
-#if defined(XP_UNIX) || defined(XP_OS2)
+#if defined(XP_UNIX) || defined(XP_OS2_EMX)
 #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) 					\
--- a/pr/include/prtypes.h
+++ b/pr/include/prtypes.h
@@ -153,16 +153,31 @@
 #define PR_IMPLEMENT(__type) __declspec(export) __type
 #define PR_EXTERN_DATA(__type) extern __declspec(export) __type
 #define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
 
 #define PR_CALLBACK
 #define PR_CALLBACK_DECL
 #define PR_STATIC_CALLBACK(__x) static __x
 
+#elif defined(XP_OS2_VACPP) 
+
+#define PR_EXPORT(__type) extern __type
+#define PR_EXPORT_DATA(__type) extern __type
+#define PR_IMPORT(__type) extern __type
+#define PR_IMPORT_DATA(__type) extern __type
+
+#define PR_EXTERN(__type) extern __type
+#define PR_IMPLEMENT(__type) __type
+#define PR_EXTERN_DATA(__type) extern __type
+#define PR_IMPLEMENT_DATA(__type) __type
+#define PR_CALLBACK _Optlink
+#define PR_CALLBACK_DECL
+#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
+
 #else /* Unix */
 
 #define PR_EXPORT(__type) extern __type
 #define PR_EXPORT_DATA(__type) extern __type
 #define PR_IMPORT(__type) extern __type
 #define PR_IMPORT_DATA(__type) extern __type
 
 #define PR_EXTERN(__type) extern __type
--- a/pr/src/io/prsocket.c
+++ b/pr/src/io/prsocket.c
@@ -39,34 +39,34 @@
 /************************************************************************/
 
 /* These two functions are only used in assertions. */
 #if defined(DEBUG)
 
 PRBool IsValidNetAddr(const PRNetAddr *addr)
 {
     if ((addr != NULL)
-#if defined(XP_UNIX) || defined(XP_OS2)
+#if defined(XP_UNIX) || defined(XP_OS2_EMX)
 	    && (addr->raw.family != PR_AF_LOCAL)
 #endif
 	    && (addr->raw.family != PR_AF_INET6)
 	    && (addr->raw.family != PR_AF_INET)) {
         return PR_FALSE;
     }
     return PR_TRUE;
 }
 
 static PRBool IsValidNetAddrLen(const PRNetAddr *addr, PRInt32 addr_len)
 {
     /*
      * The definition of the length of a Unix domain socket address
      * is not uniform, so we don't check it.
      */
     if ((addr != NULL)
-#if defined(XP_UNIX) || defined(XP_OS2)
+#if defined(XP_UNIX) || defined(XP_OS2_EMX)
             && (addr->raw.family != AF_UNIX)
 #endif
             && (PR_NETADDR_SIZE(addr) != addr_len)) {
 #if defined(LINUX) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 1
         /*
          * In glibc 2.1, struct sockaddr_in6 is 24 bytes.  In glibc 2.2
          * and in the 2.4 kernel, struct sockaddr_in6 has the scope_id
          * field and is 28 bytes.  It is possible for socket functions
@@ -1268,17 +1268,17 @@ PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRIn
 {
 	PRInt32 osfd;
 	PRFileDesc *fd;
 	PRInt32 tmp_domain = domain;
 
 	if (!_pr_initialized) _PR_ImplicitInitialization();
 	if (PR_AF_INET != domain
 			&& PR_AF_INET6 != domain
-#if defined(XP_UNIX) || defined(XP_OS2)
+#if defined(XP_UNIX) || defined(XP_OS2_EMX)
 			&& PR_AF_LOCAL != domain
 #endif
 			) {
 		PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);
 		return NULL;
 	}
 
 #if defined(_PR_INET6_PROBE)
--- a/pr/src/md/os2/os2_errors.c
+++ b/pr/src/md/os2/os2_errors.c
@@ -870,16 +870,17 @@ void _MD_os2_map_shutdown_error(PRInt32 
 			PR_SetError(PR_NOT_CONNECTED_ERROR, err);
 			break;
 		default:
 			PR_SetError(PR_UNKNOWN_ERROR, err);
 			break;
 	}
 }
 
+#ifndef XP_OS2_VACPP
 void _MD_os2_map_socketpair_error(PRInt32 err)
 {
   switch (err) {
     case ENOMEM:
       PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
       break;
     case EAFNOSUPPORT:
       PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err);
@@ -893,16 +894,17 @@ void _MD_os2_map_socketpair_error(PRInt3
     case EPROTOTYPE:
       PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err);
       break;
     default:
       _MD_os2_map_default_error(err);
       return;
   }
 }
+#endif
 
 void _MD_os2_map_getsockname_error(PRInt32 err)
 {
 	switch (err) {
 		case EBADF:
 			PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
 			break;
 		case ENOTSOCK:
--- a/pr/src/md/os2/os2sock.c
+++ b/pr/src/md/os2/os2sock.c
@@ -48,16 +48,24 @@
 #ifdef XP_OS2_EMX
  #include <sys/time.h> /* For timeval. */
 #endif
 
 #define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5
 #define READ_FD   1
 #define WRITE_FD  2
 
+#ifdef XP_OS2_VACPP
+#define _OS2_WRITEV writev
+#define _OS2_IOCTL ioctl
+#else
+#define _OS2_WRITEV so_writev
+#define _OS2_IOCTL so_ioctl
+#endif
+
 void
 _PR_MD_INIT_IO()
 {
     sock_init();
 }
 
 /* --- SOCKET IO --------------------------------------------------------- */
 
@@ -95,17 +103,17 @@ PRInt32
     return rv;
 }
 
 PRInt32
 _MD_SocketAvailable(PRFileDesc *fd)
 {
     PRInt32 result;
 
-    if (so_ioctl(fd->secret->md.osfd, FIONREAD, (char *) &result, sizeof(result)) < 0) {
+    if (_OS2_IOCTL(fd->secret->md.osfd, FIONREAD, (char *) &result, sizeof(result)) < 0) {
         PR_SetError(PR_BAD_DESCRIPTOR_ERROR, sock_errno());
         return -1;
     }
     return result;
 }
 
 static PRInt32
 socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout )
@@ -534,17 +542,17 @@ PRInt32
       * 3)
       */
     if (!fd->secret->nonblocking) {
         for (index=0; index<iov_size; index++) {
             amount += iov[index].iov_len;
         }
     }
 
-    while ((rv = so_writev(osfd, (const struct iovec*)iov, iov_size)) == -1) {
+    while ((rv = _OS2_WRITEV(osfd, (const struct iovec*)iov, iov_size)) == -1) {
         err = sock_errno();
         if ((err == EWOULDBLOCK))    {
             if (fd->secret->nonblocking) {
                 break;
             }
             if ((rv = socket_io_wait(osfd, WRITE_FD, timeout))<0)
                 goto done;
         } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
@@ -579,29 +587,30 @@ PRInt32
     PRInt32 rv;
 
     rv = shutdown(fd->secret->md.osfd, how);
     if (rv < 0)
         _PR_MD_MAP_SHUTDOWN_ERROR(sock_errno());
     return rv;
 }
 
+#ifndef XP_OS2_VACPP
 PRInt32
 _PR_MD_SOCKETPAIR(int af, int type, int flags, PRInt32 *osfd)
 {
     PRInt32 rv, err;
 
     rv = socketpair(af, type, flags, osfd);
     if (rv < 0) {
         err = _MD_ERRNO();
         _PR_MD_MAP_SOCKETPAIR_ERROR(err);
     }
     return rv;
 }
-
+#endif
 
 PRStatus
 _PR_MD_GETSOCKNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen)
 {
     PRInt32 rv, err;
 
     rv = getsockname(fd->secret->md.osfd,
                      (struct sockaddr *) addr, (int *)addrlen);
@@ -661,15 +670,15 @@ void
     PRInt32 err;
     PRUint32  one = 1;
     
     if (osfd <= 2) {
         /* Don't mess around with stdin, stdout or stderr */
         return;
     }
 
-    err = so_ioctl( osfd, FIONBIO, (char *) &one, sizeof(one));
+    err = _OS2_IOCTL( osfd, FIONBIO, (char *) &one, sizeof(one));
     if ( err != 0 )
     {
         err = sock_errno();
         _PR_MD_MAP_SOCKET_ERROR(err);
     }
 }
--- a/pr/src/md/os2/os2thred.c
+++ b/pr/src/md/os2/os2thred.c
@@ -215,20 +215,28 @@ PRStatus
                   PRThreadPriority priority, 
                   PRThreadScope scope, 
                   PRThreadState state, 
                   PRUint32 stackSize)
 {
     PARAMSTORE* params = PR_Malloc(sizeof(PARAMSTORE));
     params->start = start;
     params->thread = thread;
+#ifdef XP_OS2_VACPP /* No exception handler for VACPP */
+    thread->md.handle = thread->id = (TID) _beginthread(
+                    (void(* _Optlink)(void*))start,
+                    NULL, 
+                    thread->stack->stackSize,
+                    thread);
+#else
     thread->md.handle = thread->id = (TID) _beginthread(ExcpStartFunc,
                                                         NULL, 
                                                         thread->stack->stackSize,
                                                         params);
+#endif
     if(thread->md.handle == -1) {
         return PR_FAILURE;
     }
 
     /*
      * On OS/2, a thread is created with a thread priority of
      * THREAD_PRIORITY_NORMAL
      */
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -688,17 +688,17 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByName(
     }
 #endif
 
 	LOCK_DNS();
 
 #ifdef XP_OS2_VACPP
 	h = GETHOSTBYNAME((char *)name);
 #else
-    h = GETHOSTBYNAME(name);
+	h = GETHOSTBYNAME(name);
 #endif
     
 	if (NULL == h)
 	{
 	    PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());
 	}
 	else
 	{
@@ -919,17 +919,17 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByNam
     else
     {
         LOCK_DNS();
     	h = GETHOSTBYNAME(name);
     }
 #else /* _PR_INET6 */
     LOCK_DNS();
 #ifdef XP_OS2_VACPP
-	h = GETHOSTBYNAME((char *)name);
+    h = GETHOSTBYNAME((char *)name);
 #else
     h = GETHOSTBYNAME(name);
 #endif
 #endif /* _PR_INET6 */
     
 	if (NULL == h)
 	{
 #if defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)
@@ -1368,17 +1368,17 @@ PRUintn _PR_NetAddrSize(const PRNetAddr*
     if (AF_INET == addr->raw.family)
         addrsize = sizeof(addr->inet);
     else if (PR_AF_INET6 == addr->raw.family)
 #if defined(_PR_INET6)
         addrsize = sizeof(struct sockaddr_in6);
 #else
         addrsize = sizeof(addr->ipv6);
 #endif
-#if defined(XP_UNIX) || defined(XP_OS2)
+#if defined(XP_UNIX) || defined(XP_OS2_EMX)
     else if (AF_UNIX == addr->raw.family)
         addrsize = sizeof(addr->local);
 #endif
     else addrsize = 0;
 
     return addrsize;
 }  /* _PR_NetAddrSize */