maint: update all copyright year number ranges
[gnulib.git] / m4 / ceil.m4
1 # ceil.m4 serial 8
2 dnl Copyright (C) 2007, 2009-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.
6
7 AC_DEFUN([gl_FUNC_CEIL],
8 [
9   m4_divert_text([DEFAULTS], [gl_ceil_required=plain])
10   AC_REQUIRE([gl_MATH_H_DEFAULTS])
11   dnl Test whether ceil() can be used without libm.
12   gl_FUNC_CEIL_LIBS
13   if test "$CEIL_LIBM" = "?"; then
14     CEIL_LIBM=
15   fi
16   m4_ifdef([gl_FUNC_CEIL_IEEE], [
17     if test $gl_ceil_required = ieee && test $REPLACE_CEIL = 0; then
18       AC_CACHE_CHECK([whether ceil works according to ISO C 99 with IEC 60559],
19         [gl_cv_func_ceil_ieee],
20         [
21           save_LIBS="$LIBS"
22           LIBS="$LIBS $CEIL_LIBM"
23           AC_RUN_IFELSE(
24             [AC_LANG_SOURCE([[
25 #ifndef __NO_MATH_INLINES
26 # define __NO_MATH_INLINES 1 /* for glibc */
27 #endif
28 #include <math.h>
29 ]gl_DOUBLE_MINUS_ZERO_CODE[
30 ]gl_DOUBLE_SIGNBIT_CODE[
31 static double dummy (double f) { return 0; }
32 int main (int argc, char *argv[])
33 {
34   double (*my_ceil) (double) = argc ? ceil : dummy;
35   int result = 0;
36   /* Test whether ceil (-0.0) is -0.0.  */
37   if (signbitd (minus_zerod) && !signbitd (my_ceil (minus_zerod)))
38     result |= 1;
39   /* Test whether ceil (-0.3) is -0.0.  */
40   if (signbitd (-0.3) && !signbitd (my_ceil (-0.3)))
41     result |= 2;
42   return result;
43 }
44             ]])],
45             [gl_cv_func_ceil_ieee=yes],
46             [gl_cv_func_ceil_ieee=no],
47             [gl_cv_func_ceil_ieee="guessing no"])
48           LIBS="$save_LIBS"
49         ])
50       case "$gl_cv_func_ceil_ieee" in
51         *yes) ;;
52         *) REPLACE_CEIL=1 ;;
53       esac
54     fi
55   ])
56   if test $REPLACE_CEIL = 1; then
57     dnl No libraries are needed to link lib/ceil.c.
58     CEIL_LIBM=
59   fi
60   AC_SUBST([CEIL_LIBM])
61 ])
62
63 # Determines the libraries needed to get the ceil() function.
64 # Sets CEIL_LIBM.
65 AC_DEFUN([gl_FUNC_CEIL_LIBS],
66 [
67   gl_CACHE_VAL_SILENT([gl_cv_func_ceil_libm], [
68     gl_cv_func_ceil_libm=?
69     AC_LINK_IFELSE(
70       [AC_LANG_PROGRAM(
71          [[#ifndef __NO_MATH_INLINES
72            # define __NO_MATH_INLINES 1 /* for glibc */
73            #endif
74            #include <math.h>
75            double x;]],
76          [[x = ceil(x);]])],
77       [gl_cv_func_ceil_libm=])
78     if test "$gl_cv_func_ceil_libm" = "?"; then
79       save_LIBS="$LIBS"
80       LIBS="$LIBS -lm"
81       AC_LINK_IFELSE(
82         [AC_LANG_PROGRAM(
83            [[#ifndef __NO_MATH_INLINES
84              # define __NO_MATH_INLINES 1 /* for glibc */
85              #endif
86              #include <math.h>
87              double x;]],
88            [[x = ceil(x);]])],
89         [gl_cv_func_ceil_libm="-lm"])
90       LIBS="$save_LIBS"
91     fi
92   ])
93   CEIL_LIBM="$gl_cv_func_ceil_libm"
94 ])