Fixes for VxWorks. Are these needed for 0.9.7 and up as well?
authorRichard Levitte <levitte@openssl.org>
Wed, 4 Dec 2002 23:13:07 +0000 (23:13 +0000)
committerRichard Levitte <levitte@openssl.org>
Wed, 4 Dec 2002 23:13:07 +0000 (23:13 +0000)
PR: 374

apps/ca.c
apps/s_server.c
apps/s_time.c
crypto/rand/rand_egd.c
crypto/rand/rand_win.c
crypto/threads/mttest.c
crypto/tmdiff.c
crypto/uid.c

index 7e64a75e8d36e158b4270a2887a9d18a63260cdd..b8487208c6d2f45620c9f9269b562f92401cbc05 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -606,12 +606,14 @@ bad:
               that to access().  However, time's too short to do that just
               now.
             */
+#ifndef VXWORKS
                if (access(outdir,R_OK|W_OK|X_OK) != 0)
                        {
                        BIO_printf(bio_err,"I am unable to access the %s directory\n",outdir);
                        perror(outdir);
                        goto err;
                        }
+#endif
 
                if (stat(outdir,&sb) != 0)
                        {
index 0839ac07daf25dc8c3c3b0f3d4ab5a5f3a91a5b7..e6ecafd4ed1e34bb8189e9c2f5455e9752014c7b 100644 (file)
@@ -1250,7 +1250,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
                        else
                                {
                                BIO_printf(bio_s_out,"read R BLOCK\n");
-#ifndef MSDOS
+#if !defined(MSDOS) && !defined(VXWORKS)
                                sleep(1);
 #endif
                                continue;
index c8719a6a2200fcbce411cac6dc0d9781d2e143f5..895741d4cde77618943913ffe9005e5cb07b65c8 100644 (file)
 #include <sys/param.h>
 #endif
 
+#ifdef VXWORKS
+#include <tickLib.h>
+#undef SIGALRM
+#endif
+
 /* The following if from times(3) man page.  It may need to be changed
 */
 #ifndef HZ
index e17060fe9098b1c3e0f105515ad089e093840b6d..ce169367857a5c38a52eb6db86da2ea31845f533 100644 (file)
@@ -59,7 +59,7 @@
 /* Query the EGD <URL: http://www.lothar.com/tech/crypto/>.
  */
 
-#if defined(WIN32) || defined(MSDOS) || defined(VMS) || defined(__VMS)
+#if defined(WIN32) || defined(MSDOS) || defined(VMS) || defined(__VMS) || defined(VXWORKS)
 int RAND_egd(const char *path)
        {
        return(-1);
index 92befcd798cfcdecd5df4483e50ea458ab3e628f..3e148ad4d2547f1520550226e497f5af0d91978d 100644 (file)
@@ -732,8 +732,10 @@ int RAND_poll(void)
        /* put in some default random data, we need more than just this */
        l=curr_pid;
        RAND_add(&l,sizeof(l),0);
+#ifndef VXWORKS
        l=getuid();
        RAND_add(&l,sizeof(l),0);
+#endif
 
        l=time(NULL);
        RAND_add(&l,sizeof(l),0);
index 100165948c028f9ff4d3380368c4b8474ebee169..3d1b212b1c74f1170708e12b229c563967972dd7 100644 (file)
 #ifdef PTHREADS
 #include <pthread.h>
 #endif
+#ifdef VXWORKS
+#include <taskLib.h>
+#include <semLib.h>
+#endif
 #include <openssl/lhash.h>
 #include <openssl/crypto.h>
 #include <openssl/buffer.h>
@@ -105,10 +109,12 @@ void irix_locking_callback(int mode,int type,char *file,int line);
 void solaris_locking_callback(int mode,int type,char *file,int line);
 void win32_locking_callback(int mode,int type,char *file,int line);
 void pthreads_locking_callback(int mode,int type,char *file,int line);
+void vxworks_locking_callback(int mode,int type,char *file,int line);
 
 unsigned long irix_thread_id(void );
 unsigned long solaris_thread_id(void );
 unsigned long pthreads_thread_id(void );
+unsigned long vxworks_thread_id(void );
 
 BIO *bio_err=NULL;
 BIO *bio_stdout=NULL;
@@ -1097,4 +1103,119 @@ unsigned long pthreads_thread_id(void)
 #endif /* PTHREADS */
 
 
+#ifdef VXWORKS
+
+#define DEFAULT_TASK_NAME               NULL
+#define DEFAULT_TASK_PRIORITY           100
+#define DEFAULT_TASK_OPTIONS            0
+#define DEFAULT_TASK_STACK_BYTES        32768
+
+static SEM_ID *lock_cs;
+static long *lock_count;
+
+extern int sysClkRateGet();
+
+void thread_setup(void)
+       {
+       int i;
+
+       lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(SEM_ID));
+       lock_count=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
+       for (i=0; i<CRYPTO_num_locks(); i++)
+               {
+               lock_count[i]=0;
+               lock_cs[i] = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE);
+               }
+
+       CRYPTO_set_id_callback((unsigned long (*)())vxworks_thread_id);
+       CRYPTO_set_locking_callback((void (*)())vxworks_locking_callback);
+       }
+
+void thread_cleanup(void)
+       {
+       int i;
+
+       CRYPTO_set_locking_callback(NULL);
+       fprintf(stderr,"cleanup\n");
+       for (i=0; i<CRYPTO_num_locks(); i++)
+               {
+               semDelete(lock_cs[i]);
+               fprintf(stderr,"%8ld:%s\n",lock_count[i],
+                       CRYPTO_get_lock_name(i));
+               }
+       OPENSSL_free(lock_cs);
+       OPENSSL_free(lock_count);
+
+       fprintf(stderr,"done cleanup\n");
+       }
+
+void vxworks_locking_callback(int mode, int type, char *file, int line)
+      {
+#ifdef undef
+       fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
+               CRYPTO_thread_id(),
+               (mode&CRYPTO_LOCK)?"l":"u",
+               (type&CRYPTO_READ)?"r":"w",file,line);
+#endif
+/*
+       if (CRYPTO_LOCK_SSL_CERT == type)
+               fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
+               CRYPTO_thread_id(),
+               mode,file,line);
+*/
+       if (mode & CRYPTO_LOCK)
+               {
+               semTake(lock_cs[type], WAIT_FOREVER);
+               lock_count[type]++;
+               }
+       else
+               {
+               semGive(lock_cs[type]);
+               }
+       }
+
+
+void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
+       {
+       SSL_CTX *ssl_ctx[2];
+       int thread_ctx[MAX_THREAD_NUMBER];
+       int i;
+
+       ssl_ctx[0]=s_ctx;
+       ssl_ctx[1]=c_ctx;
+
+       /*
+       thr_setconcurrency(thread_number);
+       */
+       for (i=0; i<thread_number; i++)
+               {
+               thread_ctx[i] = taskSpawn(DEFAULT_TASK_NAME,
+                               DEFAULT_TASK_PRIORITY,
+                               DEFAULT_TASK_OPTIONS,
+                               DEFAULT_TASK_STACK_BYTES,
+                               (FUNCPTR)ndoit,
+                               (int)ssl_ctx, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+               printf("Spawned task %d (%x)\n", i, thread_ctx[i]);
+               }
+
+       printf("reaping\n");
+       for (i=0; i<thread_number; i++)
+               {
+               while(taskIdVerify(thread_ctx[i]) != ERROR)
+                       {
+                       taskDelay(sysClkRateGet()/10);
+                       }
+               printf("Reaped task %d (%x)\n", i, thread_ctx[i]);
+               }
+
+       printf("vxworks threads done (%d,%d)\n",
+               s_ctx->references,c_ctx->references);
+       }
+
+unsigned long vxworks_thread_id(void)
+       {
+       return((unsigned long)taskIdSelf());
+       }
 
+#endif /* VXWORKS */
index 830092210f420b3f707de71f312c9b7b127f521e..fc38e139a71daa7c7e5ee9c5dd75a737db0ffe29 100644 (file)
 #include <windows.h>
 #endif
 
+#ifdef VXWORKS
+#include <tickLib.h>
+#include <drv/timer/timerDev.h>
+#endif
+
 /* The following if from times(3) man page.  It may need to be changed */
 #ifndef HZ
 # ifndef CLK_TCK
index b5b61b76d4e35e1c9dc85729e945213f75994906..4bd283592ca8bc47df86c8147cc331df43d8b2b3 100644 (file)
@@ -64,7 +64,7 @@ int OPENSSL_issetugid(void)
        return issetugid();
        }
 
-#elif defined(WIN32)
+#elif defined(WIN32) || defined(VXWORKS)
 
 int OPENSSL_issetugid(void)
        {