summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcsilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50>2009-04-22 22:53:41 +0000
committercsilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50>2009-04-22 22:53:41 +0000
commit1894763f57b00f72a720c4c126815c073d9ed0f3 (patch)
treef37fee0ba3f0563ef5c20479d3634cafc3843816
parenta63235c4331445d718d151a2a659ec9687a0b8c8 (diff)
downloadgperftools-1894763f57b00f72a720c4c126815c073d9ed0f3.tar.gz
Make sure we don't clobber GetLastError() (for windows).
git-svn-id: http://gperftools.googlecode.com/svn/trunk@71 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
-rw-r--r--src/windows/port.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/windows/port.h b/src/windows/port.h
index 50866ec..9020dce 100644
--- a/src/windows/port.h
+++ b/src/windows/port.h
@@ -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...