mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 06:50:11 +01:00
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:
parent
0a4aa612ba
commit
34fe561895
1 changed files with 3 additions and 13 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue