On 07/09/2014 12:47 AM, Chia-I Wu wrote:
> The compiler may be used by multiple contexts simultaneously and needs to be
> thread-safe.
>
> Signed-off-by: Chia-I Wu <[email protected]>
> ---
> src/glsl/strtod.cpp | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/src/glsl/strtod.cpp b/src/glsl/strtod.cpp
> index 5d4346b..1ac29ec 100644
> --- a/src/glsl/strtod.cpp
> +++ b/src/glsl/strtod.cpp
> @@ -35,6 +35,17 @@
>
> #include "strtod.h"
>
> +#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) &&
> \
> + !defined(__HAIKU__) && !defined(__UCLIBC__)
> +#define GLSL_HAVE_LOCALE_T
> +#endif
Could we just do this in configure.ac (or whatever the scons analog is)
instead?
> +
> +#ifdef GLSL_HAVE_LOCALE_T
> +static struct locale_initializer {
> + locale_initializer() { loc = newlocale(LC_CTYPE_MASK, "C", NULL); }
> + locale_t loc;
> +} loc_init;
> +#endif
>
>
> /**
> @@ -44,13 +55,8 @@
> double
> glsl_strtod(const char *s, char **end)
> {
> -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) &&
> \
> - !defined(__HAIKU__) && !defined(__UCLIBC__)
> - static locale_t loc = NULL;
> - if (!loc) {
> - loc = newlocale(LC_CTYPE_MASK, "C", NULL);
> - }
> - return strtod_l(s, end, loc);
> +#ifdef GLSL_HAVE_LOCALE_T
> + return strtod_l(s, end, loc_init.loc);
> #else
> return strtod(s, end);
> #endif
> @@ -64,13 +70,8 @@ glsl_strtod(const char *s, char **end)
> float
> glsl_strtof(const char *s, char **end)
> {
> -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) &&
> \
> - !defined(__HAIKU__) && !defined(__UCLIBC__)
> - static locale_t loc = NULL;
> - if (!loc) {
> - loc = newlocale(LC_CTYPE_MASK, "C", NULL);
> - }
> - return strtof_l(s, end, loc);
> +#ifdef GLSL_HAVE_LOCALE_T
> + return strtof_l(s, end, loc_init.loc);
> #elif _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE
> return strtof(s, end);
> #else
>
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev