aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2020-07-10 13:08:30 +0200
committerMarge Bot <[email protected]>2020-07-14 10:56:03 +0000
commit34fe561895bed253070b7dadaa86b4473ad7b51a (patch)
treeb606f56b2f50dc76e1280daa4670d5e3cf580d0e /src/mesa
parent0a4aa612ba27d6b9e550f7c4a009f30fcfa0c93e (diff)
mesa/main: use call_once instead of open-coding
We already have a utility for this, so let's use that instead. Reviewed-by: Kristian H. Kristensen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5879>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/context.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index b8b11b0c450..be2e7df5824 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -394,11 +394,11 @@ one_time_init(void)
}
/**
- * One-time initialization mutex lock.
+ * One-time initialization flag
*
* \sa Used by _mesa_initialize().
*/
-mtx_t OneTimeLock = _MTX_INITIALIZER_NP;
+static once_flag init_once = ONCE_FLAG_INIT;
/**
@@ -413,17 +413,7 @@ mtx_t OneTimeLock = _MTX_INITIALIZER_NP;
void
_mesa_initialize(void)
{
- static bool initialized;
-
- mtx_lock(&OneTimeLock);
-
- /* truly one-time init */
- if (!initialized)
- one_time_init();
-
- initialized = true;
-
- mtx_unlock(&OneTimeLock);
+ call_once(&init_once, one_time_init);
}