mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 08:17:40 +00:00
ThreadLocal: Return a mutable pointer if templated with a non-const type
It makes more sense for ThreadLocal<const T>::get to return a const T* and ThreadLocal<T>::get to return a T*. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224225 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -31,7 +31,7 @@ void ThreadLocalImpl::setInstance(const void* d) {
|
||||
void **pd = reinterpret_cast<void**>(&data);
|
||||
*pd = const_cast<void*>(d);
|
||||
}
|
||||
const void* ThreadLocalImpl::getInstance() {
|
||||
void *ThreadLocalImpl::getInstance() {
|
||||
void **pd = reinterpret_cast<void**>(&data);
|
||||
return *pd;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void ThreadLocalImpl::setInstance(const void* d) {
|
||||
(void) errorcode;
|
||||
}
|
||||
|
||||
const void* ThreadLocalImpl::getInstance() {
|
||||
void *ThreadLocalImpl::getInstance() {
|
||||
pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
|
||||
return pthread_getspecific(*key);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@ using namespace sys;
|
||||
ThreadLocalImpl::ThreadLocalImpl() : data() { }
|
||||
ThreadLocalImpl::~ThreadLocalImpl() { }
|
||||
void ThreadLocalImpl::setInstance(const void* d) { data = const_cast<void*>(d);}
|
||||
const void* ThreadLocalImpl::getInstance() { return data; }
|
||||
void *ThreadLocalImpl::getInstance() { return data; }
|
||||
void ThreadLocalImpl::removeInstance() { setInstance(0); }
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ ThreadLocalImpl::~ThreadLocalImpl() {
|
||||
TlsFree(*tls);
|
||||
}
|
||||
|
||||
const void* ThreadLocalImpl::getInstance() {
|
||||
void *ThreadLocalImpl::getInstance() {
|
||||
DWORD* tls = reinterpret_cast<DWORD*>(&data);
|
||||
return TlsGetValue(*tls);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user