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; }
+void ThreadLocalImpl::removeInstance() { data = 0; }
}
#else
-#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
+#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_GETSPECIFIC)
#include <cassert>
#include <pthread.h>
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<pthread_key_t*>(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<pthread_key_t*>(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<pthread_key_t*>(data);
return pthread_getspecific(*key);
}
+void ThreadLocalImpl::removeInstance() {
+ setInstance(0);
+}
+
}
#elif defined(LLVM_ON_UNIX)