aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-12-06 02:12:45 -0800
committerChris Robinson <[email protected]>2013-12-06 02:12:45 -0800
commita846418964fc4942c4bc4eea53f0a536caa4b83f (patch)
treed261e6f3721ba51dcfd01639005d88b80884b214 /Alc
parent3f5914e0949ee12b504ee7254990e007ff8057ef (diff)
Rename pthread wrappers used for Windows to althread
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c30
-rw-r--r--Alc/compat.h34
-rw-r--r--Alc/helpers.c16
3 files changed, 47 insertions, 33 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index e89b459f..59237b0b 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -680,7 +680,7 @@ static const ALchar alExtList[] =
static volatile ALCenum LastNullDeviceError = ALC_NO_ERROR;
/* Thread-local current context */
-static pthread_key_t LocalContext;
+static althread_key_t LocalContext;
/* Process-wide current context */
static ALCcontext *volatile GlobalContext = NULL;
@@ -698,7 +698,7 @@ enum LogLevel LogLevel = LogError;
static ALCboolean TrapALCError = ALC_FALSE;
/* One-time configuration init control */
-static pthread_once_t alc_config_once = PTHREAD_ONCE_INIT;
+static althread_once_t alc_config_once = ALTHREAD_ONCE_INIT;
/* Default effect that applies to sources that don't have an effect on send 0 */
static ALeffect DefaultEffect;
@@ -768,7 +768,7 @@ BOOL APIENTRY DllMain(HINSTANCE hModule,DWORD ul_reason_for_call,LPVOID lpReserv
LockUIntMapRead(&TlsDestructor);
for(i = 0;i < TlsDestructor.size;i++)
{
- void *ptr = pthread_getspecific(TlsDestructor.array[i].key);
+ void *ptr = althread_getspecific(TlsDestructor.array[i].key);
void (*callback)(void*) = (void(*)(void*))TlsDestructor.array[i].value;
if(ptr && callback)
callback(ptr);
@@ -833,7 +833,7 @@ static void alc_init(void)
if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1))
ZScale *= -1.0f;
- pthread_key_create(&LocalContext, ReleaseThreadCtx);
+ althread_key_create(&LocalContext, ReleaseThreadCtx);
InitializeCriticalSection(&ListLock);
ThunkInit();
}
@@ -1107,7 +1107,7 @@ static void alc_initconfig(void)
if((str && str[0]) || ConfigValueStr(NULL, "default-reverb", &str))
LoadReverbPreset(str, &DefaultEffect);
}
-#define DO_INITCONFIG() pthread_once(&alc_config_once, alc_initconfig)
+#define DO_INITCONFIG() althread_once(&alc_config_once, alc_initconfig)
/************************************************
@@ -1148,7 +1148,7 @@ static void alc_deinit_safe(void)
ThunkExit();
DeleteCriticalSection(&ListLock);
- pthread_key_delete(LocalContext);
+ althread_key_delete(LocalContext);
if(LogFile != stderr)
fclose(LogFile);
@@ -2093,10 +2093,10 @@ static void ReleaseContext(ALCcontext *context, ALCdevice *device)
{
ALCcontext *volatile*tmp_ctx;
- if(pthread_getspecific(LocalContext) == context)
+ if(althread_getspecific(LocalContext) == context)
{
WARN("%p released while current on thread\n", context);
- pthread_setspecific(LocalContext, NULL);
+ althread_setspecific(LocalContext, NULL);
ALCcontext_DecRef(context);
}
@@ -2177,7 +2177,7 @@ ALCcontext *GetContextRef(void)
{
ALCcontext *context;
- context = pthread_getspecific(LocalContext);
+ context = althread_getspecific(LocalContext);
if(context)
ALCcontext_IncRef(context);
else
@@ -2746,7 +2746,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void)
{
ALCcontext *Context;
- Context = pthread_getspecific(LocalContext);
+ Context = althread_getspecific(LocalContext);
if(!Context) Context = GlobalContext;
return Context;
@@ -2759,7 +2759,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void)
ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void)
{
ALCcontext *Context;
- Context = pthread_getspecific(LocalContext);
+ Context = althread_getspecific(LocalContext);
return Context;
}
@@ -2781,9 +2781,9 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
context = ExchangePtr((XchgPtr*)&GlobalContext, context);
if(context) ALCcontext_DecRef(context);
- if((context=pthread_getspecific(LocalContext)) != NULL)
+ if((context=althread_getspecific(LocalContext)) != NULL)
{
- pthread_setspecific(LocalContext, NULL);
+ althread_setspecific(LocalContext, NULL);
ALCcontext_DecRef(context);
}
@@ -2805,8 +2805,8 @@ ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
return ALC_FALSE;
}
/* context's reference count is already incremented */
- old = pthread_getspecific(LocalContext);
- pthread_setspecific(LocalContext, context);
+ old = althread_getspecific(LocalContext);
+ althread_setspecific(LocalContext, context);
if(old) ALCcontext_DecRef(old);
return ALC_TRUE;
diff --git a/Alc/compat.h b/Alc/compat.h
index af9f8e84..dbbcce28 100644
--- a/Alc/compat.h
+++ b/Alc/compat.h
@@ -8,21 +8,21 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-typedef DWORD pthread_key_t;
-int pthread_key_create(pthread_key_t *key, void (*callback)(void*));
-int pthread_key_delete(pthread_key_t key);
-void *pthread_getspecific(pthread_key_t key);
-int pthread_setspecific(pthread_key_t key, void *val);
+typedef DWORD althread_key_t;
+int althread_key_create(althread_key_t *key, void (*callback)(void*));
+int althread_key_delete(althread_key_t key);
+void *althread_getspecific(althread_key_t key);
+int althread_setspecific(althread_key_t key, void *val);
-WCHAR *strdupW(const WCHAR *str);
-
-typedef LONG pthread_once_t;
-#define PTHREAD_ONCE_INIT 0
-void pthread_once(pthread_once_t *once, void (*callback)(void));
+typedef LONG althread_once_t;
+#define ALTHREAD_ONCE_INIT 0
+void althread_once(althread_once_t *once, void (*callback)(void));
-static inline int sched_yield(void)
+inline int alsched_yield(void)
{ SwitchToThread(); return 0; }
+WCHAR *strdupW(const WCHAR *str);
+
#define HAVE_DYNLOAD 1
#else
@@ -38,6 +38,18 @@ void LeaveCriticalSection(CRITICAL_SECTION *cs);
ALuint timeGetTime(void);
void Sleep(ALuint t);
+#define althread_key_t pthread_key_t
+#define althread_key_create pthread_key_create
+#define althread_key_delete pthread_key_delete
+#define althread_getspecific pthread_getspecific
+#define althread_setspecific pthread_setspecific
+
+#define althread_once_t pthread_once_t
+#define ALTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
+#define althread_once pthread_once
+
+#define alsched_yield sched_yield
+
#if defined(HAVE_DLFCN_H)
#define HAVE_DYNLOAD 1
#endif
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 6c6c88e2..30c5537e 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -291,18 +291,20 @@ void RestoreFPUMode(const FPUCtl *ctl)
#ifdef _WIN32
-void pthread_once(pthread_once_t *once, void (*callback)(void))
+extern inline int alsched_yield(void);
+
+void althread_once(althread_once_t *once, void (*callback)(void))
{
LONG ret;
while((ret=InterlockedExchange(once, 1)) == 1)
- sched_yield();
+ alsched_yield();
if(ret == 0)
callback();
InterlockedExchange(once, 2);
}
-int pthread_key_create(pthread_key_t *key, void (*callback)(void*))
+int althread_key_create(althread_key_t *key, void (*callback)(void*))
{
*key = TlsAlloc();
if(callback)
@@ -310,17 +312,17 @@ int pthread_key_create(pthread_key_t *key, void (*callback)(void*))
return 0;
}
-int pthread_key_delete(pthread_key_t key)
+int althread_key_delete(althread_key_t key)
{
InsertUIntMapEntry(&TlsDestructor, key, NULL);
TlsFree(key);
return 0;
}
-void *pthread_getspecific(pthread_key_t key)
+void *althread_getspecific(althread_key_t key)
{ return TlsGetValue(key); }
-int pthread_setspecific(pthread_key_t key, void *val)
+int althread_setspecific(althread_key_t key, void *val)
{
TlsSetValue(key, val);
return 0;
@@ -524,7 +526,7 @@ void SetRTPriority(void)
static void Lock(volatile ALenum *l)
{
while(ExchangeInt(l, AL_TRUE) == AL_TRUE)
- sched_yield();
+ alsched_yield();
}
static void Unlock(volatile ALenum *l)