aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-06-25 23:31:18 +0000
committerOwen Anderson <resistor@mac.com>2009-06-25 23:31:18 +0000
commit438d3946afc9ba502d56269d1a1d2c18d38d7e23 (patch)
treef60b9da38d11a41af6bed85f3ba03b511baeb819
parent7e026b74dd1fdaa81a147488423571c59079d9bb (diff)
downloadexternal_llvm-438d3946afc9ba502d56269d1a1d2c18d38d7e23.zip
external_llvm-438d3946afc9ba502d56269d1a1d2c18d38d7e23.tar.gz
external_llvm-438d3946afc9ba502d56269d1a1d2c18d38d7e23.tar.bz2
Add support for const thread locals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74226 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/System/ThreadLocal.h4
-rw-r--r--lib/System/ThreadLocal.cpp8
-rw-r--r--lib/System/Win32/ThreadLocal.inc4
3 files changed, 8 insertions, 8 deletions
diff --git a/include/llvm/System/ThreadLocal.h b/include/llvm/System/ThreadLocal.h
index 7627be2..39b1e64 100644
--- a/include/llvm/System/ThreadLocal.h
+++ b/include/llvm/System/ThreadLocal.h
@@ -24,8 +24,8 @@ namespace llvm {
public:
ThreadLocalImpl();
virtual ~ThreadLocalImpl();
- void setInstance(void* d);
- void* getInstance();
+ void setInstance(const void* d);
+ const void* getInstance();
};
template<class T>
diff --git a/lib/System/ThreadLocal.cpp b/lib/System/ThreadLocal.cpp
index 74afa3e..f8b00d1 100644
--- a/lib/System/ThreadLocal.cpp
+++ b/lib/System/ThreadLocal.cpp
@@ -25,8 +25,8 @@ namespace llvm {
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 @@ ThreadLocalImpl::~ThreadLocalImpl() {
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);
}
diff --git a/lib/System/Win32/ThreadLocal.inc b/lib/System/Win32/ThreadLocal.inc
index 5bba8b5..0ba3be4 100644
--- a/lib/System/Win32/ThreadLocal.inc
+++ b/lib/System/Win32/ThreadLocal.inc
@@ -35,12 +35,12 @@ ThreadLocalImpl::~ThreadLocalImpl() {
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);