Files
Bruno Haible a9b04535c1 Improve cross-compilation guesses for native Windows.
* m4/btowc.m4 (gl_FUNC_BTOWC): Add cross-compilation guess for native
Windows.
* m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Likewise.
* m4/calloc.m4 (_AC_FUNC_CALLOC_IF): Likewise.
* m4/canonicalize.m4 (gl_FUNC_REALPATH_WORKS): Likewise.
* m4/cbrtf.m4 (gl_FUNC_CBRTF_WORKS): Likewise.
* m4/cbrtl.m4 (gl_FUNC_CBRTL, gl_FUNC_CBRTL_WORKS): Likewise.
* m4/ceil.m4 (gl_FUNC_CEIL): Likewise.
* m4/ceilf.m4 (gl_FUNC_CEILF): Likewise.
* m4/ceill.m4 (gl_FUNC_CEILL): Likewise.
* m4/d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO): Likewise.
* m4/dup.m4 (gl_FUNC_DUP): Likewise.
* m4/expl.m4 (gl_FUNC_EXPL): Likewise.
* m4/exp2.m4 (gl_FUNC_EXP2_WORKS): Likewise.
* m4/exp2l.m4 (gl_FUNC_EXP2L): Likewise.
* m4/expm1.m4 (gl_FUNC_EXPM1): Likewise.
* m4/expm1f.m4 (gl_FUNC_EXPM1F_WORKS): Likewise.
* m4/exponentl.m4 (gl_LONG_DOUBLE_EXPONENT_LOCATION): Likewise.
* m4/fabsl.m4 (gl_FUNC_FABSL_WORKS): Likewise.
* m4/fchdir.m4 (gl_FUNC_FCHDIR): Likewise.
* m4/fcntl-o.m4 (gl_FCNTL_O_FLAGS): Likewise.
* m4/float_h.m4 (gl_FLOAT_H): Likewise.
* m4/floor.m4 (gl_FUNC_FLOOR): Likewise.
* m4/floorf.m4 (gl_FUNC_FLOORF): Likewise.
* m4/fma.m4 (gl_FUNC_FMA_WORKS): Likewise.
* m4/fmaf.m4 (gl_FUNC_FMAF_WORKS): Likewise.
* m4/fmal.m4 (gl_FUNC_FMAL_WORKS): Likewise.
* m4/fmod.m4 (gl_FUNC_FMOD): Likewise.
* m4/fmodf.m4 (gl_FUNC_FMODF): Likewise.
* m4/fmodl.m4 (gl_FUNC_FMODL): Likewise.
* m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Likewise.
* m4/frexpf.m4 (gl_FUNC_FREXPF_WORKS): Likewise.
* m4/ftello.m4 (gl_FUNC_FTELLO): Likewise.
* m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY_CLOBBER): Likewise.
* m4/hypot.m4 (gl_FUNC_HYPOT): Likewise.
* m4/hypotf.m4 (gl_FUNC_HYPOTF, gl_FUNC_HYPOTF_WORKS): Likewise.
* m4/hypotl.m4 (gl_FUNC_HYPOTL, gl_FUNC_HYPOTL_WORKS): Likewise.
* m4/ilogb.m4 (gl_FUNC_ILOGB_WORKS): Likewise.
* m4/ilogbf.m4 (gl_FUNC_ILOGBF_WORKS): Likewise.
* m4/isfinite.m4 (gl_ISFINITEL_WORKS): Likewise.
* m4/isinf.m4 (gl_ISINFL_WORKS): Likewise.
* m4/isnanf.m4 (gl_ISNANF_WORKS): Likewise.
* m4/isnanl.m4 (gl_FUNC_ISNANL_WORKS): Likewise.
* m4/ldexpl.m4 (gl_FUNC_LDEXPL_WORKS): Likewise.
* m4/log.m4 (gl_FUNC_LOG, gl_FUNC_LOG_WORKS): Likewise.
* m4/logf.m4 (gl_FUNC_LOGF, gl_FUNC_LOGF_WORKS): Likewise.
* m4/logl.m4 (gl_FUNC_LOGL_WORKS): Likewise.
* m4/log10.m4 (gl_FUNC_LOG10, gl_FUNC_LOG10_WORKS): Likewise.
* m4/log10f.m4 (gl_FUNC_LOG10F, gl_FUNC_LOG10F_WORKS): Likewise.
* m4/log10l.m4 (gl_FUNC_LOG10L_WORKS): Likewise.
* m4/log1p.m4 (gl_FUNC_LOG1P): Likewise.
* m4/log1pf.m4 (gl_FUNC_LOG1PF, gl_FUNC_LOG1PF_WORKS): Likewise.
* m4/log1pl.m4 (gl_FUNC_LOG1PL): Likewise.
* m4/log2.m4 (gl_FUNC_LOG2, gl_FUNC_LOG2_WORKS): Likewise.
* m4/log2f.m4 (gl_FUNC_LOG2F, gl_FUNC_LOG2F_WORKS): Likewise.
* m4/log2l.m4 (gl_FUNC_LOG2L_WORKS): Likewise.
* m4/logb.m4 (gl_FUNC_LOGB_WORKS): Likewise.
* m4/logbf.m4 (gl_FUNC_LOGBF_WORKS): Likewise.
* m4/logbl.m4 (gl_FUNC_LOGBL_WORKS): Likewise.
* m4/lstat.m4 (gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK): Likewise.
* m4/mbrtowc.m4 (gl_MBRTOWC_EMPTY_INPUT, gl_MBRTOWC_C_LOCALE): Likewise.
* m4/mkdir.m4 (gl_FUNC_MKDIR): Likewise.
* m4/mkstemp.m4 (gl_FUNC_MKSTEMP): Likewise.
* m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Likewise.
* m4/modf.m4 (gl_FUNC_MODF): Likewise.
* m4/modff.m4 (gl_FUNC_MODFF): Likewise.
* m4/modfl.m4 (gl_FUNC_MODFL): Likewise.
* m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Likewise.
* m4/perror.m4 (gl_FUNC_PERROR): Likewise.
* m4/popen.m4 (gl_FUNC_POPEN): Likewise.
* m4/posix_spawn.m4 (gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE,
gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2,
gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN): Likewise.
* m4/ptsname_r.m4 (gl_PREREQ_PTSNAME_R): Likewise.
* m4/putenv.m4 (gl_FUNC_PUTENV): Likewise.
* m4/regex.m4 (gl_REGEX): Likewise.
* m4/remainder.m4 (gl_FUNC_REMAINDER): Likewise.
* m4/remainderf.m4 (gl_FUNC_REMAINDERF,
gl_FUNC_REMAINDERF_WORKS): Likewise.
* m4/remainderl.m4 (gl_FUNC_REMAINDERL,
gl_FUNC_REMAINDERL_WORKS): Likewise.
* m4/rename.m4 (gl_FUNC_RENAME): Likewise.
* m4/rmdir-errno.m4 (gl_FUNC_RMDIR_NOTEMPTY): Likewise.
* m4/rmdir.m4 (gl_FUNC_RMDIR): Likewise.
* m4/round.m4 (gl_FUNC_ROUND): Likewise.
* m4/roundf.m4 (gl_FUNC_ROUNDF): Likewise.
* m4/roundl.m4 (gl_FUNC_ROUNDL): Likewise.
* m4/signbit.m4 (gl_SIGNBIT): Likewise.
* m4/sleep.m4 (gl_FUNC_SLEEP): Likewise.
* m4/sqrtl.m4 (gl_FUNC_SQRTL_WORKS): Likewise.
* m4/stdint.m4 (gl_STDINT_H): Likewise.
* m4/strerror.m4 (gl_FUNC_STRERROR_0): Likewise.
* m4/strncat.m4 (gl_FUNC_STRNCAT): Likewise.
* m4/strtod.m4 (gl_FUNC_STRTOD): Likewise.
* m4/strtoimax.m4 (gl_FUNC_STRTOIMAX): Likewise.
* m4/strtok_r.m4 (gl_FUNC_STRTOK_R): Likewise.
* m4/trunc.m4 (gl_FUNC_TRUNC): Likewise.
* m4/truncf.m4 (gl_FUNC_TRUNCF): Likewise.
* m4/truncl.m4 (gl_FUNC_TRUNCL): Likewise.
* m4/tsearch.m4 (gl_FUNC_TSEARCH): Likewise.
* m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Likewise.
* m4/ungetc.m4 (gl_FUNC_UNGETC_WORKS): Likewise.
* m4/unlink-busy.m4 (gl_FUNC_UNLINK_BUSY_TEXT): Likewise.
* m4/unlink.m4 (gl_FUNC_UNLINK): Likewise.
* m4/usleep.m4 (gl_FUNC_USLEEP): Likewise.
* m4/utimes.m4 (gl_FUNC_UTIMES): Likewise.
* m4/wcrtomb.m4 (gl_FUNC_WCRTOMB): Likewise.
* m4/wcsrtombs.m4 (gl_WCSRTOMBS_TERMINATION, gl_WCSRTOMBS_NULL):
Likewise.
* m4/wctob.m4 (gl_FUNC_WCTOB): Likewise.
* m4/chown.m4 (AC_FUNC_CHOWN): Add cross-compilation guess for native
Windows. Enable also on Autoconf 2.70.
* m4/printf.m4 (gl_PRINTF_SIZES_C99, gl_PRINTF_LONG_DOUBLE,
gl_PRINTF_INFINITE, gl_PRINTF_INFINITE_LONG_DOUBLE,
gl_PRINTF_DIRECTIVE_A, gl_PRINTF_DIRECTIVE_F, gl_PRINTF_DIRECTIVE_N,
gl_PRINTF_DIRECTIVE_LS, gl_PRINTF_FLAG_LEFTADJUST, gl_PRINTF_FLAG_ZERO,
gl_SNPRINTF_TRUNCATION_C99, gl_SNPRINTF_RETVAL_C99,
gl_SNPRINTF_DIRECTIVE_N, gl_SNPRINTF_SIZE1): Add cross-compilation guess
for native Windows.
(gl_PRINTF_POSITIONS, gl_PRINTF_FLAG_GROUPING,
gl_VSNPRINTF_ZEROSIZE_C99): Add comment.
2017-07-13 21:07:22 +02:00

