diff options
author | Ulf Möller <ulf@openssl.org> | 2006-04-11 21:34:21 +0000 |
---|---|---|
committer | Ulf Möller <ulf@openssl.org> | 2006-04-11 21:34:21 +0000 |
commit | 4700aea951dcba9b1e3b724bf4d8f0c712578892 (patch) | |
tree | a30eb63c83db7085b9067633de5391267ce74881 /crypto | |
parent | 60cdb821db3403481c891b570d163d28f041ec02 (diff) |
Add BeOS support.
PR: 1312
Submitted by: Oliver Tappe <zooey@hirschkaefer.de>
Reviewed by: Ulf Moeller
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bio/b_sock.c | 11 | ||||
-rw-r--r-- | crypto/bio/bss_dgram.c | 4 | ||||
-rw-r--r-- | crypto/cryptlib.c | 2 | ||||
-rw-r--r-- | crypto/dso/Makefile | 4 | ||||
-rw-r--r-- | crypto/dso/dso.h | 8 | ||||
-rw-r--r-- | crypto/dso/dso_err.c | 5 | ||||
-rw-r--r-- | crypto/dso/dso_openssl.c | 2 | ||||
-rw-r--r-- | crypto/rand/rand_egd.c | 2 | ||||
-rw-r--r-- | crypto/rand/rand_unix.c | 20 | ||||
-rw-r--r-- | crypto/threads/mttest.c | 99 | ||||
-rw-r--r-- | crypto/ui/ui_openssl.c | 2 |
11 files changed, 153 insertions, 6 deletions
diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c index 710a8d6d96..c8ca5923c1 100644 --- a/crypto/bio/b_sock.c +++ b/crypto/bio/b_sock.c @@ -84,6 +84,11 @@ static int wsa_init_done=0; #endif +#if defined(OPENSSL_SYS_BEOS_BONE) +/* BONE's IP6 support is incomplete */ +#undef AF_INET6 +#endif + #if 0 static unsigned long BIO_ghbn_hits=0L; static unsigned long BIO_ghbn_miss=0L; @@ -220,6 +225,10 @@ int BIO_sock_error(int sock) int j,i; int size; +#if defined(OPENSSL_SYS_BEOS_R5) + return 0; +#endif + size=sizeof(int); /* Note: under Windows the third parameter is of type (char *) * whereas under other systems it is (void *) if you don't have @@ -799,7 +808,7 @@ int BIO_accept(int sock, char **addr) if (addr == NULL) goto end; #ifdef EAI_FAMILY -# ifdef OPENSSL_SYS_VMS +# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_BEOS_BONE) # define SOCKLEN_T size_t # else # define SOCKLEN_T socklen_t diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index c21a81dc91..771003e8ac 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -341,6 +341,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) memcpy(&(data->peer), to, sizeof(struct sockaddr)); break; +#if defined(SO_RCVTIMEO) case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT: if ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr, sizeof(struct timeval)) < 0) @@ -351,6 +352,8 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) ptr, (void *)&ret) < 0) { perror("getsockopt"); ret = -1; } break; +#endif +#if defined(SO_SNDTIMEO) case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT: if ( setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr, sizeof(struct timeval)) < 0) @@ -361,6 +364,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) ptr, (void *)&ret) < 0) { perror("getsockopt"); ret = -1; } break; +#endif case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP: /* fall-through */ case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP: diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index 6464c53705..aa19dd7f27 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -436,6 +436,8 @@ unsigned long CRYPTO_thread_id(void) ret=(unsigned long)GetCurrentThreadId(); #elif defined(GETPID_IS_MEANINGLESS) ret=1L; +#elif defined(OPENSSL_SYS_BEOS) + ret=(unsigned long)find_thread(NULL); #else ret=(unsigned long)getpid(); #endif diff --git a/crypto/dso/Makefile b/crypto/dso/Makefile index 07f5d8d159..105d1e056b 100644 --- a/crypto/dso/Makefile +++ b/crypto/dso/Makefile @@ -18,9 +18,9 @@ APPS= LIB=$(TOP)/libcrypto.a LIBSRC= dso_dl.c dso_dlfcn.c dso_err.c dso_lib.c dso_null.c \ - dso_openssl.c dso_win32.c dso_vms.c + dso_openssl.c dso_win32.c dso_vms.c dso_beos.c LIBOBJ= dso_dl.o dso_dlfcn.o dso_err.o dso_lib.o dso_null.o \ - dso_openssl.o dso_win32.o dso_vms.o + dso_openssl.o dso_win32.o dso_vms.o dso_beos.o SRC= $(LIBSRC) diff --git a/crypto/dso/dso.h b/crypto/dso/dso.h index 8934c4ee21..3aa4f7aee5 100644 --- a/crypto/dso/dso.h +++ b/crypto/dso/dso.h @@ -322,6 +322,9 @@ int DSO_pathbyaddr(void *addr,char *path,int sz); * itself or libsocket. */ void *DSO_global_lookup(const char *name); +/* If BeOS is defined, use shared images. If not, return NULL. */ +DSO_METHOD *DSO_METHOD_beos(void); + /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. @@ -331,6 +334,11 @@ void ERR_load_DSO_strings(void); /* Error codes for the DSO functions. */ /* Function codes. */ +#define DSO_F_BEOS_BIND_FUNC 130 +#define DSO_F_BEOS_BIND_VAR 131 +#define DSO_F_BEOS_LOAD 132 +#define DSO_F_BEOS_NAME_CONVERTER 133 +#define DSO_F_BEOS_UNLOAD 134 #define DSO_F_DLFCN_BIND_FUNC 100 #define DSO_F_DLFCN_BIND_VAR 101 #define DSO_F_DLFCN_LOAD 102 diff --git a/crypto/dso/dso_err.c b/crypto/dso/dso_err.c index 009a543445..d7c6087a9d 100644 --- a/crypto/dso/dso_err.c +++ b/crypto/dso/dso_err.c @@ -70,6 +70,11 @@ static ERR_STRING_DATA DSO_str_functs[]= { +{ERR_FUNC(DSO_F_BEOS_BIND_FUNC), "BEOS_BIND_FUNC"}, +{ERR_FUNC(DSO_F_BEOS_BIND_VAR), "BEOS_BIND_VAR"}, +{ERR_FUNC(DSO_F_BEOS_LOAD), "BEOS_LOAD"}, +{ERR_FUNC(DSO_F_BEOS_NAME_CONVERTER), "BEOS_NAME_CONVERTER"}, +{ERR_FUNC(DSO_F_BEOS_UNLOAD), "BEOS_UNLOAD"}, {ERR_FUNC(DSO_F_DLFCN_BIND_FUNC), "DLFCN_BIND_FUNC"}, {ERR_FUNC(DSO_F_DLFCN_BIND_VAR), "DLFCN_BIND_VAR"}, {ERR_FUNC(DSO_F_DLFCN_LOAD), "DLFCN_LOAD"}, diff --git a/crypto/dso/dso_openssl.c b/crypto/dso/dso_openssl.c index a4395ebffe..b17e8e8e9e 100644 --- a/crypto/dso/dso_openssl.c +++ b/crypto/dso/dso_openssl.c @@ -74,6 +74,8 @@ DSO_METHOD *DSO_METHOD_openssl(void) return(DSO_METHOD_win32()); #elif defined(DSO_VMS) return(DSO_METHOD_vms()); +#elif defined(DSO_BEOS) + return(DSO_METHOD_beos()); #else return(DSO_METHOD_null()); #endif diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c index 50bce6caba..d53b916ebe 100644 --- a/crypto/rand/rand_egd.c +++ b/crypto/rand/rand_egd.c @@ -95,7 +95,7 @@ * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255. */ -#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_BEOS) int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) { return(-1); diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c index c340642515..c4838b6b2e 100644 --- a/crypto/rand/rand_unix.c +++ b/crypto/rand/rand_unix.c @@ -205,6 +205,16 @@ int RAND_poll(void) do { +#if defined(OPENSSL_SYS_BEOS_R5) + /* select() is broken in BeOS R5, so we simply + * try to read something and snooze if we couldn't: */ + r=read(fd,(unsigned char *)tmpbuf+n, + ENTROPY_NEEDED-n); + if (r > 0) + n += r; + else if (r == 0) + snooze(t.tv_usec); +#else FD_ZERO(&fset); FD_SET(fd, &fset); r = -1; @@ -218,7 +228,7 @@ int RAND_poll(void) if (r > 0) n += r; } - +#endif /* Some Unixen will update t, some won't. For those who won't, give up here, otherwise, we will do @@ -267,6 +277,14 @@ int RAND_poll(void) l=time(NULL); RAND_add(&l,sizeof(l),0.0); +#if defined(OPENSSL_SYS_BEOS) + { + system_info sysInfo; + get_system_info(&sysInfo); + RAND_add(&sysInfo,sizeof(sysInfo),0); + } +#endif + #if defined(DEVRANDOM) || defined(DEVRANDOM_EGD) return 1; #else diff --git a/crypto/threads/mttest.c b/crypto/threads/mttest.c index f6f3df4b6a..eba7aa8a6e 100644 --- a/crypto/threads/mttest.c +++ b/crypto/threads/mttest.c @@ -117,11 +117,13 @@ 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 netware_locking_callback(int mode,int type,char *file,int line); +void beos_locking_callback(int mode,int type,const char *file,int line); unsigned long irix_thread_id(void ); unsigned long solaris_thread_id(void ); unsigned long pthreads_thread_id(void ); unsigned long netware_thread_id(void ); +unsigned long beos_thread_id(void ); #if defined(OPENSSL_SYS_NETWARE) static MPKMutex *lock_cs; @@ -1209,3 +1211,100 @@ unsigned long netware_thread_id(void) return(ret); } #endif /* NETWARE */ + +#ifdef BEOS_THREADS + +#include <Locker.h> + +static BLocker** lock_cs; +static long* lock_count; + +void thread_setup(void) + { + int i; + + lock_cs=(BLocker**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(BLocker*)); + lock_count=(long*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); + for (i=0; i<CRYPTO_num_locks(); i++) + { + lock_count[i]=0; + lock_cs[i] = new BLocker(CRYPTO_get_lock_name(i)); + } + + CRYPTO_set_id_callback((unsigned long (*)())beos_thread_id); + CRYPTO_set_locking_callback(beos_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++) + { + delete 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 beos_locking_callback(int mode, int type, const char *file, int line) + { +#if 0 + 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 (mode & CRYPTO_LOCK) + { + lock_cs[type]->Lock(); + lock_count[type]++; + } + else + { + lock_cs[type]->Unlock(); + } + } + +void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) + { + SSL_CTX *ssl_ctx[2]; + thread_id thread_ctx[MAX_THREAD_NUMBER]; + int i; + + ssl_ctx[0]=s_ctx; + ssl_ctx[1]=c_ctx; + + for (i=0; i<thread_number; i++) + { + thread_ctx[i] = spawn_thread((thread_func)ndoit, + NULL, B_NORMAL_PRIORITY, (void *)ssl_ctx); + resume_thread(thread_ctx[i]); + } + + printf("waiting...\n"); + for (i=0; i<thread_number; i++) + { + status_t result; + wait_for_thread(thread_ctx[i], &result); + } + + printf("beos threads done (%d,%d)\n", + s_ctx->references,c_ctx->references); + } + +unsigned long beos_thread_id(void) + { + unsigned long ret; + + ret=(unsigned long)find_thread(NULL); + return(ret); + } + +#endif /* BEOS_THREADS */ diff --git a/crypto/ui/ui_openssl.c b/crypto/ui/ui_openssl.c index 1f23a45a33..8eabb850ff 100644 --- a/crypto/ui/ui_openssl.c +++ b/crypto/ui/ui_openssl.c @@ -473,7 +473,7 @@ static int open_console(UI *ui) CRYPTO_w_lock(CRYPTO_LOCK_UI); is_a_tty = 1; -#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) +#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_BEOS) tty_in=stdin; tty_out=stderr; #else |