strtoumax: fix typo in previous commit.
[gnulib.git] / m4 / floorl.m4
1 # floorl.m4 serial 11
2 dnl Copyright (C) 2007, 2009-2013 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.
6
7 AC_DEFUN([gl_FUNC_FLOORL],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
11
12   dnl Persuade glibc <math.h> to declare floorl().
13   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14
15   dnl Test whether floorl() is declared.
16   AC_CHECK_DECLS([floorl], , , [[#include <math.h>]])
17   if test "$ac_cv_have_decl_floorl" = yes; then
18     dnl Test whether floorl() can be used without libm.
19     gl_FUNC_FLOORL_LIBS
20     if test "$FLOORL_LIBM" = "?"; then
21       dnl Sun C 5.0 on Solaris declares floorl() and has it in the system-wide
22       dnl libm.so, but not in the libm.so that the compiler uses.
23       REPLACE_FLOORL=1
24     fi
25   else
26     HAVE_DECL_FLOORL=0
27   fi
28   if test $HAVE_DECL_FLOORL = 0 || test $REPLACE_FLOORL = 1; then
29     dnl Find libraries needed to link lib/floorl.c.
30     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
31       AC_REQUIRE([gl_FUNC_FLOOR])
32       FLOORL_LIBM="$FLOOR_LIBM"
33     else
34       FLOORL_LIBM=
35     fi
36   fi
37   AC_SUBST([FLOORL_LIBM])
38 ])
39
40 # Determines the libraries needed to get the floorl() function.
41 # Sets FLOORL_LIBM.
42 AC_DEFUN([gl_FUNC_FLOORL_LIBS],
43 [
44   gl_CACHE_VAL_SILENT([gl_cv_func_floorl_libm], [
45     gl_cv_func_floorl_libm=?
46     AC_LINK_IFELSE(
47       [AC_LANG_PROGRAM(
48          [[#ifndef __NO_MATH_INLINES
49            # define __NO_MATH_INLINES 1 /* for glibc */
50            #endif
51            #include <math.h>
52            long double (*funcptr) (long double) = floorl;
53            long double x;]],
54          [[x = funcptr (x) + floorl(x);]])],
55       [gl_cv_func_floorl_libm=])
56     if test "$gl_cv_func_floorl_libm" = "?"; then
57       save_LIBS="$LIBS"
58       LIBS="$LIBS -lm"
59       AC_LINK_IFELSE(
60         [AC_LANG_PROGRAM(
61            [[#ifndef __NO_MATH_INLINES
62              # define __NO_MATH_INLINES 1 /* for glibc */
63              #endif
64              #include <math.h>
65              long double (*funcptr) (long double) = floorl;
66              long double x;]],
67            [[x = funcptr (x) + floorl(x);]])],
68         [gl_cv_func_floorl_libm="-lm"])
69       LIBS="$save_LIBS"
70     fi
71   ])
72   FLOORL_LIBM="$gl_cv_func_floorl_libm"
73 ])