Module: Mesa Branch: main Commit: 7373f25c0934882250847fb292f977d2d5569642 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7373f25c0934882250847fb292f977d2d5569642
Author: Thong Thai <[email protected]> Date: Wed Apr 26 14:57:43 2023 -0400 mesa/main: rework locale setup/teardown Cc: mesa-stable Signed-off-by: Thong Thai <[email protected]> Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22699> --- src/mesa/main/context.c | 1 - src/util/strtod.c | 14 +++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index f16d8caa63b..d8eea2ea867 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -184,7 +184,6 @@ static void one_time_fini(void) { glsl_type_singleton_decref(); - _mesa_locale_fini(); } /** diff --git a/src/util/strtod.c b/src/util/strtod.c index de695d64b47..b42dc2e55b9 100644 --- a/src/util/strtod.c +++ b/src/util/strtod.c @@ -35,14 +35,22 @@ static locale_t loc; #endif #include "strtod.h" +#include "util/u_call_once.h" +static void +_mesa_locale_init_once(void) +{ + #if defined(_GNU_SOURCE) && defined(HAVE_STRTOD_L) + loc = newlocale(LC_CTYPE_MASK, "C", NULL); + atexit(_mesa_locale_fini); + #endif +} void _mesa_locale_init(void) { -#if defined(_GNU_SOURCE) && defined(HAVE_STRTOD_L) - loc = newlocale(LC_CTYPE_MASK, "C", NULL); -#endif + static util_once_flag once = UTIL_ONCE_FLAG_INIT; + util_call_once(&once, _mesa_locale_init_once); } void
