2 dnl Copyright (C) 2007, 2009-2018 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_FLOOR],
9 m4_divert_text([DEFAULTS], [gl_floor_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 dnl Test whether floor() can be used without libm.
13 if test "$FLOOR_LIBM" = "?"; then
16 m4_ifdef([gl_FUNC_FLOOR_IEEE], [
17 if test $gl_floor_required = ieee && test $REPLACE_FLOOR = 0; then
18 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
19 AC_CACHE_CHECK([whether floor works according to ISO C 99 with IEC 60559],
20 [gl_cv_func_floor_ieee],
23 LIBS="$LIBS $FLOOR_LIBM"
26 #ifndef __NO_MATH_INLINES
27 # define __NO_MATH_INLINES 1 /* for glibc */
30 ]gl_DOUBLE_MINUS_ZERO_CODE[
31 ]gl_DOUBLE_SIGNBIT_CODE[
32 static double dummy (double f) { return 0; }
33 int main (int argc, char *argv[])
35 double (*my_floor) (double) = argc ? floor : dummy;
36 /* Test whether floor (-0.0) is -0.0. */
37 if (signbitd (minus_zerod) && !signbitd (my_floor (minus_zerod)))
42 [gl_cv_func_floor_ieee=yes],
43 [gl_cv_func_floor_ieee=no],
45 # Guess yes on glibc systems.
46 *-gnu* | gnu*) gl_cv_func_floor_ieee="guessing yes" ;;
47 # Guess yes on native Windows.
48 mingw*) gl_cv_func_floor_ieee="guessing yes" ;;
49 # If we don't know, assume the worst.
50 *) gl_cv_func_floor_ieee="guessing no" ;;
55 case "$gl_cv_func_floor_ieee" in
61 if test $REPLACE_FLOOR = 1; then
62 dnl No libraries are needed to link lib/floor.c.
65 AC_SUBST([FLOOR_LIBM])
68 # Determines the libraries needed to get the floor() function.
70 AC_DEFUN([gl_FUNC_FLOOR_LIBS],
72 gl_CACHE_VAL_SILENT([gl_cv_func_floor_libm], [
73 gl_cv_func_floor_libm=?
76 [[#ifndef __NO_MATH_INLINES
77 # define __NO_MATH_INLINES 1 /* for glibc */
80 double (*funcptr) (double) = floor;
82 [[x = funcptr(x) + floor(x);]])],
83 [gl_cv_func_floor_libm=])
84 if test "$gl_cv_func_floor_libm" = "?"; then
89 [[#ifndef __NO_MATH_INLINES
90 # define __NO_MATH_INLINES 1 /* for glibc */
93 double (*funcptr) (double) = floor;
95 [[x = funcptr(x) + floor(x);]])],
96 [gl_cv_func_floor_libm="-lm"])
100 FLOOR_LIBM="$gl_cv_func_floor_libm"