diff --git a/src/cairo-misc.c b/src/cairo-misc.c index 59cf76fc9..582206ffd 100644 --- a/src/cairo-misc.c +++ b/src/cairo-misc.c @@ -798,26 +798,18 @@ _cairo_get_locale_decimal_point (void) #if defined (HAVE_NEWLOCALE) && defined (HAVE_STRTOD_L) +static cairo_atomic_once_t C_locale_once; static locale_t C_locale; static locale_t get_C_locale (void) { - locale_t C; - -retry: - C = (locale_t) _cairo_atomic_ptr_get ((cairo_atomic_intptr_t *) &C_locale); - - if (unlikely (!C)) { - C = newlocale (LC_ALL_MASK, "C", NULL); - - if (!_cairo_atomic_ptr_cmpxchg ((cairo_atomic_intptr_t *) &C_locale, NULL, C)) { - freelocale (C_locale); - goto retry; - } + if (_cairo_atomic_init_once_enter (&C_locale_once)) { + C_locale = newlocale (LC_ALL_MASK, "C", NULL); + _cairo_atomic_init_once_leave (&C_locale_once); } - return C; + return C_locale; } double