summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/threads
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/threads')
-rw-r--r--src/lib/libcrypto/threads/mttest.c99
-rw-r--r--src/lib/libcrypto/threads/netware.bat79
-rw-r--r--src/lib/libcrypto/threads/pthreads-vms.com9
3 files changed, 81 insertions, 106 deletions
diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c
index eba7aa8a6e..f6f3df4b6a 100644
--- a/src/lib/libcrypto/threads/mttest.c
+++ b/src/lib/libcrypto/threads/mttest.c
@@ -117,13 +117,11 @@ void solaris_locking_callback(int mode,int type,char *file,int line);
117void win32_locking_callback(int mode,int type,char *file,int line); 117void win32_locking_callback(int mode,int type,char *file,int line);
118void pthreads_locking_callback(int mode,int type,char *file,int line); 118void pthreads_locking_callback(int mode,int type,char *file,int line);
119void netware_locking_callback(int mode,int type,char *file,int line); 119void netware_locking_callback(int mode,int type,char *file,int line);
120void beos_locking_callback(int mode,int type,const char *file,int line);
121 120
122unsigned long irix_thread_id(void ); 121unsigned long irix_thread_id(void );
123unsigned long solaris_thread_id(void ); 122unsigned long solaris_thread_id(void );
124unsigned long pthreads_thread_id(void ); 123unsigned long pthreads_thread_id(void );
125unsigned long netware_thread_id(void ); 124unsigned long netware_thread_id(void );
126unsigned long beos_thread_id(void );
127 125
128#if defined(OPENSSL_SYS_NETWARE) 126#if defined(OPENSSL_SYS_NETWARE)
129static MPKMutex *lock_cs; 127static MPKMutex *lock_cs;
@@ -1211,100 +1209,3 @@ unsigned long netware_thread_id(void)
1211 return(ret); 1209 return(ret);
1212} 1210}
1213#endif /* NETWARE */ 1211#endif /* NETWARE */
1214
1215#ifdef BEOS_THREADS
1216
1217#include <Locker.h>
1218
1219static BLocker** lock_cs;
1220static long* lock_count;
1221
1222void 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
1238void 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
1256void 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
1275void 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
1302unsigned 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/netware.bat b/src/lib/libcrypto/threads/netware.bat
new file mode 100644
index 0000000000..0b3eca3caf
--- /dev/null
+++ b/src/lib/libcrypto/threads/netware.bat
@@ -0,0 +1,79 @@
1@echo off
2rem batch file to build multi-thread test ( mttest.nlm )
3
4rem command line arguments:
5rem debug => build using debug settings
6
7rem
8rem After building, copy mttest.nlm to the server and run it, you'll probably
9rem want to redirect stdout and stderr. An example command line would be
10rem "mttest.nlm -thread 20 -loops 10 -CAfile \openssl\apps\server.pem >mttest.out 2>mttest.err"
11rem
12
13del mttest.nlm
14
15set BLD_DEBUG=
16set CFLAGS=
17set LFLAGS=
18set LIBS=
19
20if "%1" == "DEBUG" set BLD_DEBUG=YES
21if "%1" == "debug" set BLD_DEBUG=YES
22
23if "%MWCIncludes%" == "" goto inc_error
24if "%PRELUDE%" == "" goto prelude_error
25if "%IMPORTS%" == "" goto imports_error
26
27set CFLAGS=-c -I..\..\outinc_nw -nosyspath -DOPENSSL_SYS_NETWARE -opt off -g -sym internal -maxerrors 20
28
29if "%BLD_DEBUG%" == "YES" set LIBS=..\..\out_nw.dbg\ssl.lib ..\..\out_nw.dbg\crypto.lib
30if "%BLD_DEBUG%" == "" set LIBS=..\..\out_nw\ssl.lib ..\..\out_nw\crypto.lib
31
32set LFLAGS=-msgstyle gcc -zerobss -stacksize 32768 -nostdlib -sym internal
33
34rem generate command file for metrowerks
35echo.
36echo Generating Metrowerks command file: mttest.def
37echo # dynamically generated command file for metrowerks build > mttest.def
38echo IMPORT @%IMPORTS%\clib.imp >> mttest.def
39echo IMPORT @%IMPORTS%\threads.imp >> mttest.def
40echo IMPORT @%IMPORTS%\ws2nlm.imp >> mttest.def
41echo IMPORT GetProcessSwitchCount >> mttest.def
42echo MODULE clib >> mttest.def
43
44rem compile
45echo.
46echo Compiling mttest.c
47mwccnlm.exe mttest.c %CFLAGS%
48if errorlevel 1 goto end
49
50rem link
51echo.
52echo Linking mttest.nlm
53mwldnlm.exe %LFLAGS% -screenname mttest -commandfile mttest.def mttest.o "%PRELUDE%" %LIBS% -o mttest.nlm
54if errorlevel 1 goto end
55
56goto end
57
58:inc_error
59echo.
60echo Environment variable MWCIncludes is not set - see install.nw
61goto end
62
63:prelude_error
64echo.
65echo Environment variable PRELUDE is not set - see install.nw
66goto end
67
68:imports_error
69echo.
70echo Environment variable IMPORTS is not set - see install.nw
71goto end
72
73
74:end
75set BLD_DEBUG=
76set CFLAGS=
77set LFLAGS=
78set LIBS=
79
diff --git a/src/lib/libcrypto/threads/pthreads-vms.com b/src/lib/libcrypto/threads/pthreads-vms.com
index 1cf92bdf57..63f5b8cc2e 100644
--- a/src/lib/libcrypto/threads/pthreads-vms.com
+++ b/src/lib/libcrypto/threads/pthreads-vms.com
@@ -2,13 +2,8 @@ $! 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$ if (f$getsyi("cpu").lt.128) 5$ arch := vax
6$ then 6$ if f$getsyi("CPU") .ge. 128 then arch := axp
7$ arch := VAX
8$ else
9$ arch = f$edit( f$getsyi( "ARCH_NAME"), "UPCASE")
10$ if (arch .eqs. "") then arch = "UNK"
11$ endif
12$ define/user openssl [--.include.openssl] 7$ define/user openssl [--.include.openssl]
13$ cc/def=PTHREADS mttest.c 8$ cc/def=PTHREADS mttest.c
14$ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib 9$ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib