summaryrefslogtreecommitdiff
path: root/Build/source/libs/mpfr/mpfr-src/acinclude.m4
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/acinclude.m4')
-rw-r--r--Build/source/libs/mpfr/mpfr-src/acinclude.m4547
1 files changed, 508 insertions, 39 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/acinclude.m4 b/Build/source/libs/mpfr/mpfr-src/acinclude.m4
index 69e2e74a648..db142a7eb31 100644
--- a/Build/source/libs/mpfr/mpfr-src/acinclude.m4
+++ b/Build/source/libs/mpfr/mpfr-src/acinclude.m4
@@ -40,6 +40,7 @@ AC_DEFUN([MPFR_CONFIGS],
[
AC_REQUIRE([AC_OBJEXT])
AC_REQUIRE([MPFR_CHECK_LIBM])
+AC_REQUIRE([MPFR_CHECK_LIBQUADMATH])
AC_REQUIRE([AC_HEADER_TIME])
AC_REQUIRE([AC_CANONICAL_HOST])
@@ -68,9 +69,6 @@ AC_CHECK_MEMBERS([struct lconv.decimal_point, struct lconv.thousands_sep],,,
dnl Check how to get `alloca'
AC_FUNC_ALLOCA
-dnl SIZE_MAX macro
-gl_SIZE_MAX
-
dnl va_copy macro
AC_MSG_CHECKING([how to copy va_list])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@@ -93,28 +91,35 @@ dnl FIXME: The functions memmove, memset and strtol are really needed by
dnl MPFR, but if they are implemented as macros, this is also OK (in our
dnl case). So, we do not return an error, but their tests are currently
dnl useless.
+dnl Moreover, for memmove and memset, when gcc -Werror is used, these
+dnl functions are considered to be missing because of a "conflicting
+dnl types for built-in function" error. Possible workarounds if the
+dnl results of this test are used (thus one doesn't want an error):
+dnl * If "$GCC" is set, disable built-ins by adding -fno-builtin
+dnl to $CFLAGS for this test (this would yield a failure if such
+dnl functions are defined only as built-ins, but does this occur
+dnl in practice?).
+dnl * Enable -Werror only for the main compilation (and possibly
+dnl some particular tests) via a new configure option.
dnl gettimeofday is not defined for MinGW
-AC_CHECK_FUNCS([memmove memset setlocale strtol gettimeofday])
+AC_CHECK_FUNCS([memmove memset setlocale strtol gettimeofday signal])
-dnl Check for IEEE-754 switches on Alpha
-case $host in
-alpha*-*-*)
- saved_CFLAGS="$CFLAGS"
- AC_CACHE_CHECK([for IEEE-754 switches], mpfr_cv_ieee_switches, [
- if test -n "$GCC"; then
- mpfr_cv_ieee_switches="-mfp-rounding-mode=d -mieee-with-inexact"
- else
- mpfr_cv_ieee_switches="-fprm d -ieee_with_inexact"
- fi
- CFLAGS="$CFLAGS $mpfr_cv_ieee_switches"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], , mpfr_cv_ieee_switches="none")
- ])
- if test "$mpfr_cv_ieee_switches" = "none"; then
- CFLAGS="$saved_CFLAGS"
- else
- CFLAGS="$saved_CFLAGS $mpfr_cv_ieee_switches"
- fi
-esac
+dnl We cannot use AC_CHECK_FUNCS on sigaction, because while this
+dnl function may be provided by the C library, its prototype and
+dnl associated structure may not be available, e.g. when compiling
+dnl with "gcc -std=c99".
+AC_MSG_CHECKING(for sigaction and its associated structure)
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <signal.h>
+static int f (int (*func)(int, const struct sigaction *, struct sigaction *))
+{ return 0; }
+]], [[
+ return f(sigaction);
+]])], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SIGACTION, 1,
+ [Define if you have a working sigaction function.])
+],[AC_MSG_RESULT(no)])
dnl check for long long
AC_CHECK_TYPE([long long int],
@@ -136,6 +141,34 @@ if test "$ac_cv_type_intmax_t" = yes; then
if test "$mpfr_cv_have_intmax_max" = "yes"; then
AC_DEFINE(MPFR_HAVE_INTMAX_MAX,1,[Define if you have a working INTMAX_MAX.])
fi
+ AC_CACHE_CHECK([for working printf length modifier for intmax_t],
+ mpfr_cv_printf_maxlm, [
+ saved_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS -I$srcdir/src"
+ for modifier in j ll l
+ do
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <stdio.h>
+#include <string.h>
+#include "mpfr-intmax.h"
+]],[[
+ char s[64];
+ sprintf (s, "%${modifier}d %${modifier}u",
+ (intmax_t) -17, (uintmax_t) 42);
+ return strcmp (s, "-17 42") != 0;
+]])],
+ mpfr_cv_printf_maxlm=${modifier}; break,
+ mpfr_cv_printf_maxlm=none,
+dnl We assume that j is working when cross-compiling.
+ mpfr_cv_printf_maxlm=j; break
+ )
+ done
+ CPPFLAGS="$saved_CPPFLAGS"
+ ])
+ if test "$mpfr_cv_printf_maxlm" != "none"; then
+ AC_DEFINE_UNQUOTED([MPFR_PRINTF_MAXLM],["$mpfr_cv_printf_maxlm"],
+ [Define to a working printf length modifier for intmax_t])
+ fi
fi
AC_CHECK_TYPE( [union fpc_csr],
@@ -146,6 +179,51 @@ AC_CHECK_TYPE( [union fpc_csr],
#endif
])
+dnl Check for _Noreturn function specifier (ISO C11)
+AC_CACHE_CHECK([for _Noreturn], mpfr_cv_have_noreturn, [
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[_Noreturn void foo(int);]])],
+ mpfr_cv_have_noreturn=yes, mpfr_cv_have_noreturn=no)
+])
+if test "$mpfr_cv_have_noreturn" = "yes"; then
+ AC_DEFINE(MPFR_HAVE_NORETURN,1,[Define if the _Noreturn function specifier is supported.])
+fi
+
+dnl Check for __builtin_unreachable
+AC_CACHE_CHECK([for __builtin_unreachable], mpfr_cv_have_builtin_unreachable,
+[
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(
+ [[int x;]],
+ [[if (x) __builtin_unreachable(); ]]
+ )],
+ mpfr_cv_have_builtin_unreachable=yes,
+ mpfr_cv_have_builtin_unreachable=no)
+])
+if test "$mpfr_cv_have_builtin_unreachable" = "yes"; then
+ AC_DEFINE(MPFR_HAVE_BUILTIN_UNREACHABLE, 1,
+ [Define if the __builtin_unreachable GCC built-in is supported.])
+fi
+
+dnl Check for attribute constructor and destructor
+MPFR_CHECK_CONSTRUCTOR_ATTR()
+
+dnl Check for POSIX Thread. Since the AX_PTHREAD macro is not standard
+dnl (it is provided by autoconf-archive), we need to detect whether it
+dnl is left unexpanded, otherwise the configure script won't fail and
+dnl "make distcheck" won't give any error, yielding buggy tarballs!
+dnl The \b is necessary to avoid an error with recent ax_pthread.m4
+dnl (such as with Debian's autoconf-archive 20160320-1), which contains
+dnl AX_PTHREAD_ZOS_MISSING, etc. It is not documented, but see:
+dnl https://lists.gnu.org/archive/html/autoconf/2015-03/msg00011.html
+dnl
+dnl Note: each time a change is done in m4_pattern_forbid, autogen.sh
+dnl should be tested with and without ax_pthread.m4 availability (in
+dnl the latter case, there should be an error).
+m4_pattern_forbid([AX_PTHREAD\b])
+AX_PTHREAD([])
+
+dnl Check for ISO C11 Thread
+MPFR_CHECK_C11_THREAD()
+
dnl Check for fesetround
AC_CACHE_CHECK([for fesetround], mpfr_cv_have_fesetround, [
saved_LIBS="$LIBS"
@@ -204,13 +282,16 @@ static double get_max (void) { static volatile double d = DBL_MAX; return d; }
fi
dnl Check if subnormal (denormalized) numbers are supported
-AC_CACHE_CHECK([for subnormal numbers], mpfr_cv_have_denorms, [
+dnl for the binary64 format, the smallest normal number is 2^(-1022)
+dnl for the binary32 format, the smallest normal number is 2^(-126)
+AC_CACHE_CHECK([for subnormal double-precision numbers],
+mpfr_cv_have_denorms, [
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
int main (void) {
double x = 2.22507385850720138309e-308;
fprintf (stderr, "%e\n", x / 2.0);
- return 2.0 * (x / 2.0) != x;
+ return 2.0 * (double) (x / 2.0) != x;
}
]])],
[mpfr_cv_have_denorms="yes"],
@@ -218,7 +299,25 @@ int main (void) {
[mpfr_cv_have_denorms="cannot test, assume no"])
])
if test "$mpfr_cv_have_denorms" = "yes"; then
- AC_DEFINE(HAVE_DENORMS,1,[Define if subnormal (denormalized) floats work.])
+ AC_DEFINE(HAVE_DENORMS,1,[Define if subnormal (denormalized) doubles work.])
+fi
+AC_CACHE_CHECK([for subnormal single-precision numbers],
+mpfr_cv_have_denorms_flt, [
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdio.h>
+int main (void) {
+ float x = 1.17549435082229e-38;
+ fprintf (stderr, "%e\n", x / 2.0);
+ return 2.0 * (float) (x / 2.0) != x;
+}
+]])],
+ [mpfr_cv_have_denorms_flt="yes"],
+ [mpfr_cv_have_denorms_flt="no"],
+ [mpfr_cv_have_denorms_flt="cannot test, assume no"])
+])
+if test "$mpfr_cv_have_denorms_flt" = "yes"; then
+ AC_DEFINE(HAVE_DENORMS_FLT,1,
+ [Define if subnormal (denormalized) floats work.])
fi
dnl Check if signed zeros are supported. Note: the test will fail
@@ -241,7 +340,7 @@ dnl Check the FP division by 0 fails (e.g. on a non-IEEE-754 platform).
dnl In such a case, MPFR_ERRDIVZERO is defined to disable the tests
dnl involving a FP division by 0.
dnl For the developers: to check whether all these tests are disabled,
-dnl configure MPFR with "-DMPFR_TEST_DIVBYZERO=1 -DMPFR_ERRDIVZERO=1".
+dnl configure MPFR with "-DMPFR_TESTS_FPE_DIV -DMPFR_ERRDIVZERO".
AC_CACHE_CHECK([if the FP division by 0 fails], mpfr_cv_errdivzero, [
AC_RUN_IFELSE([AC_LANG_SOURCE([[
int main (void) {
@@ -379,6 +478,27 @@ static int f (double (*func)(double)) { return 0; }
AC_DEFINE(HAVE_NEARBYINT, 1,[Have ISO C99 nearbyint function])
],[AC_MSG_RESULT(no)])
+dnl Check if _mulx_u64 is provided
+dnl Note: This intrinsic is not standard. We need a run because
+dnl it may be provided but not working as expected (with ICC 15,
+dnl one gets an "Illegal instruction").
+AC_MSG_CHECKING([for _mulx_u64])
+AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <immintrin.h>
+]], [[
+ unsigned long long h1, h2;
+ _mulx_u64(17, 42, &h1);
+ _mulx_u64(-1, -1, &h2);
+ return h1 == 0 && h2 == -2 ? 0 : 1;
+]])],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_MULX_U64, 1,[Have a working _mulx_u64 function])
+ ],
+ [AC_MSG_RESULT(no)
+ ],
+ [AC_MSG_RESULT([cannot test, assume no])
+ ])
+
LIBS="$saved_LIBS"
dnl Now try to check the long double format
@@ -386,7 +506,7 @@ MPFR_C_LONG_DOUBLE_FORMAT
if test "$enable_logging" = yes; then
if test "$enable_thread_safe" = yes; then
- AC_MSG_ERROR([Enable either `Logging' or `thread-safe', not both])
+ AC_MSG_ERROR([enable either `Logging' or `thread-safe', not both])
else
enable_thread_safe=no
fi
@@ -417,6 +537,7 @@ int main (void) {
AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe])
AC_DEFINE([MPFR_USE_C11_THREAD_SAFE],1,[Build MPFR as thread safe using C11])
tls_c11_support=yes
+ enable_thread_safe=yes
],
[AC_MSG_RESULT(no)
],
@@ -440,6 +561,7 @@ then
]])],
[AC_MSG_RESULT(yes)
AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe])
+ enable_thread_safe=yes
],
[AC_MSG_RESULT(no)
if test "$enable_thread_safe" = yes; then
@@ -456,6 +578,113 @@ then
CPPFLAGS="$saved_CPPFLAGS"
fi
fi
+
+dnl Check if decimal floats are available.
+dnl For the different cases, we try to use values that will not be returned
+dnl by build tools. For instance, 1 must not be used as it can be returned
+dnl by ld in case of link failure.
+if test "$enable_decimal_float" != no; then
+ AC_MSG_CHECKING(if compiler knows _Decimal64)
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[_Decimal64 x;]])],
+ [AC_MSG_RESULT(yes)
+ AC_MSG_CHECKING(decimal float format)
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <stdlib.h>
+]], [[
+volatile _Decimal64 x = 1;
+union { double d; _Decimal64 d64; } y;
+if (x != x) return 83;
+y.d64 = 1234567890123456.0dd;
+return y.d == 0.14894469406741037E-123 ? 80 :
+ y.d == 0.59075095508629822E-68 ? 81 : 82;
+]])], [AC_MSG_RESULT(internal error)
+ AC_MSG_FAILURE(unexpected exit status 0)],
+ [d64_exit_status=$?
+ case "$d64_exit_status" in
+ 80) AC_MSG_RESULT(DPD)
+ AC_DEFINE([DPD_FORMAT],1,[DPD format])
+ AC_DEFINE([MPFR_WANT_DECIMAL_FLOATS],1,
+ [Build decimal float functions]) ;;
+ 81) AC_MSG_RESULT(BID)
+ AC_DEFINE([MPFR_WANT_DECIMAL_FLOATS],1,
+ [Build decimal float functions]) ;;
+ 82) AC_MSG_RESULT(neither DPD nor BID)
+ if test "$enable_decimal_float" = yes; then
+ AC_MSG_ERROR([unsupported decimal float format.
+Please build MPFR without --enable-decimal-float.])
+ fi ;;
+ *) AC_MSG_RESULT(unknown (exit status $d64_exit_status))
+ if test "$enable_decimal_float" = yes; then
+ AC_MSG_ERROR([internal or link error.
+Please build MPFR without --enable-decimal-float.])
+ fi ;;
+ esac],
+ [AC_MSG_RESULT(assuming DPD)
+ AC_DEFINE([DPD_FORMAT],1,[])
+ AC_DEFINE([MPFR_WANT_DECIMAL_FLOATS],1,
+ [Build decimal float functions])])
+ ],
+ [AC_MSG_RESULT(no)
+ if test "$enable_decimal_float" = yes; then
+ AC_MSG_ERROR([compiler doesn't know _Decimal64 (ISO/IEC TR 24732).
+Please use another compiler or build MPFR without --enable-decimal-float.])
+ fi])
+fi
+
+dnl Check if __float128 is available. We also require the compiler
+dnl to support C99 constants (this prevents the __float128 support
+dnl with GCC's -std=c90, but who cares?).
+if test "$enable_float128" != no; then
+ AC_MSG_CHECKING(if compiler knows __float128 with C99 constants)
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[__float128 x = 0x1.fp+16383q;]])],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE([MPFR_WANT_FLOAT128],1,[Build float128 functions])],
+ [AC_MSG_RESULT(no)
+ if test "$enable_float128" = yes; then
+ AC_MSG_ERROR([compiler doesn't know __float128 with C99 constants
+Please use another compiler or build MPFR without --enable-float128.])
+ fi])
+fi
+
+dnl Check if Static Assertions are supported.
+AC_MSG_CHECKING(for Static Assertion support)
+saved_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS -I$srcdir/src"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#define MPFR_USE_STATIC_ASSERT 1
+#include "mpfr-sassert.h"
+
+/* Test if Static Assertions work */
+MPFR_DECL_STATIC_ASSERT(sizeof(char) <= sizeof(int));
+
+int main (void) {
+ MPFR_DECL_STATIC_ASSERT(sizeof(int) <= sizeof(long));
+ int x;
+ (void) (x = 1); /* cast to void: avoid a warning, at least with GCC */
+ /* Test of the macro after a declaraction and a statement. */
+ MPFR_STAT_STATIC_ASSERT(sizeof(short) <= sizeof(int));
+ return 0;
+}
+ ]])],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE([MPFR_USE_STATIC_ASSERT],1,[Build MPFR with Static Assertions])
+ ],
+ [AC_MSG_RESULT(no)
+ ],
+ [AC_MSG_RESULT([cannot test, assume no])
+ ])
+CPPFLAGS="$saved_CPPFLAGS"
+
+if test "$enable_lto" = "yes" ; then
+ MPFR_LTO
+fi
+
+dnl Check if the shared cache was requested and its requirements are ok.
+if test "$mpfr_want_shared_cache" = yes ;then
+ MPFR_CHECK_SHARED_CACHE()
+fi
+
])
dnl end of MPFR_CONFIGS
@@ -569,6 +798,32 @@ You need to use another compiler (or lower the optimization level).])
esac
])
+dnl MPFR_CHECK_MP_LIMB_T_VS_LONG
+dnl ----------------------------
+dnl Check that a long can fit in a mp_limb_t.
+dnl If so, it set the define MPFR_LONG_WITHIN_LIMB
+AC_DEFUN([MPFR_CHECK_MP_LIMB_T_VS_LONG], [
+AC_REQUIRE([MPFR_CONFIGS])
+AC_CACHE_CHECK([for long to fit in mp_limb_t], mpfr_cv_long_within_limb, [
+saved_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS -I$srcdir/src"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <gmp.h>
+#include "mpfr-sassert.h"
+]], [[
+ MPFR_STAT_STATIC_ASSERT ((mp_limb_t) -1 >= (unsigned long) -1);
+ return 0;
+]])], [mpfr_cv_long_within_limb="yes"],
+ [mpfr_cv_long_within_limb="no"],
+ [mpfr_cv_long_within_limb="cannot test, assume not present"])
+])
+case $mpfr_cv_long_within_limb in
+yes*)
+ AC_DEFINE([MPFR_LONG_WITHIN_LIMB],1,[long can be stored in mp_limb_t])
+esac
+CPPFLAGS="$saved_CPPFLAGS"
+])
+
dnl MPFR_PARSE_DIRECTORY
dnl Input: $1 = a string to a relative or absolute directory
dnl Output: $2 = the variable to set with the absolute directory
@@ -576,10 +831,11 @@ AC_DEFUN([MPFR_PARSE_DIRECTORY],
[
dnl Check if argument is a directory
if test -d $1 ; then
- dnl Get the absolute path of the directory
- dnl in case of relative directory.
- dnl If realpath is not a valid command,
- dnl an error is produced and we keep the given path.
+ dnl Get the absolute path of the directory in case of relative directory
+ dnl with the realpath command. If the output is empty, the cause may be
+ dnl that this command has not been found, and we do an alternate test,
+ dnl the same as what autoconf does for the generated configure script to
+ dnl determine whether a pathname is absolute or relative.
local_tmp=`realpath $1 2>/dev/null`
if test "$local_tmp" != "" ; then
if test -d "$local_tmp" ; then
@@ -588,7 +844,15 @@ AC_DEFUN([MPFR_PARSE_DIRECTORY],
$2=$1
fi
else
- $2=$1
+ dnl The quadrigraphs @<:@, @:>@ and @:}@ produce [, ] and )
+ dnl respectively (see Autoconf manual). We cannot use quoting here
+ dnl as the result depends on the context in which this macro is
+ dnl invoked! To detect that, one needs to look at every instance
+ dnl of the macro expansion in the generated configure script.
+ case $1 in
+ @<:@\\/@:>@* | ?:@<:@\\/@:>@* @:}@ $2=$1 ;;
+ *@:}@ $2="$PWD"/$1 ;;
+ esac
fi
dnl Check for space in the directory
if test `echo $1|cut -d' ' -f1` != $1 ; then
@@ -904,6 +1168,29 @@ BEGIN {
found = 1
exit
}
+
+ if (got[23] == "000" && \
+ got[22] == "000" && \
+ got[21] == "000" && \
+ got[20] == "124" && \
+ got[19] == "064" && \
+ got[18] == "157" && \
+ got[17] == "235" && \
+ got[16] == "301" && \
+ got[15] == "000" && \
+ got[14] == "000" && \
+ got[13] == "000" && \
+ got[12] == "000" && \
+ got[11] == "000" && \
+ got[10] == "000" && \
+ got[9] == "000" && \
+ got[8] == "000")
+ {
+ # format used on ppc64le
+ print "possibly double-double, little endian"
+ found = 1
+ exit
+ }
}
}
}
@@ -939,9 +1226,18 @@ AH_VERBATIM([HAVE_LDOUBLE],
#undef HAVE_LDOUBLE_IEEE_QUAD_BIG])
case $mpfr_cv_c_long_double_format in
+ "IEEE double, big endian")
+ AC_DEFINE(HAVE_LDOUBLE_IS_DOUBLE, 1)
+ ;;
+ "IEEE double, little endian")
+ AC_DEFINE(HAVE_LDOUBLE_IS_DOUBLE, 1)
+ ;;
"IEEE extended, little endian")
AC_DEFINE(HAVE_LDOUBLE_IEEE_EXT_LITTLE, 1)
;;
+ "IEEE extended, big endian")
+ AC_DEFINE(HAVE_LDOUBLE_IEEE_EXT_BIG, 1)
+ ;;
"IEEE quad, big endian")
AC_DEFINE(HAVE_LDOUBLE_IEEE_QUAD_BIG, 1)
;;
@@ -952,17 +1248,22 @@ case $mpfr_cv_c_long_double_format in
AC_MSG_WARN([This format is known on GCC/PowerPC platforms,])
AC_MSG_WARN([but due to GCC PR26374, we can't test further.])
AC_MSG_WARN([You can safely ignore this warning, though.])
- # Since we are not sure, we do not want to define a macro.
+ AC_DEFINE(HAVE_LDOUBLE_MAYBE_DOUBLE_DOUBLE, 1)
+ ;;
+ "possibly double-double, little endian")
+ AC_MSG_WARN([This format is known on GCC/PowerPC platforms,])
+ AC_MSG_WARN([but due to GCC PR26374, we can't test further.])
+ AC_MSG_WARN([You can safely ignore this warning, though.])
+ AC_DEFINE(HAVE_LDOUBLE_MAYBE_DOUBLE_DOUBLE, 1)
;;
unknown* | "not available")
;;
*)
- AC_MSG_WARN([oops, unrecognised float format: $mpfr_cv_c_long_double_format])
+ AC_MSG_WARN([unrecognized long double FP format: $mpfr_cv_c_long_double_format])
;;
esac
])
-
dnl MPFR_CHECK_LIBM
dnl ---------------
dnl Determine a math library -lm to use.
@@ -991,6 +1292,18 @@ case $host in
esac
])
+dnl MPFR_CHECK_LIBQUADMATH
+dnl ---------------
+dnl Determine a math library -lquadmath to use.
+AC_DEFUN([MPFR_CHECK_LIBQUADMATH],
+[AC_REQUIRE([AC_CANONICAL_HOST])
+AC_SUBST(MPFR_LIBQUADMATH,'')
+case $host in
+ *)
+ AC_CHECK_LIB(quadmath, main, MPFR_LIBQUADMATH="-lquadmath")
+ ;;
+esac
+])
dnl MPFR_LD_SEARCH_PATHS_FIRST
dnl --------------------------
@@ -1017,7 +1330,7 @@ dnl Needed for mpfr-longlong.h; this is currently necessary for s390.
dnl
dnl TODO: Replace this with a cleaner type size detection, as this
dnl solution only works with gcc and assumes CHAR_BIT == 8. Probably use
-dnl <stdint.h>, and <http://gcc.gnu.org/viewcvs/trunk/config/stdint.m4>
+dnl <stdint.h>, and <https://gcc.gnu.org/viewcvs/gcc/trunk/config/stdint.m4>
dnl as a fallback.
AC_DEFUN([GMP_C_ATTRIBUTE_MODE],
@@ -1094,7 +1407,8 @@ MPFR_FUNC_GMP_PRINTF_SPEC([lld], [long long int], [
MPFR_FUNC_GMP_PRINTF_SPEC([Lf], [long double], [
#include <gmp.h>
- ],,
+ ],
+ [AC_DEFINE([PRINTF_L], 1, [gmp_printf can read long double])],
[AC_DEFINE([NPRINTF_L], 1, [gmp_printf cannot read long double])])
MPFR_FUNC_GMP_PRINTF_SPEC([td], [ptrdiff_t], [
@@ -1104,6 +1418,161 @@ MPFR_FUNC_GMP_PRINTF_SPEC([td], [ptrdiff_t], [
#include <stddef.h>
#endif
#include <gmp.h>
- ],,
+ ],
+ [AC_DEFINE([PRINTF_T], 1, [gmp_printf can read ptrdiff_t])],
[AC_DEFINE([NPRINTF_T], 1, [gmp_printf cannot read ptrdiff_t])])
])
+
+dnl MPFR_LTO
+dnl --------
+dnl To be representative, we need:
+dnl * to compile a source,
+dnl * to generate a library archive,
+dnl * to generate a program with this archive.
+AC_DEFUN([MPFR_LTO],[
+dnl Check for -flto support
+CFLAGS="$CFLAGS -flto"
+
+AC_MSG_CHECKING([if Link Time Optimisation flag '-flto' is supported...])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+int main(void) { return 0; }
+ ]])],
+ [AC_MSG_RESULT(yes)
+ ],
+ [AC_MSG_RESULT(no)
+ AC_MSG_ERROR([Link Time Optimisation flag '-flto' is not supported.])
+ ])
+
+dnl Check if it works...
+mpfr_compile_and_link()
+{
+ echo "int f(int); int f(int n) { return n; }" > conftest-f.c
+ echo "int f(int); int main() { return f(0); }" > conftest-m.c
+ echo "$CC $CFLAGS -c -o conftest-f.o conftest-f.c" >&2
+ $CC $CFLAGS -c -o conftest-f.o conftest-f.c || return 1
+ echo "$AR cru conftest-lib.a conftest-f.o" >&2
+ $AR cru conftest-lib.a conftest-f.o || return 1
+ echo "$RANLIB conftest-lib.a" >&2
+ $RANLIB conftest-lib.a || return 1
+ echo "$CC $CFLAGS conftest-m.c conftest-lib.a" >&2
+ $CC $CFLAGS conftest-m.c conftest-lib.a || return 1
+ return 0
+}
+ AC_MSG_CHECKING([if Link Time Optimisation works with AR=$AR])
+ if mpfr_compile_and_link 2> conftest-log1.txt ; then
+ cat conftest-log1.txt >&AS_MESSAGE_LOG_FD
+ AC_MSG_RESULT(yes)
+ else
+ cat conftest-log1.txt >&AS_MESSAGE_LOG_FD
+ AC_MSG_RESULT(no)
+ AR=gcc-ar
+ RANLIB=gcc-ranlib
+ AC_MSG_CHECKING([if Link Time Optimisation works with AR=$AR])
+ if mpfr_compile_and_link 2> conftest-log2.txt; then
+ cat conftest-log2.txt >&AS_MESSAGE_LOG_FD
+ AC_MSG_RESULT(yes)
+ else
+ cat conftest-log2.txt >&AS_MESSAGE_LOG_FD
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([Link Time Optimisation is not supported (see config.log for details).])
+ fi
+ fi
+rm -f conftest*
+])
+
+dnl MPFR_CHECK_SHARED_CACHE
+dnl ----------------------
+dnl Check if the conditions for the shared cache are met:
+dnl * either pthread / C11 are available.
+dnl * either constructor or once.
+AC_DEFUN([MPFR_CHECK_SHARED_CACHE], [
+ AC_MSG_CHECKING(if shared cache is supported)
+ if test "$enable_logging" = yes ; then
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([shared cache does not work with logging support.])
+dnl because logging support disables threading support
+ elif test "$enable_thread_safe" != yes ; then
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([shared cache needs thread attribute.])
+ elif test "$ax_pthread_ok" != yes && "$mpfr_c11_thread_ok" != yes ; then
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([shared cache needs pthread/C11 library.])
+ else
+ AC_MSG_RESULT(yes)
+ if test "$ax_pthread_ok" = yes ; then
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ LIBS="$LIBS $PTHREAD_LIBS"
+ fi
+ fi
+])
+
+dnl MPFR_CHECK_CONSTRUCTOR_ATTR
+dnl ---------------------------
+dnl Check for constructor/destructor attributes to function.
+dnl Output: Define
+dnl * MPFR_HAVE_CONSTRUCTOR_ATTR C define
+dnl * mpfr_have_constructor_destructor_attributes shell variable to yes
+dnl if supported.
+AC_DEFUN([MPFR_CHECK_CONSTRUCTOR_ATTR], [
+AC_MSG_CHECKING([for constructor and destructor attributes])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <stdlib.h>
+int x = 0;
+__attribute__((constructor)) static void
+call_f(void) { x = 1742; }
+__attribute__((destructor)) static void
+call_g(void) { x = 1448; }
+]], [[
+ return (x == 1742) ? 0 : 1;
+]])], [AC_MSG_RESULT(yes)
+ mpfr_have_constructor_destructor_attributes=yes ],
+ [AC_MSG_RESULT(no)]
+)
+
+if test "$mpfr_have_constructor_destructor_attributes" = "yes"; then
+ AC_DEFINE(MPFR_HAVE_CONSTRUCTOR_ATTR, 1,
+ [Define if the constructor/destructor GCC attributes are supported.])
+fi
+])
+
+dnl MPFR_CHECK_C11_THREAD
+dnl ---------------------
+dnl Check for C11 thread support
+dnl Output: Define
+dnl * MPFR_HAVE_C11_LOCK C define
+dnl * mpfr_c11_thread_ok shell variable to yes
+dnl if supported.
+dnl We don't check for __STDC_NO_THREADS__ define variable but rather try to mimic our usage.
+AC_DEFUN([MPFR_CHECK_C11_THREAD], [
+AC_MSG_CHECKING([for ISO C11 thread support])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <assert.h>
+#include <thread.h>
+ mtx_t lock;
+ once_flag once = ONCE_FLAG_INIT;
+ thrd_t thd_idx;
+ int x = 0;
+ void once_call (void) { x = 1; }
+]], [[
+ int err;
+ err = mtx_init(&lock, mtx_plain);
+ assert(err == thrd_success);
+ err = mtx_lock(&lock);
+ assert(err == thrd_success);
+ err = mtx_unlock(&lock);
+ assert(err == thrd_success);
+ mtx_destroy(&lock);
+ once_call(&once, once_call);
+ return x == 1 ? 0 : -1;
+]])], [AC_MSG_RESULT(yes)
+ mpfr_c11_thread_ok=yes ],
+ [AC_MSG_RESULT(no)]
+)
+
+if test "$mpfr_c11_thread_ok" = "yes"; then
+ AC_DEFINE(MPFR_HAVE_C11_LOCK, 1,
+ [Define if the ISO C11 Thread is supported.])
+fi
+])
+
+