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;
65 /* Test remainderl(...,0.0L).
66 This test fails on OSF/1 5.1. */
67 f = my_remainderl (2.0L, 0.0L);
68 if (numeric_equal (f, f))
73 [gl_cv_func_remainderl_ieee=yes],
74 [gl_cv_func_remainderl_ieee=no],
75 [gl_cv_func_remainderl_ieee="guessing no"])
78 case "$gl_cv_func_remainderl_ieee" in
80 *) REPLACE_REMAINDERL=1 ;;
87 if test $HAVE_REMAINDERL = 0 || test $REPLACE_REMAINDERL = 1; then
88 dnl Find libraries needed to link lib/remainderl.c.
89 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
90 REMAINDERL_LIBM="$REMAINDER_LIBM"
92 AC_REQUIRE([gl_FUNC_ROUNDL])
93 AC_REQUIRE([gl_FUNC_FMAL])
95 dnl Append $ROUNDL_LIBM to REMAINDERL_LIBM, avoiding gratuitous duplicates.
96 case " $REMAINDERL_LIBM " in
97 *" $ROUNDL_LIBM "*) ;;
98 *) REMAINDERL_LIBM="$REMAINDERL_LIBM $ROUNDL_LIBM" ;;
100 dnl Append $FMAL_LIBM to REMAINDERL_LIBM, avoiding gratuitous duplicates.
101 case " $REMAINDERL_LIBM " in
103 *) REMAINDERL_LIBM="$REMAINDERL_LIBM $FMAL_LIBM" ;;
107 AC_SUBST([REMAINDERL_LIBM])