66 #ifdef OPENSSL_SYS_WIN32
75 #include <sys/prctl.h>
83 #include "../../e_os.h"
106 #define THREAD_STACK_SIZE (16*1024)
108 #ifdef OPENSSL_SYS_WIN32
110 static HANDLE *lock_cs;
119 lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
133 CloseHandle(lock_cs[i]);
141 WaitForSingleObject(lock_cs[type],INFINITE);
145 ReleaseMutex(lock_cs[type]);
156 static mutex_t *lock_cs;
158 static rwlock_t *lock_cs;
160 static long *lock_count;
176 mutex_init(&(lock_cs[i]),USYNC_THREAD,NULL);
178 rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL);
194 mutex_destroy(&(lock_cs[i]));
196 rwlock_destroy(&(lock_cs[i]));
206 fprintf(stderr,
"thread=%4d mode=%s lock=%s %s:%d\n",
214 fprintf(stderr,
"(t,m,f,l) %ld %d %s %d\n",
218 if (mode & CRYPTO_LOCK)
221 mutex_lock(&(lock_cs[type]));
224 rw_rdlock(&(lock_cs[type]));
226 rw_wrlock(&(lock_cs[type]));
233 mutex_unlock(&(lock_cs[type]));
235 rw_unlock(&(lock_cs[type]));
244 ret=(
unsigned long)thr_self();
252 static usptr_t *arena;
253 static usema_t **lock_cs;
260 strcpy(filename,
"/tmp/mttest.XXXXXX");
263 usconfig(CONF_STHREADIOOFF);
264 usconfig(CONF_STHREADMALLOCOFF);
265 usconfig(CONF_INITUSERS,100);
266 usconfig(CONF_LOCKTYPE,US_DEBUGPLUS);
267 arena=usinit(filename);
273 lock_cs[i]=usnewsema(arena,1);
289 sprintf(buf,
"%2d:",i);
290 usdumpsema(lock_cs[i],stdout,buf);
291 usfreesema(lock_cs[i],arena);
298 if (mode & CRYPTO_LOCK)
300 uspsema(lock_cs[type]);
304 usvsema(lock_cs[type]);
312 ret=(
unsigned long)getpid();
320 static pthread_mutex_t *lock_cs;
321 static long *lock_count;
332 pthread_mutex_init(&(lock_cs[i]),NULL);
346 pthread_mutex_destroy(&(lock_cs[i]));
356 fprintf(stderr,
"thread=%4d mode=%s lock=%s %s:%d\n",
358 (mode&CRYPTO_LOCK)?
"l":
"u",
359 (type&CRYPTO_READ)?
"r":
"w",file,line);
363 fprintf(stderr,
"(t,m,f,l) %ld %d %s %d\n",
367 if (mode & CRYPTO_LOCK)
369 pthread_mutex_lock(&(lock_cs[type]));
374 pthread_mutex_unlock(&(lock_cs[type]));
382 ret=(
unsigned long)pthread_self();