Fixes for OS/2 build
authorjpierre%netscape.com
Thu, 22 Nov 2001 00:46:48 +0000
changeset 2366 246c740603c97a5b7067174144f6c9b41f9511ad
parent 2365 5dca0bdef1589227036f44dc07655f6eb6a27e72
child 2368 19a33428679edc04c4b28ff76370fd25e914cc3b
push idunknown
push userunknown
push dateunknown
Fixes for OS/2 build
security/nss/lib/ssl/sslimpl.h
security/nss/lib/ssl/sslsnce.c
--- a/security/nss/lib/ssl/sslimpl.h
+++ b/security/nss/lib/ssl/sslimpl.h
@@ -1264,18 +1264,21 @@ ssl_EmulateSendFile( PRFileDesc *       
 #else
 #define SSL_TRACE(msg)
 #endif
 
 void ssl_Trace(const char *format, ...);
 
 SEC_END_PROTOS
 
+#ifdef XP_OS2_VACPP
+#include <process.h>
+#endif
 
-#if defined(XP_UNIX)
+#if defined(XP_UNIX) || defined(XP_OS2)
 #define SSL_GETPID() getpid()
 #elif defined(WIN32)
 
 extern int __cdecl _getpid(void);
 /* #define SSL_GETPID() GetCurrentProcessId() */
 #define SSL_GETPID() _getpid()
 #else
 #define SSL_GETPID() 0
--- a/security/nss/lib/ssl/sslsnce.c
+++ b/security/nss/lib/ssl/sslsnce.c
@@ -64,17 +64,17 @@
  *     sidCacheEntry            sidCacheData[ numSIDCacheEntries];
  *     certCacheEntry           certCacheData[numCertCacheEntries];
  *     SSLWrappedSymWrappingKey keyCacheData[kt_kea_size][SSL_NUM_WRAP_MECHS];
  * } sharedMemCacheData;
  */
 #include "nssrenam.h"
 #include "seccomon.h"
 
-#if defined(XP_UNIX) || defined(XP_WIN32)
+#if defined(XP_UNIX) || defined(XP_WIN32) || defined (XP_OS2)
 
 #include "cert.h"
 #include "ssl.h"
 #include "sslimpl.h"
 #include "sslproto.h"
 #include "pk11func.h"
 #include "base64.h"
 
@@ -84,28 +84,36 @@
 
 #include <syslog.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
 #include <signal.h>
 #include "unix_err.h"
 
-#else /* XP_WIN32 */
+#else
+
+#ifdef XP_WIN32
 #include <wtypes.h>
 #include "win32err.h"
-#endif /* XP_WIN32 */
+#endif
+
+#endif 
 #include <sys/types.h>
 
 #define SET_ERROR_CODE /* reminder */
 
 #include "nspr.h"
 #include "nsslocks.h"
 #include "sslmutex.h"
 
+#ifdef XP_OS2_VACPP
+#pragma pack(1)
+#endif
+
 /*
 ** Format of a cache entry in the shared memory.
 */ 
 struct sidCacheEntryStr {
 /* 16 */    PRIPv6Addr  addr;	/* client's IP address */
 /*  4 */    PRUint32    creationTime;
 /*  4 */    PRUint32    lastAccessTime;	
 /*  4 */    PRUint32    expirationTime;
@@ -264,17 +272,17 @@ static SECStatus LaunchLockPoller(cacheD
 
 struct inheritanceStr {
     PRUint32 sharedMemSize;
     PRUint16 fmStrLen;
 };
 
 typedef struct inheritanceStr inheritance;
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(XP_OS2)
 
 #define DEFAULT_CACHE_DIRECTORY "\\temp"
 
 #endif /* _win32 */
 
 #ifdef XP_UNIX
 
 #define DEFAULT_CACHE_DIRECTORY "/tmp"
@@ -867,16 +875,30 @@ ServerSessionIDUncache(sslSessionID *sid
 	    psce->valid = 0;
 	}
 	UnlockSet(cache, set);
     }
     sid->cached = invalid_cache;
     PORT_SetError(err);
 }
 
