diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 4 | ||||
-rw-r--r-- | Alc/compat.h | 8 | ||||
-rw-r--r-- | Alc/helpers.c | 11 | ||||
-rw-r--r-- | Alc/threads.c | 12 |
4 files changed, 14 insertions, 21 deletions
@@ -737,7 +737,7 @@ enum LogLevel LogLevel = LogError; static ALCboolean TrapALCError = ALC_FALSE; /* One-time configuration init control */ -static althread_once_t alc_config_once = ALTHREAD_ONCE_INIT; +static alonce_flag alc_config_once = AL_ONCE_INIT; /* Default effect that applies to sources that don't have an effect on send 0 */ static ALeffect DefaultEffect; @@ -1139,7 +1139,7 @@ static void alc_initconfig(void) if((str && str[0]) || ConfigValueStr(NULL, "default-reverb", &str)) LoadReverbPreset(str, &DefaultEffect); } -#define DO_INITCONFIG() althread_once(&alc_config_once, alc_initconfig) +#define DO_INITCONFIG() alcall_once(&alc_config_once, alc_initconfig) /************************************************ diff --git a/Alc/compat.h b/Alc/compat.h index 50516ce8..2765ef18 100644 --- a/Alc/compat.h +++ b/Alc/compat.h @@ -8,10 +8,6 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> -typedef LONG althread_once_t; -#define ALTHREAD_ONCE_INIT 0 -void althread_once(althread_once_t *once, void (*callback)(void)); - WCHAR *strdupW(const WCHAR *str); /* Opens a file with standard I/O. The filename is expected to be UTF-8. */ @@ -23,10 +19,6 @@ FILE *al_fopen(const char *fname, const char *mode); #include <pthread.h> -#define althread_once_t pthread_once_t -#define ALTHREAD_ONCE_INIT PTHREAD_ONCE_INIT -#define althread_once pthread_once - #define al_fopen(_n, _m) fopen((_n), (_m)) #if defined(HAVE_DLFCN_H) && !defined(IN_IDE_PARSER) diff --git a/Alc/helpers.c b/Alc/helpers.c index 79dac143..e1e94f10 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -311,17 +311,6 @@ void RestoreFPUMode(const FPUCtl *ctl) #ifdef _WIN32 -void althread_once(althread_once_t *once, void (*callback)(void)) -{ - LONG ret; - while((ret=InterlockedExchange(once, 1)) == 1) - althrd_yield(); - if(ret == 0) - callback(); - InterlockedExchange(once, 2); -} - - static WCHAR *FromUTF8(const char *str) { WCHAR *out = NULL; diff --git a/Alc/threads.c b/Alc/threads.c index d0aea6e8..d9dabec1 100644 --- a/Alc/threads.c +++ b/Alc/threads.c @@ -294,6 +294,17 @@ int altimespec_get(struct timespec *ts, int base) return 0; } + +void alcall_once(alonce_flag *once, void (*callback)(void)) +{ + LONG ret; + while((ret=InterlockedExchange(once, 1)) == 1) + althrd_yield(); + if(ret == 0) + (*callback)(); + InterlockedExchange(once, 2); +} + #else #include <unistd.h> @@ -304,6 +315,7 @@ int altimespec_get(struct timespec *ts, int base) extern inline int althrd_sleep(const struct timespec *ts, struct timespec *rem); +extern inline void alcall_once(alonce_flag *once, void (*callback)(void)); void althrd_setname(althrd_t thr, const char *name) |