diff options
Diffstat (limited to 'src/lib/libcrypto/threads')
-rw-r--r-- | src/lib/libcrypto/threads/mttest.c | 99 | ||||
-rw-r--r-- | src/lib/libcrypto/threads/pthreads-vms.com | 9 |
2 files changed, 106 insertions, 2 deletions
diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c index f6f3df4b6a..eba7aa8a6e 100644 --- a/src/lib/libcrypto/threads/mttest.c +++ b/src/lib/libcrypto/threads/mttest.c | |||
@@ -117,11 +117,13 @@ void solaris_locking_callback(int mode,int type,char *file,int line); | |||
117 | void win32_locking_callback(int mode,int type,char *file,int line); | 117 | void win32_locking_callback(int mode,int type,char *file,int line); |
118 | void pthreads_locking_callback(int mode,int type,char *file,int line); | 118 | void pthreads_locking_callback(int mode,int type,char *file,int line); |
119 | void netware_locking_callback(int mode,int type,char *file,int line); | 119 | void netware_locking_callback(int mode,int type,char *file,int line); |
120 | void beos_locking_callback(int mode,int type,const char *file,int line); | ||
120 | 121 | ||
121 | unsigned long irix_thread_id(void ); | 122 | unsigned long irix_thread_id(void ); |
122 | unsigned long solaris_thread_id(void ); | 123 | unsigned long solaris_thread_id(void ); |
123 | unsigned long pthreads_thread_id(void ); | 124 | unsigned long pthreads_thread_id(void ); |
124 | unsigned long netware_thread_id(void ); | 125 | unsigned long netware_thread_id(void ); |
126 | unsigned long beos_thread_id(void ); | ||
125 | 127 | ||
126 | #if defined(OPENSSL_SYS_NETWARE) | 128 | #if defined(OPENSSL_SYS_NETWARE) |
127 | static MPKMutex *lock_cs; | 129 | static MPKMutex *lock_cs; |
@@ -1209,3 +1211,100 @@ unsigned long netware_thread_id(void) | |||
1209 | return(ret); | 1211 | return(ret); |
1210 | } | 1212 | } |
1211 | #endif /* NETWARE */ | 1213 | #endif /* NETWARE */ |
1214 | |||
1215 | #ifdef BEOS_THREADS | ||
1216 | |||
1217 | #include <Locker.h> | ||
1218 | |||
1219 | static BLocker** lock_cs; | ||
1220 | static long* lock_count; | ||
1221 | |||
1222 | void thread_setup(void) | ||
1223 | { | ||
1224 | int i; | ||
1225 | |||
1226 | lock_cs=(BLocker**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(BLocker*)); | ||
1227 | lock_count=(long*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); | ||
1228 | for (i=0; i<CRYPTO_num_locks(); i++) | ||
1229 | { | ||
1230 | lock_count[i]=0; | ||
1231 | lock_cs[i] = new BLocker(CRYPTO_get_lock_name(i)); | ||
1232 | } | ||
1233 | |||
1234 | CRYPTO_set_id_callback((unsigned long (*)())beos_thread_id); | ||
1235 | CRYPTO_set_locking_callback(beos_locking_callback); | ||
1236 | } | ||
1237 | |||
1238 | void thread_cleanup(void) | ||
1239 | { | ||
1240 | int i; | ||
1241 | |||
1242 | CRYPTO_set_locking_callback(NULL); | ||
1243 | fprintf(stderr,"cleanup\n"); | ||
1244 | for (i=0; i<CRYPTO_num_locks(); i++) | ||
1245 | { | ||
1246 | delete lock_cs[i]; | ||
1247 | fprintf(stderr,"%8ld:%s\n",lock_count[i], | ||
1248 | CRYPTO_get_lock_name(i)); | ||
1249 | } | ||
1250 | OPENSSL_free(lock_cs); | ||
1251 | OPENSSL_free(lock_count); | ||
1252 | |||
1253 | fprintf(stderr,"done cleanup\n"); | ||
1254 | } | ||
1255 | |||
1256 | void beos_locking_callback(int mode, int type, const char *file, int line) | ||
1257 | { | ||
1258 | #if 0 | ||
1259 | fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n", | ||
1260 | CRYPTO_thread_id(), | ||
1261 | (mode&CRYPTO_LOCK)?"l":"u", | ||
1262 | (type&CRYPTO_READ)?"r":"w",file,line); | ||
1263 | #endif | ||
1264 | if (mode & CRYPTO_LOCK) | ||
1265 | { | ||
1266 | lock_cs[type]->Lock(); | ||
1267 | lock_count[type]++; | ||
1268 | } | ||
1269 | else | ||
1270 | { | ||
1271 | lock_cs[type]->Unlock(); | ||
1272 | } | ||
1273 | } | ||
1274 | |||
1275 | void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) | ||
1276 | { | ||
1277 | SSL_CTX *ssl_ctx[2]; | ||
1278 | thread_id thread_ctx[MAX_THREAD_NUMBER]; | ||
1279 | int i; | ||
1280 | |||
1281 | ssl_ctx[0]=s_ctx; | ||
1282 | ssl_ctx[1]=c_ctx; | ||
1283 | |||
1284 | for (i=0; i<thread_number; i++) | ||
1285 | { | ||
1286 | thread_ctx[i] = spawn_thread((thread_func)ndoit, | ||
1287 | NULL, B_NORMAL_PRIORITY, (void *)ssl_ctx); | ||
1288 | resume_thread(thread_ctx[i]); | ||
1289 | } | ||
1290 | |||
1291 | printf("waiting...\n"); | ||
1292 | for (i=0; i<thread_number; i++) | ||
1293 | { | ||
1294 | status_t result; | ||
1295 | wait_for_thread(thread_ctx[i], &result); | ||
1296 | } | ||
1297 | |||
1298 | printf("beos threads done (%d,%d)\n", | ||
1299 | s_ctx->references,c_ctx->references); | ||
1300 | } | ||
1301 | |||
1302 | unsigned long beos_thread_id(void) | ||
1303 | { | ||
1304 | unsigned long ret; | ||
1305 | |||
1306 | ret=(unsigned long)find_thread(NULL); | ||
1307 | return(ret); | ||
1308 | } | ||
1309 | |||
1310 | #endif /* BEOS_THREADS */ | ||
diff --git a/src/lib/libcrypto/threads/pthreads-vms.com b/src/lib/libcrypto/threads/pthreads-vms.com index 63f5b8cc2e..1cf92bdf57 100644 --- a/src/lib/libcrypto/threads/pthreads-vms.com +++ b/src/lib/libcrypto/threads/pthreads-vms.com | |||
@@ -2,8 +2,13 @@ $! To compile mttest on VMS. | |||
2 | $! | 2 | $! |
3 | $! WARNING: only tested with DEC C so far. | 3 | $! WARNING: only tested with DEC C so far. |
4 | $ | 4 | $ |
5 | $ arch := vax | 5 | $ if (f$getsyi("cpu").lt.128) |
6 | $ if f$getsyi("CPU") .ge. 128 then arch := axp | 6 | $ then |
7 | $ arch := VAX | ||
8 | $ else | ||
9 | $ arch = f$edit( f$getsyi( "ARCH_NAME"), "UPCASE") | ||
10 | $ if (arch .eqs. "") then arch = "UNK" | ||
11 | $ endif | ||
7 | $ define/user openssl [--.include.openssl] | 12 | $ define/user openssl [--.include.openssl] |
8 | $ cc/def=PTHREADS mttest.c | 13 | $ cc/def=PTHREADS mttest.c |
9 | $ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib | 14 | $ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib |