Make sure we don't clobber GetLastError() (for windows).

git-svn-id: http://gperftools.googlecode.com/svn/trunk@71 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
This commit is contained in:
csilvers 2009-04-22 22:53:41 +00:00
parent a63235c433
commit 1894763f57

View File

@ -103,8 +103,12 @@ enum { PTHREAD_ONCE_INIT = 0 }; // important that this be 0! for SpinLock
extern pthread_key_t PthreadKeyCreate(void (*destr_fn)(void*)); // in port.cc
#define perftools_pthread_key_create(pkey, destr_fn) \
*(pkey) = PthreadKeyCreate(destr_fn)
#define perftools_pthread_getspecific(key) \
TlsGetValue(key)
inline void* perftools_pthread_getspecific(DWORD key) {
DWORD err = GetLastError();
void* rv = TlsGetValue(key);
if (err) SetLastError(err);
return rv;
}
#define perftools_pthread_setspecific(key, val) \
TlsSetValue((key), (val))
// NOTE: this is Win98 and later. For Win95 we could use a CRITICAL_SECTION...