From 94cfb27da3941eea2b20867eacc09a5b91168438 Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 30 Jul 1998 13:51:57 +0000 Subject: Thu Jul 30 23:12:45 1998 Ross Johnson * implement.h: Remove _pthread_find_entry() prototype. * private.c: Extend comments. Remove _pthread_find_entry() - no longer needed. * create.c (_pthread_start_call): Add call to TlsSetValue() to store the thread ID. * dll.c (PthreadsEntryPoint): Implement. This is called whenever a process loads the DLL. Used to initialise thread local storage. * implement.h: Add _pthread_threadID_TlsIndex. Add ()s around _PTHREAD_VALID expression. * misc.c (pthread_self): Re-implement using Win32 TLS to store the threads own ID. --- misc.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'misc.c') diff --git a/misc.c b/misc.c index 9834630..ca39513 100644 --- a/misc.c +++ b/misc.c @@ -44,23 +44,16 @@ pthread_once(pthread_once_t *once_control, pthread_t pthread_self(void) { - /* It looks like a pthread_t needs to be a HANDLE, but Win32 also has - another way of identifying threads: their thread id. We hope - that all of the Win32 functions we are going to use only need - HANDLEs. The morons. */ + pthread_t ret; + + ret = (pthread_t) TlsGetValue(_pthread_threadID_TlsIndex); - /* FIXME: Need a new lookup method with the new thread allocation - scheme. - - We can use the Win32 handle though as a basis (perhaps - to look up a table) because pthread_self() will never be called - after the Win32 thread has terminated (unless we can raise - ourselves from the dead!), and therefore the Win32 handle cannot - have been reused yet. */ + if (ret == 0) + { + /* FIXME: Oh no! This can't happen. */ + } -#if 0 - return GetCurrentThread(); -#endif + return ret; } int -- cgit v1.2.3