From ea0efc06fdad2019ffceb86d079dd853e9d79cea Mon Sep 17 00:00:00 2001 From: Malcolm Beattie Date: Fri, 24 Oct 1997 13:50:59 +0000 Subject: Improve internal threading API. Introduce win32/win32thread.[ch] to use new API and patch win32 makefile stuff a little. p4raw-id: //depot/perl@172 --- win32/win32thread.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 win32/win32thread.c (limited to 'win32/win32thread.c') diff --git a/win32/win32thread.c b/win32/win32thread.c new file mode 100644 index 0000000000..e74d7e8933 --- /dev/null +++ b/win32/win32thread.c @@ -0,0 +1,30 @@ +#include "EXTERN.h" +#include "perl.h" +#include "win32/win32thread.h" + +void +init_thread_intern(struct thread *thr) +{ + DuplicateHandle(GetCurrentProcess(), + GetCurrentThread(), + GetCurrentProcess(), + &self, + 0, + FALSE, + DUPLICATE_SAME_ACCESS); + if ((thr_key = TlsAlloc()) == TLS_OUT_OF_INDEXES) + croak("panic: TlsAlloc"); + if (TlsSetValue(thr_key, (LPVOID) thr) != TRUE) + croak("panic: TlsSetValue"); +} + +int +thread_create(struct thread *thr, THREAD_RET_TYPE (*fn)(void *)) +{ + DWORD junk; + + MUTEX_LOCK(&thr->mutex); + self = CreateThread(NULL, 0, fn, (void*)thr, 0, &junk); + MUTEX_UNLOCK(&thr->mutex); + return self ? 0 : -1; +} -- cgit v1.2.1