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 <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5879>
This commit is contained in:
Erik Faye-Lund 2020-07-10 13:08:30 +02:00 committed by Marge Bot
parent 0a4aa612ba
commit 34fe561895

View file

@ -394,11 +394,11 @@ one_time_init(void)
} }
/** /**
* One-time initialization mutex lock. * One-time initialization flag
* *
* \sa Used by _mesa_initialize(). * \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 void
_mesa_initialize(void) _mesa_initialize(void)
{ {
static bool initialized; call_once(&init_once, one_time_init);
mtx_lock(&OneTimeLock);
/* truly one-time init */
if (!initialized)
one_time_init();
initialized = true;
mtx_unlock(&OneTimeLock);
} }