diff --git a/configure.ac b/configure.ac index ac64a38d43..2ae522eba9 100644 --- a/configure.ac +++ b/configure.ac @@ -795,6 +795,24 @@ AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"]) AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"]) AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"]) +dnl glibc 2.26 doesn't provide anymore xlocale.h header, so we check +dnl if at least locale_t is supported +AC_MSG_CHECKING(if locale_t is supported) +AC_LINK_IFELSE([AC_LANG_SOURCE([[ +#define _GNU_SOURCE +#include +#ifdef HAVE_XLOCALE_H +#include +#endif +int main() { + locale_t loc; + return 1; +}]])], STRUCT_LOCALE_T_SUPPORTED=yes, STRUCT_LOCALE_T_SUPPORTED=no) +if test "x$STRUCT_LOCALE_T_SUPPORTED" != xyes; then + DEFINES="$DEFINES -DHAVE_LOCALE_T" +fi +AC_MSG_RESULT($STRUCT_LOCALE_T_SUPPORTED) + dnl Check to see if dlopen is in default libraries (like Solaris, which dnl has it in libc), or if libdl is needed to get it. AC_CHECK_FUNC([dlopen], [DEFINES="$DEFINES -DHAVE_DLOPEN"], diff --git a/src/util/strtod.c b/src/util/strtod.c index ea7d395e2d..3c779c1e14 100644 --- a/src/util/strtod.c +++ b/src/util/strtod.c @@ -30,6 +30,8 @@ #include #ifdef HAVE_XLOCALE_H #include +#endif +#ifdef HAVE_LOCALE_T static locale_t loc; #endif #endif @@ -40,7 +42,7 @@ static locale_t loc; void _mesa_locale_init(void) { -#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H) +#if defined(_GNU_SOURCE) && defined(HAVE_LOCALE_T) loc = newlocale(LC_CTYPE_MASK, "C", NULL); #endif } @@ -48,7 +50,7 @@ _mesa_locale_init(void) void _mesa_locale_fini(void) { -#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H) +#if defined(_GNU_SOURCE) && defined(HAVE_LOCALE_T) freelocale(loc); #endif } @@ -60,7 +62,7 @@ _mesa_locale_fini(void) double _mesa_strtod(const char *s, char **end) { -#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H) +#if defined(_GNU_SOURCE) && defined(HAVE_LOCALE_T) return strtod_l(s, end, loc); #else return strtod(s, end); @@ -75,7 +77,7 @@ _mesa_strtod(const char *s, char **end) float _mesa_strtof(const char *s, char **end) { -#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H) +#if defined(_GNU_SOURCE) && defined(HAVE_LOCALE_T) return strtof_l(s, end, loc); #elif defined(HAVE_STRTOF) return strtof(s, end);