diff --git a/3rdparty/3rdpartyDLL.vsprops b/3rdparty/3rdpartyDLL.vsprops index 0c5392da35..b1d1e2e0fc 100644 --- a/3rdparty/3rdpartyDLL.vsprops +++ b/3rdparty/3rdpartyDLL.vsprops @@ -23,4 +23,8 @@ SubSystem="2" ImportLibrary="$(OutDir)\$(ProjectName).lib" /> + diff --git a/3rdparty/w32pthreads/global.c b/3rdparty/w32pthreads/global.c index d460a42c23..4e101f6cf0 100644 --- a/3rdparty/w32pthreads/global.c +++ b/3rdparty/w32pthreads/global.c @@ -37,18 +37,18 @@ #include "ptw32pch.h" +__declspec(thread) ptw32_thread_t* ptw32_selfThread = NULL; int ptw32_processInitialized = PTW32_FALSE; ptw32_thread_t * ptw32_threadReuseTop = PTW32_THREAD_REUSE_EMPTY; ptw32_thread_t * ptw32_threadReuseBottom = PTW32_THREAD_REUSE_EMPTY; -pthread_key_t ptw32_selfThreadKey = NULL; pthread_key_t ptw32_cleanupKey = NULL; pthread_cond_t ptw32_cond_list_head = NULL; pthread_cond_t ptw32_cond_list_tail = NULL; int ptw32_concurrency = 0; -/* What features have been auto-detaected */ +/* What features have been auto-detected */ int ptw32_features = 0; BOOL ptw32_smp_system = PTW32_TRUE; /* Safer if assumed true initially. */ diff --git a/3rdparty/w32pthreads/include/implement.h b/3rdparty/w32pthreads/include/implement.h index bb3a5deeb3..0439fd2cbe 100644 --- a/3rdparty/w32pthreads/include/implement.h +++ b/3rdparty/w32pthreads/include/implement.h @@ -136,7 +136,7 @@ struct ptw32_thread_t_ void *parms; int ptErrno; int detachState; - pthread_mutex_t threadLock; /* Used for serialised access to public thread state */ + pthread_mutex_t threadLock; /* Used for serialized access to public thread state */ int sched_priority; /* As set, not as currently is */ pthread_mutex_t cancelLock; /* Used for async-cancel safety */ int cancelState; @@ -528,10 +528,11 @@ extern "C" { #endif /* __cplusplus */ +extern __declspec(thread) ptw32_thread_t* ptw32_selfThread; + extern int ptw32_processInitialized; extern ptw32_thread_t * ptw32_threadReuseTop; extern ptw32_thread_t * ptw32_threadReuseBottom; -extern pthread_key_t ptw32_selfThreadKey; extern pthread_key_t ptw32_cleanupKey; extern pthread_cond_t ptw32_cond_list_head; extern pthread_cond_t ptw32_cond_list_tail; diff --git a/3rdparty/w32pthreads/pthread_exit.c b/3rdparty/w32pthreads/pthread_exit.c index a4903129b6..08d98dc835 100644 --- a/3rdparty/w32pthreads/pthread_exit.c +++ b/3rdparty/w32pthreads/pthread_exit.c @@ -65,13 +65,7 @@ pthread_exit (void *value_ptr) * ------------------------------------------------------ */ { - ptw32_thread_t * sp; - - /* - * Don't use pthread_self() to avoid creating an implicit POSIX thread handle - * unnecessarily. - */ - sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + ptw32_thread_t * sp = ptw32_selfThread; #ifdef _UWIN if (--pthread_count <= 0) diff --git a/3rdparty/w32pthreads/pthread_self.c b/3rdparty/w32pthreads/pthread_self.c index d72a0971d0..57887dbb04 100644 --- a/3rdparty/w32pthreads/pthread_self.c +++ b/3rdparty/w32pthreads/pthread_self.c @@ -61,14 +61,7 @@ pthread_self (void) { pthread_t self; pthread_t nil = {NULL, 0}; - ptw32_thread_t * sp; - -#ifdef _UWIN - if (!ptw32_selfThreadKey) - return nil; -#endif - - sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + ptw32_thread_t * sp = ptw32_selfThread; if (sp != NULL) { @@ -128,8 +121,7 @@ pthread_self (void) * because the new handle is not yet public. */ sp->sched_priority = GetThreadPriority (sp->threadH); - - pthread_setspecific (ptw32_selfThreadKey, (void *) sp); + ptw32_selfThread = ptw32_new().p; } } diff --git a/3rdparty/w32pthreads/pthread_setspecific.c b/3rdparty/w32pthreads/pthread_setspecific.c index f06b696166..00bce01fc1 100644 --- a/3rdparty/w32pthreads/pthread_setspecific.c +++ b/3rdparty/w32pthreads/pthread_setspecific.c @@ -68,40 +68,16 @@ pthread_setspecific (pthread_key_t key, const void *value) pthread_t self; int result = 0; - if (key != ptw32_selfThreadKey) - { - /* - * Using pthread_self will implicitly create - * an instance of pthread_t for the current - * thread if one wasn't explicitly created - */ - self = pthread_self (); - if (self.p == NULL) - { - return ENOENT; - } - } - else - { - /* - * Resolve catch-22 of registering thread with selfThread - * key - */ - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - - if (sp == NULL) - { - if (value == NULL) - { - return ENOENT; - } - self = *((pthread_t *) value); - } - else - { - self = sp->ptHandle; - } - } + /* + * Using pthread_self will implicitly create + * an instance of pthread_t for the current + * thread if one wasn't explicitly created + */ + self = pthread_self (); + if (self.p == NULL) + { + return ENOENT; + } result = 0; diff --git a/3rdparty/w32pthreads/pthread_win32_attach_detach_np.c b/3rdparty/w32pthreads/pthread_win32_attach_detach_np.c index ebd6b59f94..627f103302 100644 --- a/3rdparty/w32pthreads/pthread_win32_attach_detach_np.c +++ b/3rdparty/w32pthreads/pthread_win32_attach_detach_np.c @@ -213,7 +213,7 @@ pthread_win32_process_detach_np () { if (ptw32_processInitialized) { - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + ptw32_thread_t * sp = ptw32_selfThread; if (sp != NULL) { @@ -224,7 +224,8 @@ pthread_win32_process_detach_np () if (sp->detachState == PTHREAD_CREATE_DETACHED) { ptw32_threadDestroy (sp->ptHandle); - TlsSetValue (ptw32_selfThreadKey->key, NULL); + free(ptw32_selfThread); + ptw32_selfThread = NULL; } } @@ -277,7 +278,7 @@ pthread_win32_thread_detach_np () * Don't use pthread_self() - to avoid creating an implicit POSIX thread handle * unnecessarily. */ - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + ptw32_thread_t * sp = ptw32_selfThread; if (sp != NULL) // otherwise Win32 thread with no implicit POSIX handle. { @@ -294,8 +295,8 @@ pthread_win32_thread_detach_np () if (sp->detachState == PTHREAD_CREATE_DETACHED) { ptw32_threadDestroy (sp->ptHandle); - - TlsSetValue (ptw32_selfThreadKey->key, NULL); + free(ptw32_selfThread); + ptw32_selfThread = NULL; } } } diff --git a/3rdparty/w32pthreads/pthreads_2008.vcproj b/3rdparty/w32pthreads/pthreads_2008.vcproj index 354578ba38..d7efd24dd0 100644 --- a/3rdparty/w32pthreads/pthreads_2008.vcproj +++ b/3rdparty/w32pthreads/pthreads_2008.vcproj @@ -6,6 +6,7 @@ ProjectGUID="{26511268-2902-4997-8421-ECD7055F9E28}" RootNamespace="pthreads" Keyword="Win32Proj" + TargetFrameworkVersion="0" > - - - - - - - - - diff --git a/3rdparty/w32pthreads/ptw32_processInitialize.c b/3rdparty/w32pthreads/ptw32_processInitialize.c index d13b0226f0..bdd9ca9791 100644 --- a/3rdparty/w32pthreads/ptw32_processInitialize.c +++ b/3rdparty/w32pthreads/ptw32_processInitialize.c @@ -80,10 +80,8 @@ ptw32_processInitialize (void) /* * Initialize Keys */ - if ((pthread_key_create (&ptw32_selfThreadKey, NULL) != 0) || - (pthread_key_create (&ptw32_cleanupKey, NULL) != 0)) + if (pthread_key_create (&ptw32_cleanupKey, NULL) != 0) { - ptw32_processTerminate (); } diff --git a/3rdparty/w32pthreads/ptw32_processTerminate.c b/3rdparty/w32pthreads/ptw32_processTerminate.c index d2dfa7a247..5400714976 100644 --- a/3rdparty/w32pthreads/ptw32_processTerminate.c +++ b/3rdparty/w32pthreads/ptw32_processTerminate.c @@ -66,23 +66,9 @@ ptw32_processTerminate (void) { ptw32_thread_t * tp, * tpNext; - if (ptw32_selfThreadKey != NULL) - { - /* - * Release ptw32_selfThreadKey - */ - pthread_key_delete (ptw32_selfThreadKey); - - ptw32_selfThreadKey = NULL; - } - if (ptw32_cleanupKey != NULL) { - /* - * Release ptw32_cleanupKey - */ pthread_key_delete (ptw32_cleanupKey); - ptw32_cleanupKey = NULL; } diff --git a/3rdparty/w32pthreads/ptw32_threadStart.c b/3rdparty/w32pthreads/ptw32_threadStart.c index 5c0fe0e857..028ba768a6 100644 --- a/3rdparty/w32pthreads/ptw32_threadStart.c +++ b/3rdparty/w32pthreads/ptw32_threadStart.c @@ -165,7 +165,7 @@ ptw32_threadStart (void *vthreadParms) } #endif - pthread_setspecific (ptw32_selfThreadKey, sp); + ptw32_selfThread = sp; sp->state = PThreadStateRunning; diff --git a/3rdparty/w32pthreads/ptw32_throw.c b/3rdparty/w32pthreads/ptw32_throw.c index 493f4e4dc1..c54a7c0a1c 100644 --- a/3rdparty/w32pthreads/ptw32_throw.c +++ b/3rdparty/w32pthreads/ptw32_throw.c @@ -53,7 +53,7 @@ ptw32_throw (DWORD exception) * Don't use pthread_self() to avoid creating an implicit POSIX thread handle * unnecessarily. */ - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); + ptw32_thread_t * sp = ptw32_selfThread; #ifdef __CLEANUP_SEH DWORD exceptionInformation[3]; @@ -81,7 +81,7 @@ ptw32_throw (DWORD exception) exitCode = (unsigned) PTHREAD_CANCELED; break; case PTW32_EPS_EXIT: - exitCode = (unsigned) sp->exitStatus;; + exitCode = (unsigned) sp->exitStatus; break; } diff --git a/3rdparty/w32pthreads/w32pthreads.v2.rc b/3rdparty/w32pthreads/w32pthreads.rc similarity index 100% rename from 3rdparty/w32pthreads/w32pthreads.v2.rc rename to 3rdparty/w32pthreads/w32pthreads.rc