From 5eceb593e9cfd57611e99217e2f9c346bb10305c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 28 Aug 2011 17:21:01 -0700 Subject: Emulate pthread TLS functions in Windows --- Alc/helpers.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Alc/helpers.c') diff --git a/Alc/helpers.c b/Alc/helpers.c index 43ab43b9..85433368 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -59,6 +59,32 @@ void pthread_once(pthread_once_t *once, void (*callback)(void)) InterlockedExchange(once, 2); } + +int pthread_key_create(pthread_key_t *key, void (*callback)(void*)) +{ + *key = TlsAlloc(); + if(callback) + InsertUIntMapEntry(&TlsDestructor, *key, callback); + return 0; +} + +int pthread_key_delete(pthread_key_t key) +{ + InsertUIntMapEntry(&TlsDestructor, key, NULL); + TlsFree(key); + return 0; +} + +void *pthread_getspecific(pthread_key_t key) +{ return TlsGetValue(key); } + +int pthread_setspecific(pthread_key_t key, void *val) +{ + TlsSetValue(key, val); + return 0; +} + + void *LoadLib(const char *name) { return LoadLibraryA(name); } void CloseLib(void *handle) -- cgit v1.2.3