Branch
Hash :
7b089321
Author :
Date :
2025-01-01T09:24:36
maint: run 'make update-copyright'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
# fenv-exceptions-tracking-c23.m4
# serial 2
dnl Copyright (C) 2023-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FENV_EXCEPTIONS_TRACKING_C23],
[
AC_REQUIRE([gl_FENV_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST])
gl_MATHFUNC([fesetexcept], [int], [(int)], [#include <fenv.h>])
if test $gl_cv_func_fesetexcept_no_libm != yes \
&& test $gl_cv_func_fesetexcept_in_libm != yes; then
HAVE_FESETEXCEPT=0
else
dnl Persuade glibc <fenv.h> to declare feenableexcept().
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
gl_MATHFUNC([feenableexcept], [int], [(int)], [#include <fenv.h>])
dnl On glibc 2.37 for PowerPC and i386, fesetexcept may raise traps.
AC_CACHE_CHECK([whether fesetexcept is guaranteed non-trapping],
[gl_cv_func_fesetexcept_works],
[if test $gl_cv_func_feenableexcept_no_libm = yes \
|| test $gl_cv_func_feenableexcept_in_libm = yes; then
dnl A platform that has feenableexcept.
saved_LIBS="$LIBS"
if test $gl_cv_func_feenableexcept_no_libm != yes; then
LIBS="$LIBS -lm"
fi
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <fenv.h>
static volatile double a, b;
static volatile long double al, bl;
]],
[[if (feclearexcept (FE_INVALID) == 0
&& feenableexcept (FE_INVALID) == 0
&& fesetexcept (FE_INVALID) == 0)
{
a = 1.0; b = a + a;
al = 1.0L; bl = al + al;
}
return 0;
]])
],
[gl_cv_func_fesetexcept_works=yes],
[gl_cv_func_fesetexcept_works=no],
[case "$host_os" in
# Guess yes or no on glibc systems, depending on CPU.
*-gnu*)
case "$host_cpu" in
changequote(,)dnl
powerpc* | i[34567]86 | x86_64)
changequote([,])dnl
gl_cv_func_fesetexcept_works="guessing no" ;;
*)
gl_cv_func_fesetexcept_works="guessing yes" ;;
esac
;;
# If we don't know, obey --enable-cross-guesses.
*) gl_cv_func_fesetexcept_works="$gl_cross_guess_normal" ;;
esac
])
LIBS="$saved_LIBS"
else
gl_cv_func_fesetexcept_works="guessing yes"
fi
])
case "$gl_cv_func_fesetexcept_works" in
*yes) ;;
*) REPLACE_FESETEXCEPT=1 ;;
esac
fi
dnl Modify FENV_EXCEPTIONS_TRACKING_LIBM, set by gl_FENV_EXCEPTIONS_TRACKING.
AC_REQUIRE([gl_FENV_EXCEPTIONS_TRACKING])
if test $HAVE_FESETEXCEPT = 0 || test $REPLACE_FESETEXCEPT = 1; then
gl_PREREQ_FENV_EXCEPTIONS
dnl Possibly need -lm for fpgetsticky(), fpsetsticky().
if test $gl_cv_func_fpsetsticky_no_libm = no \
&& test $gl_cv_func_fpsetsticky_in_libm = yes \
&& test -z "$FENV_EXCEPTIONS_TRACKING_LIBM"; then
FENV_EXCEPTIONS_TRACKING_LIBM=-lm
fi
fi
])