1 # remainderf.m4 serial 4
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 Persuade glibc <math.h> to declare remainderf().
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16 dnl Test whether remainderf() exists. Assume that remainderf(), if it exists, is
17 dnl defined in the same library as remainder().
19 LIBS="$LIBS $REMAINDER_LIBM"
20 AC_CACHE_CHECK([for remainderf],
21 [gl_cv_func_remainderf],
25 [[#ifndef __NO_MATH_INLINES
26 # define __NO_MATH_INLINES 1 /* for glibc */
29 float (*funcptr) (float, float) = remainderf;
32 [[return funcptr (x, y) > 1
33 || remainderf (x, y) > 1;]])],
34 [gl_cv_func_remainderf=yes],
35 [gl_cv_func_remainderf=no])
38 if test $gl_cv_func_remainderf = yes; then
39 REMAINDERF_LIBM="$REMAINDER_LIBM"
40 m4_ifdef([gl_FUNC_REMAINDERF_IEEE], [
41 if test $gl_remainderf_required = ieee && test $REPLACE_REMAINDERF = 0; then
42 AC_CACHE_CHECK([whether remainderf works according to ISO C 99 with IEC 60559],
43 [gl_cv_func_remainderf_ieee],
46 LIBS="$LIBS $REMAINDERF_LIBM"
49 #ifndef __NO_MATH_INLINES
50 # define __NO_MATH_INLINES 1 /* for glibc */
53 /* Compare two numbers with ==.
54 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
57 numeric_equal (float x, float y)
61 static float dummy (float x, float y) { return 0; }
62 int main (int argc, char *argv[])
64 float (*my_remainderf) (float, float) = argc ? remainderf : dummy;
67 /* Test remainderf(...,0.0f).
68 This test fails on OSF/1 5.1. */
69 f = my_remainderf (2.0f, 0.0f);
70 if (numeric_equal (f, f))
75 [gl_cv_func_remainderf_ieee=yes],
76 [gl_cv_func_remainderf_ieee=no],
77 [gl_cv_func_remainderf_ieee="guessing no"])
80 case "$gl_cv_func_remainderf_ieee" in
82 *) REPLACE_REMAINDERF=1 ;;
89 if test $HAVE_REMAINDERF = 0 || test $REPLACE_REMAINDERF = 1; then
90 dnl Find libraries needed to link lib/remainderf.c.
91 if test $gl_cv_func_remainder_no_libm = yes \
92 || test $gl_cv_func_remainder_in_libm = yes; then
93 AC_DEFINE([HAVE_REMAINDER], [1],
94 [Define to 1 if the remainder() function is available in libc or libm.])
95 REMAINDERF_LIBM="$REMAINDER_LIBM"
97 AC_REQUIRE([gl_FUNC_FABSF])
98 AC_REQUIRE([gl_FUNC_FMODF])
99 AC_REQUIRE([gl_FUNC_ISNANF])
101 dnl Append $FABSF_LIBM to REMAINDERF_LIBM, avoiding gratuitous duplicates.
102 case " $REMAINDERF_LIBM " in
103 *" $FABSF_LIBM "*) ;;
104 *) REMAINDERF_LIBM="$REMAINDERF_LIBM $FABSF_LIBM" ;;
106 dnl Append $FMODF_LIBM to REMAINDERF_LIBM, avoiding gratuitous duplicates.
107 case " $REMAINDERF_LIBM " in
108 *" $FMODF_LIBM "*) ;;
109 *) REMAINDERF_LIBM="$REMAINDERF_LIBM $FMODF_LIBM" ;;
111 dnl Append $ISNANF_LIBM to REMAINDERF_LIBM, avoiding gratuitous duplicates.
112 case " $REMAINDERF_LIBM " in
113 *" $ISNANF_LIBM "*) ;;
114 *) REMAINDERF_LIBM="$REMAINDERF_LIBM $ISNANF_LIBM" ;;
118 AC_SUBST([REMAINDERF_LIBM])