aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-20 01:07:27 -0700
committerChris Robinson <[email protected]>2011-08-20 01:07:27 -0700
commitb036bc9e049efe97a5532b24e08640e7f5cf3934 (patch)
tree390b9ef8b98946c8ed418e189ed2076a916c9520 /Alc
parent9989f33fc24042578bf4bf2c50a06a6366d07c1d (diff)
More closely emulate pthread_once in Windows
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 7322d924..06294392 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -694,23 +694,23 @@ static void alc_initconfig(void)
}
#ifdef _WIN32
-static struct once_control {
- LONG canpass;
- LONG hasrun;
-} once_control = { TRUE, FALSE };
-static void call_once(struct once_control *once, void (*callback)(void))
+typedef LONG pthread_once_t;
+#define PTHREAD_ONCE_INIT 0
+
+static void pthread_once(pthread_once_t *once, void (*callback)(void))
{
- while(InterlockedExchange(&once->canpass, FALSE) == FALSE)
+ LONG ret;
+ while((ret=InterlockedExchange(once, 1)) == 1)
Sleep(0);
- if(InterlockedExchange(&once->hasrun, TRUE) == FALSE)
+ if(ret == 0)
callback();
- InterlockedExchange(&once->canpass, TRUE);
+ InterlockedExchange(once, 2);
}
-#define DO_INITCONFIG() call_once(&once_control, alc_initconfig)
-#else
+#endif
+
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
#define DO_INITCONFIG() pthread_once(&once_control, alc_initconfig)
-#endif
+
static void ProbeList(ALCchar **list, size_t *listsize, enum DevProbe type)
{