diff --git a/.pick_status.json b/.pick_status.json index bcb21919c49..8d0214abf2c 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -958,7 +958,7 @@ "description": "mesa/main: rework locale setup/teardown", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, 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