+#ifdef XP_OS2
+
+#define INCL_DOSPROCESS
+#include <os2.h>
+
+long gettid(void)
+{
+    PTIB ptib;
+    PPIB ppib;
+    DosGetInfoBlocks(&ptib, &ppib);
+    return ((long)ptib->tib_ordinal); /* thread id */
+}
+#endif
+
 static SECStatus
 InitCache(cacheDesc *cache, int maxCacheEntries, PRUint32 ssl2_timeout, 
           PRUint32 ssl3_timeout, const char *directory)
 {
     ptrdiff_t     ptr;
     sidCacheLock *pLock;
     char *        sharedMem;
     PRFileMap *   cacheMemMap;
@@ -972,20 +994,27 @@ InitCache(cacheDesc *cache, int maxCache
 
     /* Create file names */
 #ifdef XP_UNIX
     /* there's some confusion here about whether PR_OpenAnonFileMap wants
     ** a directory name or a file name for its first argument.
     cfn = PR_smprintf("%s/.sslsvrcache.%d", directory, myPid);
     */
     cfn = PR_smprintf("%s", directory);
-#else /* XP_WIN32 */
+#endif
+ 
+#ifdef XP_WIN32
     cfn = PR_smprintf("%s/svrcache_%d_%x.ssl", directory, myPid, 
     			GetCurrentThreadId());
-#endif /* XP_WIN32 */
+#endif
+
+#ifdef XP_OS2
+    cfn = PR_smprintf("%s/svrcache_%d_%x.ssl", directory, myPid, 
+    			gettid());
+#endif
     if (!cfn) {
 	goto loser;
     }
 
     /* Create cache */
     cacheMemMap = PR_OpenAnonFileMap(cfn, cache->sharedMemSize, 
                                             PR_PROT_READWRITE);
     PR_smprintf_free(cfn);
@@ -1086,18 +1115,20 @@ SSL_ConfigServerSessionIDCacheInstance(	
 			  const char *   directory)
 {
     SECStatus rv;
 
 #if defined(DEBUG_nelsonb)
     printf("sizeof(sidCacheEntry) == %u\n", sizeof(sidCacheEntry));
 #endif
 #if !(defined(SOLARIS) && defined(i386))
+#ifndef XP_OS2
     PORT_Assert(sizeof(sidCacheEntry) % 8 == 0);
 #endif
+#endif
     PORT_Assert(sizeof(certCacheEntry) == 4096);
 
     myPid = SSL_GETPID();
     if (!directory) {
 	directory = DEFAULT_CACHE_DIRECTORY;
     }
     rv = InitCache(cache, maxCacheEntries, ssl2_timeout, ssl3_timeout, 
                    directory);
@@ -1171,18 +1202,18 @@ SSL_ConfigMPServerSIDCache(	int      max
 
     putEnvFailed = (SECStatus)NSS_PutEnv(envVarName, envValue);
     PR_smprintf_free(envValue);
     if (putEnvFailed) {
         SET_ERROR_CODE
         result = SECFailure;
     }
 
-#if !defined(WIN32)
-    /* Launch thread to poll cache for expired locks */
+#if defined(XP_UNIX)
+    /* Launch thread to poll cache for expired locks on Unix */
     LaunchLockPoller(cache);
 #endif
     return result;
 }
 
 SECStatus
 SSL_InheritMPServerSIDCacheInstance(cacheDesc *cache, const char * envString)
 {
@@ -1324,17 +1355,17 @@ loser:
 }
 
 SECStatus
 SSL_InheritMPServerSIDCache(const char * envString)
 {
     return SSL_InheritMPServerSIDCacheInstance(&globalCache, envString);
 }
 
-#if !defined(WIN32)
+#if defined(XP_UNIX)
 
 #define SID_LOCK_EXPIRATION_TIMEOUT  30 /* seconds */
 
 static void
 LockPoller(void * arg)
 {
     cacheDesc *    cache         = (cacheDesc *)arg;
     cacheDesc *    sharedCache   = cache->sharedCache;