1 # remainderf.m4 serial 3
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_REMAINDERF],
9 m4_divert_text([DEFAULTS], [gl_remainderf_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 AC_REQUIRE([gl_FUNC_REMAINDER])
13 dnl Test whether remainderf() exists. Assume that remainderf(), if it exists, is
14 dnl defined in the same library as remainder().
16 LIBS="$LIBS $REMAINDER_LIBM"
17 AC_CACHE_CHECK([for remainderf],
18 [gl_cv_func_remainderf],
22 [[#ifndef __NO_MATH_INLINES
23 # define __NO_MATH_INLINES 1 /* for glibc */
26 float (*funcptr) (float, float) = remainderf;
29 [[return funcptr (x, y) > 1
30 || remainderf (x, y) > 1;]])],
31 [gl_cv_func_remainderf=yes],
32 [gl_cv_func_remainderf=no])
35 if test $gl_cv_func_remainderf = yes; then
36 REMAINDERF_LIBM="$REMAINDER_LIBM"
37 m4_ifdef([gl_FUNC_REMAINDERF_IEEE], [
38 if test $gl_remainderf_required = ieee && test $REPLACE_REMAINDERF = 0; then
39 AC_CACHE_CHECK([whether remainderf works according to ISO C 99 with IEC 60559],
40 [gl_cv_func_remainderf_ieee],
43 LIBS="$LIBS $REMAINDERF_LIBM"
46 #ifndef __NO_MATH_INLINES
47 # define __NO_MATH_INLINES 1 /* for glibc */
50 /* Compare two numbers with ==.
51 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
54 numeric_equal (float x, float y)
58 static float dummy (float x, float y) { return 0; }
59 int main (int argc, char *argv[])
61 float (*my_remainderf) (float, float) = argc ? remainderf : dummy;
64 /* Test remainderf(...,0.0f).
65 This test fails on OSF/1 5.1. */
66 f = my_remainderf (2.0f, 0.0f);
67 if (numeric_equal (f, f))
72 [gl_cv_func_remainderf_ieee=yes],
73 [gl_cv_func_remainderf_ieee=no],
74 [gl_cv_func_remainderf_ieee="guessing no"])
77 case "$gl_cv_func_remainderf_ieee" in
79 *) REPLACE_REMAINDERF=1 ;;
86 if test $HAVE_REMAINDERF = 0 || test $REPLACE_REMAINDERF = 1; then
87 dnl Find libraries needed to link lib/remainderf.c.
88 if test $gl_cv_func_remainder_no_libm = yes \
89 || test $gl_cv_func_remainder_in_libm = yes; then
90 AC_DEFINE([HAVE_REMAINDER], [1],
91 [Define to 1 if the remainder() function is available in libc or libm.])
92 REMAINDERF_LIBM="$REMAINDER_LIBM"
94 AC_REQUIRE([gl_FUNC_FABSF])
95 AC_REQUIRE([gl_FUNC_FMODF])
96 AC_REQUIRE([gl_FUNC_ISNANF])
98 dnl Append $FABSF_LIBM to REMAINDERF_LIBM, avoiding gratuitous duplicates.
99 case " $REMAINDERF_LIBM " in
100 *" $FABSF_LIBM "*) ;;
101 *) REMAINDERF_LIBM="$REMAINDERF_LIBM $FABSF_LIBM" ;;
103 dnl Append $FMODF_LIBM to REMAINDERF_LIBM, avoiding gratuitous duplicates.
104 case " $REMAINDERF_LIBM " in
105 *" $FMODF_LIBM "*) ;;
106 *) REMAINDERF_LIBM="$REMAINDERF_LIBM $FMODF_LIBM" ;;
108 dnl Append $ISNANF_LIBM to REMAINDERF_LIBM, avoiding gratuitous duplicates.
109 case " $REMAINDERF_LIBM " in
110 *" $ISNANF_LIBM "*) ;;
111 *) REMAINDERF_LIBM="$REMAINDERF_LIBM $ISNANF_LIBM" ;;
115 AC_SUBST([REMAINDERF_LIBM])