nthreads = 1;
cvcache = newHV();
curcop = &compiling;
- thr->flags = THRf_NORMAL;
+ thr->flags = THRf_R_JOINABLE;
+ MUTEX_INIT(&thr->mutex);
thr->next = thr;
thr->prev = thr;
- #ifdef FAKE_THREADS
- self = thr;
- thr->next_run = thr->prev_run = thr;
- thr->wait_queue = 0;
- thr->private = 0;
thr->tid = 0;
+ #ifdef HAVE_THREAD_INTERN
+ init_thread_intern(thr);
#else
+#ifdef WIN32
+ DuplicateHandle(GetCurrentProcess(),
+ GetCurrentThread(),
+ GetCurrentProcess(),
+ &self,
+ 0,
+ FALSE,
+ DUPLICATE_SAME_ACCESS);
+ /* XXX TlsAlloc() should probably be done in the DLL entry
+ * point also.
+ */
+ if ((thr_key = TlsAlloc()) == TLS_OUT_OF_INDEXES)
+ croak("panic: pthread_key_create");
+ if (TlsSetValue(thr_key, (LPVOID) thr) != TRUE)
+ croak("panic: pthread_setspecific");
+#else
self = pthread_self();
if (pthread_key_create(&thr_key, 0))
croak("panic: pthread_key_create");