From 9e359ac98f503ec7da0725defc21d43d7974a3a5 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 30 Nov 2015 17:34:32 +1100 Subject: [PATCH] base: Windows heim_base_once_t cleanup heim_base_once_t can just be a LONG on Windows, the structure is not needed --- lib/base/heimbase.c | 6 +++--- lib/base/heimbase.h | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/base/heimbase.c b/lib/base/heimbase.c index 5642b1cd3..3f164fa8f 100644 --- a/lib/base/heimbase.c +++ b/lib/base/heimbase.c @@ -374,10 +374,10 @@ heim_base_once_f(heim_base_once_t *once, void *ctx, void (*func)(void *)) * State 1 means that func() is executing. * State 2 means that func() has completed execution. */ - if (InterlockedCompareExchange(&once->state, 1L, 0L) == 0L) { + if (InterlockedCompareExchange(once, 1L, 0L) == 0L) { /* State is now 1 */ (*func)(ctx); - (void)InterlockedExchange(&once->state, 2L); + (void)InterlockedExchange(once, 2L); /* State is now 2 */ } else { /* @@ -385,7 +385,7 @@ heim_base_once_f(heim_base_once_t *once, void *ctx, void (*func)(void *)) * the current state under a full memory barrier. As long * as the current state is 1 continue to spin. */ - while (InterlockedCompareExchange(&once->state, 2L, 0L) == 1L) + while (InterlockedCompareExchange(once, 2L, 0L) == 1L) SwitchToThread(); } #elif defined(HAVE_DISPATCH_DISPATCH_H) diff --git a/lib/base/heimbase.h b/lib/base/heimbase.h index 7a4ec385d..7f2c1c4ef 100644 --- a/lib/base/heimbase.h +++ b/lib/base/heimbase.h @@ -56,13 +56,10 @@ typedef void * heim_object_t; typedef unsigned int heim_tid_t; typedef heim_object_t heim_bool_t; typedef heim_object_t heim_null_t; -#if defined(WIN32) -typedef struct { - LONG state; -} heim_base_once_t; -# define HEIM_BASE_ONCE_INIT {0L} -#else # define HEIM_BASE_ONCE_INIT 0 +#ifdef WIN32 +typedef LONG heim_base_once_t; +#else typedef long heim_base_once_t; /* XXX arch dependant */ #endif