X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSystem%2FThreadLocal.cpp;h=f6a55a1c0b9b183b1fbccc7976e52bf95406abbc;hb=e5f77cda25169fcbadc32f0f0b3da2e00ba86b7c;hp=8d119fbf24138b10d918acc4dad349a5b5d8aac6;hpb=27fcfe1364943dadd99fd0ef5af6793f58acc446;p=oota-llvm.git diff --git a/lib/System/ThreadLocal.cpp b/lib/System/ThreadLocal.cpp index 8d119fbf241..f6a55a1c0b9 100644 --- a/lib/System/ThreadLocal.cpp +++ b/lib/System/ThreadLocal.cpp @@ -25,8 +25,9 @@ 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(d);} +const void* ThreadLocalImpl::getInstance() { return data; } +void ThreadLocalImpl::removeInstance() { data = 0; } } #else @@ -43,27 +44,34 @@ ThreadLocalImpl::ThreadLocalImpl() : data(0) { pthread_key_t* key = new pthread_key_t; int errorcode = pthread_key_create(key, NULL); assert(errorcode == 0); - data = key; + (void) errorcode; + data = (void*)key; } ThreadLocalImpl::~ThreadLocalImpl() { pthread_key_t* key = static_cast(data); int errorcode = pthread_key_delete(*key); - assert(errorcode = 0); + assert(errorcode == 0); + (void) errorcode; delete key; } -void ThreadLocalImpl::setInstance(void* d) { +void ThreadLocalImpl::setInstance(const void* d) { pthread_key_t* key = static_cast(data); int errorcode = pthread_setspecific(*key, d); assert(errorcode == 0); + (void) errorcode; } -void* ThreadLocalImpl::getInstance() { +const void* ThreadLocalImpl::getInstance() { pthread_key_t* key = static_cast(data); return pthread_getspecific(*key); } +void ThreadLocalImpl::removeInstance() { + setInstance(0); +} + } #elif defined(LLVM_ON_UNIX)