[llvm-commits] [llvm] r74226 - in /llvm/trunk: include/llvm/System/ThreadLocal.h lib/System/ThreadLocal.cpp lib/System/Win32/ThreadLocal.inc
Owen Anderson
resistor at mac.com
Thu Jun 25 16:31:18 PDT 2009
Author: resistor
Date: Thu Jun 25 18:31:18 2009
New Revision: 74226
URL: http://llvm.org/viewvc/llvm-project?rev=74226&view=rev
Log:
Add support for const thread locals.
Modified:
llvm/trunk/include/llvm/System/ThreadLocal.h
llvm/trunk/lib/System/ThreadLocal.cpp
llvm/trunk/lib/System/Win32/ThreadLocal.inc
Modified: llvm/trunk/include/llvm/System/ThreadLocal.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/ThreadLocal.h?rev=74226&r1=74225&r2=74226&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/ThreadLocal.h (original)
+++ llvm/trunk/include/llvm/System/ThreadLocal.h Thu Jun 25 18:31:18 2009
@@ -24,8 +24,8 @@
public:
ThreadLocalImpl();
virtual ~ThreadLocalImpl();
- void setInstance(void* d);
- void* getInstance();
+ void setInstance(const void* d);
+ const void* getInstance();
};
template<class T>
Modified: llvm/trunk/lib/System/ThreadLocal.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/ThreadLocal.cpp?rev=74226&r1=74225&r2=74226&view=diff
==============================================================================
--- llvm/trunk/lib/System/ThreadLocal.cpp (original)
+++ llvm/trunk/lib/System/ThreadLocal.cpp Thu Jun 25 18:31:18 2009
@@ -25,8 +25,8 @@
using namespace sys;
ThreadLocalImpl::ThreadLocalImpl() { }
ThreadLocalImpl::~ThreadLocalImpl() { }
-void ThreadLocalImpl::setInstance(void* d) { data = d; }
-void* ThreadLocalImpl::getInstance() { return data; }
+void ThreadLocalImpl::setInstance(const void* d) { data = const_cast<void*>(d);}
+const void* ThreadLocalImpl::getInstance() { return data; }
}
#else
@@ -53,13 +53,13 @@
delete key;
}
-void ThreadLocalImpl::setInstance(void* d) {
+void ThreadLocalImpl::setInstance(const void* d) {
pthread_key_t* key = static_cast<pthread_key_t*>(data);
int errorcode = pthread_setspecific(*key, d);
assert(errorcode == 0);
}
-void* ThreadLocalImpl::getInstance() {
+const void* ThreadLocalImpl::getInstance() {
pthread_key_t* key = static_cast<pthread_key_t*>(data);
return pthread_getspecific(*key);
}
Modified: llvm/trunk/lib/System/Win32/ThreadLocal.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/ThreadLocal.inc?rev=74226&r1=74225&r2=74226&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/ThreadLocal.inc (original)
+++ llvm/trunk/lib/System/Win32/ThreadLocal.inc Thu Jun 25 18:31:18 2009
@@ -35,12 +35,12 @@
delete tls;
}
-void* ThreadLocalImpl::getInstance() {
+const void* ThreadLocalImpl::getInstance() {
DWORD* tls = static_cast<DWORD*>(data);
return TlsGetValue(*tls);
}
-void ThreadLocalImpl::setInstance(void* d){
+void ThreadLocalImpl::setInstance(const void* d){
DWORD* tls = static_cast<DWORD*>(data);
int errorcode = TlsSetValue(*tls, d);
assert(errorcode == 0);
More information about the llvm-commits
mailing list