3 #include "win32/win32thread.h"
6 init_thread_intern(struct thread *thr)
8 DuplicateHandle(GetCurrentProcess(),
14 DUPLICATE_SAME_ACCESS);
15 if ((thr_key = TlsAlloc()) == TLS_OUT_OF_INDEXES)
16 croak("panic: TlsAlloc");
17 if (TlsSetValue(thr_key, (LPVOID) thr) != TRUE)
18 croak("panic: TlsSetValue");
22 thread_create(struct thread *thr, THREAD_RET_TYPE (*fn)(void *))
26 MUTEX_LOCK(&thr->mutex);
27 thr->self = CreateThread(NULL, 0, fn, (void*)thr, 0, &junk);
28 MUTEX_UNLOCK(&thr->mutex);
29 return thr->self ? 0 : -1;