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:

committed by
Marge Bot

parent
0a4aa612ba
commit
34fe561895
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user