mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-14 15:39:00 +00:00
Add support for const thread locals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74226 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7e026b74dd
commit
438d3946af
@ -24,8 +24,8 @@ namespace llvm {
|
|||||||
public:
|
public:
|
||||||
ThreadLocalImpl();
|
ThreadLocalImpl();
|
||||||
virtual ~ThreadLocalImpl();
|
virtual ~ThreadLocalImpl();
|
||||||
void setInstance(void* d);
|
void setInstance(const void* d);
|
||||||
void* getInstance();
|
const void* getInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -25,8 +25,8 @@ namespace llvm {
|
|||||||
using namespace sys;
|
using namespace sys;
|
||||||
ThreadLocalImpl::ThreadLocalImpl() { }
|
ThreadLocalImpl::ThreadLocalImpl() { }
|
||||||
ThreadLocalImpl::~ThreadLocalImpl() { }
|
ThreadLocalImpl::~ThreadLocalImpl() { }
|
||||||
void ThreadLocalImpl::setInstance(void* d) { data = d; }
|
void ThreadLocalImpl::setInstance(const void* d) { data = const_cast<void*>(d);}
|
||||||
void* ThreadLocalImpl::getInstance() { return data; }
|
const void* ThreadLocalImpl::getInstance() { return data; }
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -53,13 +53,13 @@ ThreadLocalImpl::~ThreadLocalImpl() {
|
|||||||
delete key;
|
delete key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadLocalImpl::setInstance(void* d) {
|
void ThreadLocalImpl::setInstance(const void* d) {
|
||||||
pthread_key_t* key = static_cast<pthread_key_t*>(data);
|
pthread_key_t* key = static_cast<pthread_key_t*>(data);
|
||||||
int errorcode = pthread_setspecific(*key, d);
|
int errorcode = pthread_setspecific(*key, d);
|
||||||
assert(errorcode == 0);
|
assert(errorcode == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ThreadLocalImpl::getInstance() {
|
const void* ThreadLocalImpl::getInstance() {
|
||||||
pthread_key_t* key = static_cast<pthread_key_t*>(data);
|
pthread_key_t* key = static_cast<pthread_key_t*>(data);
|
||||||
return pthread_getspecific(*key);
|
return pthread_getspecific(*key);
|
||||||
}
|
}
|
||||||
|
@ -35,12 +35,12 @@ ThreadLocalImpl::~ThreadLocalImpl() {
|
|||||||
delete tls;
|
delete tls;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ThreadLocalImpl::getInstance() {
|
const void* ThreadLocalImpl::getInstance() {
|
||||||
DWORD* tls = static_cast<DWORD*>(data);
|
DWORD* tls = static_cast<DWORD*>(data);
|
||||||
return TlsGetValue(*tls);
|
return TlsGetValue(*tls);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadLocalImpl::setInstance(void* d){
|
void ThreadLocalImpl::setInstance(const void* d){
|
||||||
DWORD* tls = static_cast<DWORD*>(data);
|
DWORD* tls = static_cast<DWORD*>(data);
|
||||||
int errorcode = TlsSetValue(*tls, d);
|
int errorcode = TlsSetValue(*tls, d);
|
||||||
assert(errorcode == 0);
|
assert(errorcode == 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user