Mesa (master): configure: check for xlocale.h and strtof
Kenneth Graunke
kwg at kemper.freedesktop.org
Thu Oct 30 09:30:11 UTC 2014
Module: Mesa
Branch: master
Commit: b039dbfffd8eedef53a5ff9ae6b0ae09e6844d9c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b039dbfffd8eedef53a5ff9ae6b0ae09e6844d9c
Author: Chia-I Wu <olvaffe at gmail.com>
Date: Wed Aug 20 14:40:23 2014 +0800
configure: check for xlocale.h and strtof
With the assumptions that xlocale.h implies newlocale and strtof_l. SCons is
updated to define HAVE_XLOCALE_H on linux and darwin.
Signed-off-by: Chia-I Wu <olv at lunarg.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
---
configure.ac | 3 +++
scons/gallium.py | 4 ++++
src/util/strtod.cpp | 12 ++++--------
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7dbba76..fc7d372 100644
--- a/configure.ac
+++ b/configure.ac
@@ -527,6 +527,9 @@ if test "x$enable_asm" = xyes; then
esac
fi
+AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
+AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
+
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/scons/gallium.py b/scons/gallium.py
index dd5ca56..e3786d2 100755
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -301,6 +301,10 @@ def generate(env):
cppdefines += ['HAVE_ALIAS']
else:
cppdefines += ['GLX_ALIAS_UNSUPPORTED']
+
+ if env['platform'] in ('linux', 'darwin'):
+ cppdefines += ['HAVE_XLOCALE_H']
+
if env['platform'] == 'haiku':
cppdefines += [
'HAVE_PTHREAD',
diff --git a/src/util/strtod.cpp b/src/util/strtod.cpp
index 2f1d229..2a3e8eb 100644
--- a/src/util/strtod.cpp
+++ b/src/util/strtod.cpp
@@ -28,7 +28,7 @@
#ifdef _GNU_SOURCE
#include <locale.h>
-#ifdef __APPLE__
+#ifdef HAVE_XLOCALE_H
#include <xlocale.h>
#endif
#endif
@@ -44,9 +44,7 @@
double
_mesa_strtod(const char *s, char **end)
{
-#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
- !defined(ANDROID) && !defined(__HAIKU__) && !defined(__UCLIBC__) && \
- !defined(__NetBSD__)
+#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
static locale_t loc = NULL;
if (!loc) {
loc = newlocale(LC_CTYPE_MASK, "C", NULL);
@@ -65,15 +63,13 @@ _mesa_strtod(const char *s, char **end)
float
_mesa_strtof(const char *s, char **end)
{
-#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \
- !defined(ANDROID) && !defined(__HAIKU__) && !defined(__UCLIBC__) && \
- !defined(__NetBSD__)
+#if defined(_GNU_SOURCE) && defined(HAVE_XLOCALE_H)
static locale_t loc = NULL;
if (!loc) {
loc = newlocale(LC_CTYPE_MASK, "C", NULL);
}
return strtof_l(s, end, loc);
-#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)
+#elif defined(HAVE_STRTOF)
return strtof(s, end);
#else
return (float) strtod(s, end);
More information about the mesa-commit
mailing list