diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-06-09 10:53:21 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-06-09 10:53:21 +0000 |
commit | c65d9ccdc2eccb0ccaf6efe00789f1bd4bdeba10 (patch) | |
tree | b1f0e5f95b4513ca561ed65fcd5fe2a2621fb4d2 | |
parent | 536f0395a0859e20a44d0aa796034f4aa2481f1f (diff) | |
download | mpfr-c65d9ccdc2eccb0ccaf6efe00789f1bd4bdeba10.tar.gz |
[acinclude.m4] Make MPFR_CHECK_MP_LIMB_T_VS_LONG and
MPFR_CHECK_MP_LIMB_T_VS_INTMAX similar:
* Use AC_LINK_IFELSE in MPFR_CHECK_MP_LIMB_T_VS_LONG too: this
is safer than AC_COMPILE_IFELSE, as it will detect undefined
function-like macros.
* Define MPFR_USE_STATIC_ASSERT in MPFR_CHECK_MP_LIMB_T_VS_INTMAX
too in order to make sure that a static assertion is used (not
the MPFR_ASSERTN fallback).
Note: These constitute redundant safeguards because if MPFR_ASSERTN
is used, it will be regarded as a function since the macro is not
defined in this context, and linking will fail as a consequence.
But this redundancy will protect more against MPFR code evolution.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13949 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | acinclude.m4 | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index aab0f49ee..5e58d476c 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -996,7 +996,6 @@ esac dnl MPFR_CHECK_MP_LIMB_T_VS_LONG dnl ---------------------------- dnl Check whether a long fits in mp_limb_t. -dnl Note: Since AC_COMPILE_IFELSE is used, the test needs a static assertion. dnl If static assertions are not supported, one gets "no" even though a long dnl fits in mp_limb_t. Therefore, code without MPFR_LONG_WITHIN_LIMB defined dnl needs to be portable. @@ -1009,7 +1008,11 @@ 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([[ +dnl AC_LINK_IFELSE is safer than AC_COMPILE_IFELSE, as it will detect +dnl undefined function-like macros (which otherwise may be regarded +dnl as valid function calls with AC_COMPILE_IFELSE since prototypes +dnl are not required by the C standard). +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <gmp.h> /* Make sure that a static assertion is used (not MPFR_ASSERTN). */ #undef MPFR_USE_STATIC_ASSERT @@ -1037,10 +1040,15 @@ if test "$ac_cv_type_intmax_t" = yes; then AC_CACHE_CHECK([for intmax_t to fit in mp_limb_t], mpfr_cv_intmax_within_limb, [ saved_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$srcdir/src -DMPFR_NEED_INTMAX_H" -dnl AC_LINK_IFELSE is safier than AC_COMPILE_IFELSE, which did not detect -dnl the missing #include "mpfr-sassert.h". +dnl AC_LINK_IFELSE is safer than AC_COMPILE_IFELSE, as it will detect +dnl undefined function-like macros (which otherwise may be regarded +dnl as valid function calls with AC_COMPILE_IFELSE since prototypes +dnl are not required by the C standard). AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <gmp.h> +/* Make sure that a static assertion is used (not MPFR_ASSERTN). */ +#undef MPFR_USE_STATIC_ASSERT +#define MPFR_USE_STATIC_ASSERT 1 #include "mpfr-sassert.h" #include "mpfr-intmax.h" ]], [[ |