We already have a utility for this, so let's use that instead.
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5879>
}
/**
- * 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;
/**
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);
}