aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-04-17 00:11:12 -0700
committerChris Robinson <[email protected]>2014-04-17 00:11:12 -0700
commitc3b1c31d9b530e64e84805435784ec53eb5ea745 (patch)
tree4d289aa82e96d6fbba5242889f755e02c3820420 /OpenAL32
parent8cc3d05949b9c2750a5460488cac58c82174e85c (diff)
Rename althread_key_ wrappers to altss_ and move it to threads.h/c
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/threads.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/OpenAL32/Include/threads.h b/OpenAL32/Include/threads.h
index f0ee1b5c..0c9601c9 100644
--- a/OpenAL32/Include/threads.h
+++ b/OpenAL32/Include/threads.h
@@ -20,6 +20,7 @@ enum {
typedef int (*althrd_start_t)(void*);
+typedef void (*altss_dtor_t)(void*);
#ifdef _WIN32
@@ -28,6 +29,7 @@ typedef int (*althrd_start_t)(void*);
typedef HANDLE althrd_t;
typedef CRITICAL_SECTION almtx_t;
+typedef DWORD altss_t;
#ifndef __MINGW32__
struct timespec {
@@ -89,6 +91,18 @@ inline int almtx_trylock(almtx_t *mtx)
return althrd_success;
}
+
+inline void *altss_get(altss_t tss_id)
+{
+ return TlsGetValue(tss_id);
+}
+
+inline int altss_set(altss_t tss_id, void *val)
+{
+ TlsSetValue(tss_id, val);
+ return althrd_success;
+}
+
#else
#include <stdint.h>
@@ -98,6 +112,7 @@ inline int almtx_trylock(almtx_t *mtx)
typedef pthread_t althrd_t;
typedef pthread_mutex_t almtx_t;
+typedef pthread_key_t altss_t;
inline althrd_t althrd_current(void)
@@ -166,6 +181,19 @@ inline int almtx_trylock(almtx_t *mtx)
return althrd_error;
}
+
+inline void *altss_get(altss_t tss_id)
+{
+ return pthread_getspecific(tss_id);
+}
+
+inline int altss_set(altss_t tss_id, void *val)
+{
+ if(pthread_setspecific(tss_id, val) != 0)
+ return althrd_error;
+ return althrd_success;
+}
+
#endif
@@ -177,6 +205,9 @@ int almtx_init(almtx_t *mtx, int type);
void almtx_destroy(almtx_t *mtx);
int almtx_timedlock(almtx_t *mtx, const struct timespec *ts);
+int altss_create(altss_t *tss_id, altss_dtor_t callback);
+void altss_delete(altss_t tss_id);
+
void SetThreadName(const char *name);