391 lines
17 KiB
Plaintext

# fmal.m4 serial 6
dnl Copyright (C) 2011-2017 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.
AC_DEFUN([gl_FUNC_FMAL],
[
AC_REQUIRE([gl_MATH_H_DEFAULTS])
AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
dnl Persuade glibc <math.h> to declare fmal().
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
dnl Determine FMAL_LIBM.
gl_MATHFUNC([fmal], [long double], [(long double, long double, long double)],
[extern
#ifdef __cplusplus
"C"
#endif
long double fmal (long double, long double, long double);
])
if test $gl_cv_func_fmal_no_libm = yes \
|| test $gl_cv_func_fmal_in_libm = yes; then
dnl Also check whether it's declared.
dnl IRIX 6.5 has fmal() in libm but doesn't declare it in <math.h>,
dnl and the function is buggy.
AC_CHECK_DECL([fmal], , [REPLACE_FMAL=1], [[#include <math.h>]])
if test $REPLACE_FMAL = 0; then
gl_FUNC_FMAL_WORKS
case "$gl_cv_func_fmal_works" in
*no) REPLACE_FMAL=1 ;;
esac
fi
else
HAVE_FMAL=0
fi
if test $HAVE_FMAL = 0 || test $REPLACE_FMAL = 1; then
dnl Find libraries needed to link lib/fmal.c.
if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
AC_REQUIRE([gl_FUNC_FMA])
FMAL_LIBM="$FMA_LIBM"
else
AC_REQUIRE([gl_FUNC_FREXPL])
AC_REQUIRE([gl_FUNC_LDEXPL])
AC_REQUIRE([gl_FUNC_FEGETROUND])
FMAL_LIBM=
dnl Append $FREXPL_LIBM to FMAL_LIBM, avoiding gratuitous duplicates.
case " $FMAL_LIBM " in
*" $FREXPL_LIBM "*) ;;
*) FMAL_LIBM="$FMAL_LIBM $FREXPL_LIBM" ;;
esac
dnl Append $LDEXPL_LIBM to FMAL_LIBM, avoiding gratuitous duplicates.
case " $FMAL_LIBM " in
*" $LDEXPL_LIBM "*) ;;
*) FMAL_LIBM="$FMAL_LIBM $LDEXPL_LIBM" ;;
esac
dnl Append $FEGETROUND_LIBM to FMAL_LIBM, avoiding gratuitous duplicates.
case " $FMAL_LIBM " in
*" $FEGETROUND_LIBM "*) ;;
*) FMAL_LIBM="$FMAL_LIBM $FEGETROUND_LIBM" ;;
esac
fi
fi
AC_SUBST([FMAL_LIBM])
])
dnl Test whether fmal() has any of the 15 known bugs of glibc 2.11.3 on x86_64.
AC_DEFUN([gl_FUNC_FMAL_WORKS],
[
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_REQUIRE([gl_FUNC_LDEXPL])
save_LIBS="$LIBS"
LIBS="$LIBS $FMAL_LIBM $LDEXPL_LIBM"
AC_CACHE_CHECK([whether fmal works], [gl_cv_func_fmal_works],
[
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include <float.h>
#include <math.h>
/* Override the values of <float.h>, like done in float.in.h. */
#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
# undef LDBL_MANT_DIG
# define LDBL_MANT_DIG 64
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP (-16381)
# undef LDBL_MAX_EXP
# define LDBL_MAX_EXP 16384
#endif
#if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
# undef LDBL_MANT_DIG
# define LDBL_MANT_DIG 64
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP (-16381)
# undef LDBL_MAX_EXP
# define LDBL_MAX_EXP 16384
#endif
#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP DBL_MIN_EXP
#endif
#if defined __sgi && (LDBL_MANT_DIG >= 106)
# undef LDBL_MANT_DIG
# define LDBL_MANT_DIG 106
# if defined __GNUC__
# undef LDBL_MIN_EXP
# define LDBL_MIN_EXP DBL_MIN_EXP
# endif
#endif
long double p0 = 0.0L;
int main()
{
int failed_tests = 0;
/* This test fails on glibc 2.11 powerpc. */
{
volatile long double x = 1.5L; /* 3 * 2^-1 */
volatile long double y = x;
volatile long double z = ldexpl (1.0L, LDBL_MANT_DIG + 1); /* 2^65 */
/* x * y + z with infinite precision: 2^65 + 9 * 2^-2.
Lies between (2^63 + 0) * 2^2 and (2^63 + 1) * 2^2
and is closer to (2^63 + 1) * 2^2, therefore the rounding
must round up and produce (2^63 + 1) * 2^2. */
volatile long double expected = z + 4.0L;
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 1;
}
/* This test fails on glibc 2.11 powerpc. */
{
volatile long double x = 1.25L; /* 2^0 + 2^-2 */
volatile long double y = - x;
volatile long double z = ldexpl (1.0L, LDBL_MANT_DIG + 1); /* 2^65 */
/* x * y + z with infinite precision: 2^65 - 2^0 - 2^-1 - 2^-4.
Lies between (2^64 - 1) * 2^1 and 2^64 * 2^1
and is closer to (2^64 - 1) * 2^1, therefore the rounding
must round down and produce (2^64 - 1) * 2^1. */
volatile long double expected = (ldexpl (1.0L, LDBL_MANT_DIG) - 1.0L) * 2.0L;
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 1;
}
/* This test fails on glibc 2.11 x86,x86_64,powerpc, glibc 2.7 hppa,sparc,
OSF/1 5.1, mingw. */
{
volatile long double x = 1.0L + ldexpl (1.0L, 1 - LDBL_MANT_DIG); /* 2^0 + 2^-63 */
volatile long double y = x;
volatile long double z = 4.0L; /* 2^2 */
/* x * y + z with infinite precision: 2^2 + 2^0 + 2^-62 + 2^-126.
Lies between (2^63 + 2^61) * 2^-61 and (2^63 + 2^61 + 1) * 2^-61
and is closer to (2^63 + 2^61 + 1) * 2^-61, therefore the rounding
must round up and produce (2^63 + 2^61 + 1) * 2^-61. */
volatile long double expected = 4.0L + 1.0L + ldexpl (1.0L, 3 - LDBL_MANT_DIG);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 2;
}
/* This test fails on glibc 2.11 x86,x86_64,powerpc glibc 2.7 hppa,sparc,
OSF/1 5.1, mingw. */
{
volatile long double x = 1.0L + ldexpl (1.0L, 1 - LDBL_MANT_DIG); /* 2^0 + 2^-63 */
volatile long double y = - x;
volatile long double z = 8.0L; /* 2^3 */
/* x * y + z with infinite precision: 2^2 + 2^1 + 2^0 - 2^-62 - 2^-126.
Lies between (2^63 + 2^62 + 2^61 - 1) * 2^-61 and
(2^63 + 2^62 + 2^61) * 2^-61 and is closer to
(2^63 + 2^62 + 2^61 - 1) * 2^-61, therefore the rounding
must round down and produce (2^63 + 2^62 + 2^61 - 1) * 2^-61. */
volatile long double expected = 7.0L - ldexpl (1.0L, 3 - LDBL_MANT_DIG);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 2;
}
/* This test fails on glibc 2.11 powerpc. */
{
volatile long double x = 1.25L; /* 2^0 + 2^-2 */
volatile long double y = - 0.75L; /* - 2^0 + 2^-2 */
volatile long double z = ldexpl (1.0L, LDBL_MANT_DIG); /* 2^64 */
/* x * y + z with infinite precision: 2^64 - 2^0 + 2^-4.
Lies between (2^64 - 2^0) and 2^64 and is closer to (2^64 - 2^0),
therefore the rounding must round down and produce (2^64 - 2^0). */
volatile long double expected = ldexpl (1.0L, LDBL_MANT_DIG) - 1.0L;
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 1;
}
if ((LDBL_MANT_DIG % 2) == 1)
{
/* These tests fail on glibc 2.7 hppa,sparc, OSF/1 5.1. */
{
volatile long double x = 1.0L + ldexpl (1.0L, - (LDBL_MANT_DIG + 1) / 2); /* 2^0 + 2^-27 */
volatile long double y = 1.0L - ldexpl (1.0L, - (LDBL_MANT_DIG + 1) / 2); /* 2^0 - 2^-27 */
volatile long double z = - ldexpl (1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG); /* - 2^-1074 */
/* x * y + z with infinite precision: 2^0 - 2^-54 - 2^-1074.
Lies between (2^53 - 1) * 2^-53 and 2^53 * 2^-53 and is closer to
(2^53 - 1) * 2^-53, therefore the rounding must round down and
produce (2^53 - 1) * 2^-53. */
volatile long double expected = 1.0L - ldexpl (1.0L, - LDBL_MANT_DIG);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 4;
}
{
volatile long double x = 1.0L + ldexpl (1.0L, - (LDBL_MANT_DIG + 1) / 2); /* 2^0 + 2^-57 */
volatile long double y = x;
volatile long double z = ldexpl (1.0L, - LDBL_MANT_DIG); /* 2^-113 */
/* x * y + z with infinite precision: 2^0 + 2^-56 + 2^-113 + 2^-114.
Lies between (2^112 + 2^56) * 2^-112 and (2^112 + 2^56 + 1) * 2^-112
and is closer to (2^112 + 2^56 + 1) * 2^-112, therefore the rounding
must round up and produce (2^112 + 2^56 + 1) * 2^-112. */
volatile long double expected =
1.0L + ldexpl (1.0L, - (LDBL_MANT_DIG - 1) / 2) + ldexpl (1.0L, 1 - LDBL_MANT_DIG);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 4;
}
}
else
{
/* These tests fail on glibc 2.11 x86,x86_64,powerpc, mingw. */
{
volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
volatile long double y = x;
volatile long double z = ldexpl (1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG); /* 2^-16445 */
/* x * y + z with infinite precision: 2^0 + 2^-31 + 2^-64 + 2^-16445.
Lies between (2^63 + 2^32 + 0) * 2^-63 and (2^63 + 2^32 + 1) * 2^-63
and is closer to (2^63 + 2^32 + 1) * 2^-63, therefore the rounding
must round up and produce (2^63 + 2^32 + 1) * 2^-63. */
volatile long double expected =
1.0L + ldexpl (1.0L, 1 - LDBL_MANT_DIG / 2) + ldexpl (1.0L, 1 - LDBL_MANT_DIG);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 8;
}
{
volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
volatile long double y = x;
volatile long double z = ldexpl (1.0L, - LDBL_MANT_DIG); /* 2^-64 */
/* x * y + z with infinite precision: 2^0 + 2^-31 + 2^-63.
Rounding must return this value unchanged. */
volatile long double expected = 1.0L + ldexpl (1.0L, 1 - LDBL_MANT_DIG / 2) + ldexpl (1.0L, 1 - LDBL_MANT_DIG);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 8;
}
{
volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
volatile long double y = x;
volatile long double z = ldexpl (1.0L, 1 - LDBL_MANT_DIG); /* 2^-63 */
/* x * y + z with infinite precision: 2^0 + 2^-31 + 2^-63 + 2^-64.
Lies between (2^63 + 2^32 + 1) * 2^-63 and (2^63 + 2^32 + 2) * 2^-63
and is at the same distance from each. According to the round-to-even
rule, the rounding must round up and produce (2^63 + 2^32 + 2) * 2^-63. */
volatile long double expected = 1.0L + ldexpl (1.0L, -31) + ldexpl (1.0L, -62);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 8;
}
{
volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
volatile long double y = x;
volatile long double z = ldexpl (1.0L, LDBL_MANT_DIG / 2 + 1); /* 2^33 */
/* x * y + z with infinite precision: 2^33 + 2^0 + 2^-31 + 2^-64.
Lies between (2^63 + 2^30) * 2^-30 and (2^63 + 2^30 + 1) * 2^-30
and is closer to (2^63 + 2^30 + 1) * 2^-30, therefore the rounding
must round up and produce (2^63 + 2^30 + 1) * 2^-30. */
volatile long double expected = z + 1.0L + ldexp (1.0L, 2 - LDBL_MANT_DIG / 2);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 8;
}
{
volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
volatile long double y = x;
volatile long double z = - ldexpl (1.0, 1 - LDBL_MANT_DIG); /* - 2^-63 */
/* x * y + z with infinite precision: 2^0 + 2^-31 - 2^-64.
Lies between (2^63 + 2^32 - 1) * 2^-63 and (2^63 + 2^32) * 2^-63
and is at the same distance from each. According to the round-to-even
rule, the rounding must round up and produce (2^63 + 2^32) * 2^-63. */
volatile long double expected = 1.0L + ldexpl (1.0L, 1 - LDBL_MANT_DIG / 2);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 8;
}
{
volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
volatile long double y = x;
volatile long double z = - 1.0L; /* - 2^0 */
/* x * y + z with infinite precision: 2^-31 + 2^-64.
Rounding must return this value unchanged. */
volatile long double expected = ldexpl (1.0L, 1 - LDBL_MANT_DIG / 2) + ldexpl (1.0L, - LDBL_MANT_DIG);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 8;
}
{
volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
volatile long double y = - x;
volatile long double z = 2.0L; /* 2^1 */
/* x * y + z with infinite precision: 2^0 - 2^31 - 2^-64.
Rounding must return this value unchanged. */
volatile long double expected = 1.0L - ldexpl (1.0L, 1 - LDBL_MANT_DIG / 2) - ldexpl (1.0L, - LDBL_MANT_DIG);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 8;
}
{
volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
volatile long double y = - x;
volatile long double z = ldexpl (1.0L, LDBL_MANT_DIG / 2 + 2); /* 2^34 */
/* x * y + z with infinite precision: 2^34 - (2^0 + 2^-31 + 2^-64).
Lies between (2^64 - 2^30 - 1) * 2^-30 and (2^64 - 2^30) * 2^-30
and is closer to (2^64 - 2^30 - 1) * 2^-30, therefore the rounding
must round down and produce (2^64 - 2^30 - 1) * 2^-30. */
volatile long double expected = z - 1.0L - ldexpl (1.0L, 2 - LDBL_MANT_DIG / 2);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 8;
}
{
volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2 - 1); /* 2^0 + 2^-33 */
volatile long double y = 1.0L - ldexpl (1.0L, - LDBL_MANT_DIG / 2 - 1); /* 2^0 - 2^-33 */
volatile long double z = - ldexpl (1.0L, - LDBL_MANT_DIG - 1); /* 2^-65 */
/* x * y + z with infinite precision: 2^0 - 2^-65 - 2^-66.
Lies between (2^64 - 1) * 2^-64 and 2^64 * 2^-64 and is closer to
(2^64 - 1) * 2^-64, therefore the rounding must round down and
produce (2^64 - 1) * 2^-64. */
volatile long double expected = 1.0L - ldexpl (1.0L, - LDBL_MANT_DIG);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 8;
}
{
volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2 - 1); /* 2^0 + 2^-33 */
volatile long double y = 1.0L - ldexpl (1.0L, - LDBL_MANT_DIG / 2 - 1); /* 2^0 - 2^-33 */
volatile long double z = - 1.0L; /* 2^0 */
/* x * y + z with infinite precision: - 2^-66.
Rounding must return this value unchanged. */
volatile long double expected = - ldexpl (1.0L, - LDBL_MANT_DIG - 2);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 8;
}
}
/* This test fails on glibc 2.11 x86,x86_64,powerpc, glibc 2.7 hppa,sparc,
FreeBSD 6.4 x86, mingw. */
{
long double minus_inf = -1.0L / p0;
volatile long double x = ldexpl (1.0L, LDBL_MAX_EXP - 1);
volatile long double y = ldexpl (1.0L, LDBL_MAX_EXP - 1);
volatile long double z = minus_inf;
volatile long double result = fmal (x, y, z);
if (!(result == minus_inf))
failed_tests |= 16;
}
/* This test fails on glibc 2.11 x86,x86_64,powerpc glibc 2.7 hppa,sparc,
Mac OS X 10.5, FreeBSD 6.4 x86, OSF/1 5.1, mingw. */
{
volatile long double x = ldexpl (1.0L, LDBL_MAX_EXP - 1);
volatile long double y = 2.0L;
volatile long double z =
- ldexpl (ldexpl (1.0L, LDBL_MAX_EXP - 1) - ldexpl (1.0L, LDBL_MAX_EXP - LDBL_MANT_DIG - 1), 1);
volatile long double expected = ldexpl (1.0L, LDBL_MAX_EXP - LDBL_MANT_DIG);
volatile long double result = fmal (x, y, z);
if (result != expected)
failed_tests |= 32;
}
return failed_tests;
}]])],
[gl_cv_func_fmal_works=yes],
[gl_cv_func_fmal_works=no],
[dnl Guess yes on native Windows with MSVC.
dnl Otherwise guess no, even on glibc systems.
gl_cv_func_fmal_works="guessing no"
case "$host_os" in
mingw*)
AC_EGREP_CPP([Known], [
#ifdef _MSC_VER
Known
#endif
], [gl_cv_func_fmal_works="guessing yes"])
;;
esac
])
])
LIBS="$save_LIBS"
])
# Prerequisites of lib/fmal.c.
AC_DEFUN([gl_PREREQ_FMAL], [:])