Building for Android
Marc Glisse
marc.glisse at inria.fr
Tue Jun 25 22:32:17 CEST 2013
On Mon, 17 Jun 2013, Marc Glisse wrote:
> Probably just a configure test to detect platforms without decimal_point in
> lconv.
Would the attached work / make sense?
--
Marc Glisse
-------------- next part --------------
diff -r 53d1f20e8169 configure.ac
--- a/configure.ac Wed Jun 19 17:25:56 2013 +0200
+++ b/configure.ac Tue Jun 25 22:20:56 2013 +0200
@@ -2753,6 +2753,15 @@
and contains `psp_iticksperclktick'.])],,
[#include <sys/pstat.h>])
+# Reasons for checking:
+# lconv decimal_point - not in android
+#
+AC_CHECK_MEMBER(struct lconv.decimal_point,
+ [AC_DEFINE(HAVE_LCONV_DECIMAL_POINT, 1,
+[Define to 1 if <locale.h> `struct lconv' exists
+and contains `decimal_point'.])],,
+ [#include <locale.h>])
+
# C++ tests, when required
#
if test $enable_cxx = yes; then
diff -r 53d1f20e8169 cxx/ismpf.cc
--- a/cxx/ismpf.cc Wed Jun 19 17:25:56 2013 +0200
+++ b/cxx/ismpf.cc Tue Jun 25 22:20:56 2013 +0200
@@ -45,7 +45,7 @@
bool ok = false;
// C decimal point, as expected by mpf_set_str
- const char *lconv_point = localeconv()->decimal_point;
+ const char *lconv_point = GMP_DECIMAL_POINT;
// C++ decimal point
#if HAVE_STD__LOCALE
diff -r 53d1f20e8169 cxx/osmpf.cc
--- a/cxx/osmpf.cc Wed Jun 19 17:25:56 2013 +0200
+++ b/cxx/osmpf.cc Tue Jun 25 22:20:56 2013 +0200
@@ -47,7 +47,7 @@
point[0] = use_facet< numpunct<char> >(o.getloc()).decimal_point();
point[1] = '\0';
#else
- const char *point = localeconv()->decimal_point;
+ const char *point = GMP_DECIMAL_POINT;
#endif
GMP_ASPRINTF_T_INIT (d, &result);
diff -r 53d1f20e8169 gmp-impl.h
--- a/gmp-impl.h Wed Jun 19 17:25:56 2013 +0200
+++ b/gmp-impl.h Tue Jun 25 22:20:56 2013 +0200
@@ -4363,7 +4363,8 @@
#define GMP_DECIMAL_POINT (nl_langinfo (RADIXCHAR))
#endif
/* localeconv is slower since it returns all locale stuff */
-#if HAVE_LOCALECONV && ! defined (GMP_DECIMAL_POINT)
+/* A placeholder localeconv is useless. */
+#if HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT && ! defined (GMP_DECIMAL_POINT)
#define GMP_DECIMAL_POINT (localeconv()->decimal_point)
#endif
#if ! defined (GMP_DECIMAL_POINT)
diff -r 53d1f20e8169 tests/cxx/clocale.c
--- a/tests/cxx/clocale.c Wed Jun 19 17:25:56 2013 +0200
+++ b/tests/cxx/clocale.c Tue Jun 25 22:20:56 2013 +0200
@@ -41,7 +41,7 @@
extern char point_string[];
-#if HAVE_LOCALECONV
+#if HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT
struct lconv *
localeconv (void)
{
diff -r 53d1f20e8169 tests/cxx/t-locale.cc
--- a/tests/cxx/t-locale.cc Wed Jun 19 17:25:56 2013 +0200
+++ b/tests/cxx/t-locale.cc Tue Jun 25 22:20:56 2013 +0200
@@ -105,7 +105,7 @@
cout << " point " << point[i] << "\n";
cout << " str \"" << str << "\"\n";
cout << " localeconv point \""
- << localeconv()->decimal_point << "\"\n";
+ << GMP_DECIMAL_POINT << "\"\n";
abort ();
}
@@ -120,7 +120,7 @@
cout << " got " << got << "\n";
cout << " want " << want << "\n";
cout << " localeconv point \""
- << localeconv()->decimal_point << "\"\n";
+ << GMP_DECIMAL_POINT << "\"\n";
abort ();
}
}
diff -r 53d1f20e8169 tests/misc/t-locale.c
--- a/tests/misc/t-locale.c Wed Jun 19 17:25:56 2013 +0200
+++ b/tests/misc/t-locale.c Tue Jun 25 22:20:56 2013 +0200
@@ -52,7 +52,7 @@
const char *decimal_point;
/* Replace the libc localeconv with one we can manipulate. */
-#if HAVE_LOCALECONV
+#if HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT
struct lconv *
localeconv (void)
{
More information about the gmp-discuss
mailing list