From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:25 +0000 (-0700) Subject: Fixes for VThread change X-Git-Tag: stable-10.2.0~339 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c1eb3bb5e7fbff13156d05a037bf652cf2bdc384;p=thirdparty%2Fopen-vm-tools.git Fixes for VThread change Two fixes for build issues - numVCPU.c: Windows compiler apparently doesn't like empty initalizer lists. Fill in with a value. - vthreadBase.c: when VTHREAD_INVALID_ID went from -1 to 0, missed some adjustment code in VThreadBaseSetLocal and VThreadBaseGetLocal which "adjusted" the value by +1/-1 so default-zero would work correctly. The value no longer needs adjustment. This did not impact Linux because Linux uses have a thread-local cache which returned before this slow path. --- diff --git a/open-vm-tools/lib/misc/vthreadBase.c b/open-vm-tools/lib/misc/vthreadBase.c index 01785060c..ea6edc5ec 100644 --- a/open-vm-tools/lib/misc/vthreadBase.c +++ b/open-vm-tools/lib/misc/vthreadBase.c @@ -472,11 +472,6 @@ VThreadBaseAreKeysInited(void) * the compiler to inline this with the expectation that "local" * is a compile time constant. * - * To facilitate lazy initialization we special case - * VTHREAD_LOCAL_ID slightly and arrange so that if its value is - * read before it is initialized we return -1 instead of 0 (since - * 0 is used as a real thread id). - * * Note that we use store the thread local value using pthreads * even when HAVE_TLS is defined. This way we continue to use * the same pthread destructor path for cleanup as we would @@ -489,26 +484,23 @@ static INLINE Bool VThreadBaseSetLocal(VThreadLocal local, void *value) { VThreadBaseKeyType key; - void *adjustedValue = value; Bool success; ASSERT(VThreadBaseAreKeysInited()); if (local == VTHREAD_LOCAL_BASE) { key = Atomic_Read(&vthreadBaseGlobals.baseKey); } else { ASSERT(local == VTHREAD_LOCAL_ID); - /* VThreadGetLocal compensates for this, lets the default be -1. */ - adjustedValue = (void*)((uintptr_t)adjustedValue + 1); key = Atomic_Read(&vthreadBaseGlobals.threadIDKey); } ASSERT(key != VTHREADBASE_INVALID_KEY); #if defined _WIN32 #if defined VM_WIN_UWP - success = FlsSetValue(key, adjustedValue); + success = FlsSetValue(key, value); #else - success = TlsSetValue(key, adjustedValue); + success = TlsSetValue(key, value); #endif #else - success = pthread_setspecific(key, adjustedValue) == 0; + success = pthread_setspecific(key, value) == 0; #endif #ifdef HAVE_TLS if (success) { @@ -569,9 +561,6 @@ VThreadBaseGetLocal(VThreadLocal local) #else result = pthread_getspecific(key); #endif - if (local == VTHREAD_LOCAL_ID) { - result = (void*)((uintptr_t)result - 1); /* See VThreadBaseSetLocal. */ - } #endif return result;