1 # remainderl.m4 serial 2
2 dnl Copyright (C) 2012 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_REMAINDERL],
9 m4_divert_text([DEFAULTS], [gl_remainderl_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
12 AC_REQUIRE([gl_FUNC_REMAINDER])
14 dnl Test whether remainderl() exists. Assume that remainderl(), if it exists, is
15 dnl defined in the same library as remainder().
17 LIBS="$LIBS $REMAINDER_LIBM"
18 AC_CACHE_CHECK([for remainderl],
19 [gl_cv_func_remainderl],
23 [[#ifndef __NO_MATH_INLINES
24 # define __NO_MATH_INLINES 1 /* for glibc */
27 long double (*funcptr) (long double, long double) = remainderl;
30 [[return funcptr (x, y) > 1
31 || remainderl (x, y) > 1;]])],
32 [gl_cv_func_remainderl=yes],
33 [gl_cv_func_remainderl=no])
36 if test $gl_cv_func_remainderl = yes; then
37 REMAINDERL_LIBM="$REMAINDER_LIBM"
38 m4_ifdef([gl_FUNC_REMAINDERL_IEEE], [
39 if test $gl_remainderl_required = ieee && test $REPLACE_REMAINDERL = 0; then
40 AC_CACHE_CHECK([whether remainderl works according to ISO C 99 with IEC 60559],
41 [gl_cv_func_remainderl_ieee],
44 LIBS="$LIBS $REMAINDERL_LIBM"
47 #ifndef __NO_MATH_INLINES
48 # define __NO_MATH_INLINES 1 /* for glibc */
51 /* Compare two numbers with ==.
52 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
55 numeric_equal (long double x, long double y)
59 static long double dummy (long double x, long double y) { return 0; }
60 int main (int argc, char *argv[])
62 long double (*my_remainderl) (long double, long double) = argc ? remainderl : dummy;
64 /* Test remainderl(...,0.0L).
65 This test fails on OSF/1 5.1. */
66 f = my_remainderl (2.0L, 0.0L);
67 if (numeric_equal (f, f))
72 [gl_cv_func_remainderl_ieee=yes],
73 [gl_cv_func_remainderl_ieee=no],
74 [gl_cv_func_remainderl_ieee="guessing no"])
77 case "$gl_cv_func_remainderl_ieee" in
79 *) REPLACE_REMAINDERL=1 ;;
86 if test $HAVE_REMAINDERL = 0 || test $REPLACE_REMAINDERL = 1; then
87 dnl Find libraries needed to link lib/remainderl.c.
88 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
89 REMAINDERL_LIBM="$REMAINDER_LIBM"
91 AC_REQUIRE([gl_FUNC_ROUNDL])
92 AC_REQUIRE([gl_FUNC_FMAL])
94 dnl Append $ROUNDL_LIBM to REMAINDERL_LIBM, avoiding gratuitous duplicates.
95 case " $REMAINDERL_LIBM " in
96 *" $ROUNDL_LIBM "*) ;;
97 *) REMAINDERL_LIBM="$REMAINDERL_LIBM $ROUNDL_LIBM" ;;
99 dnl Append $FMAL_LIBM to REMAINDERL_LIBM, avoiding gratuitous duplicates.
100 case " $REMAINDERL_LIBM " in
102 *) REMAINDERL_LIBM="$REMAINDERL_LIBM $FMAL_LIBM" ;;
106 AC_SUBST([REMAINDERL_LIBM])