maint: update all copyright year number ranges
[gnulib.git] / m4 / ceill.m4
1 # ceill.m4 serial 12
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_CEILL],
8 [
9   m4_divert_text([DEFAULTS], [gl_ceill_required=plain])
10   AC_REQUIRE([gl_MATH_H_DEFAULTS])
11   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
12
13   dnl Persuade glibc <math.h> to declare ceill().
14   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15
16   dnl Test whether ceill() is declared.
17   AC_CHECK_DECLS([ceill], , , [[#include <math.h>]])
18   if test "$ac_cv_have_decl_ceill" = yes; then
19     dnl Test whether ceill() can be used without libm.
20     gl_FUNC_CEILL_LIBS
21     if test "$CEILL_LIBM" = "?"; then
22       dnl Sun C 5.0 on Solaris declares ceill() and has it in the system-wide
23       dnl libm.so, but not in the libm.so that the compiler uses.
24       REPLACE_CEILL=1
25     fi
26     m4_ifdef([gl_FUNC_CEILL_IEEE], [
27       if test $gl_ceill_required = ieee && test $REPLACE_CEILL = 0; then
28         AC_CACHE_CHECK([whether ceill works according to ISO C 99 with IEC 60559],
29           [gl_cv_func_ceill_ieee],
30           [
31             save_LIBS="$LIBS"
32             LIBS="$LIBS $CEILL_LIBM"
33             AC_RUN_IFELSE(
34               [AC_LANG_SOURCE([[
35 #ifndef __NO_MATH_INLINES
36 # define __NO_MATH_INLINES 1 /* for glibc */
37 #endif
38 #include <math.h>
39 ]gl_LONG_DOUBLE_MINUS_ZERO_CODE[
40 ]gl_LONG_DOUBLE_SIGNBIT_CODE[
41 static long double dummy (long double f) { return 0; }
42 int main (int argc, char *argv[])
43 {
44   long double (*my_ceill) (long double) = argc ? ceill : dummy;
45   /* Test whether ceill (-0.3L) is -0.0L.  */
46   if (signbitl (minus_zerol) && !signbitl (my_ceill (-0.3L)))
47     return 1;
48   return 0;
49 }
50               ]])],
51               [gl_cv_func_ceill_ieee=yes],
52               [gl_cv_func_ceill_ieee=no],
53               [gl_cv_func_ceill_ieee="guessing no"])
54             LIBS="$save_LIBS"
55           ])
56         case "$gl_cv_func_ceill_ieee" in
57           *yes) ;;
58           *) REPLACE_CEILL=1 ;;
59         esac
60       fi
61     ])
62   else
63     HAVE_DECL_CEILL=0
64   fi
65   if test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1; then
66     dnl Find libraries needed to link lib/ceill.c.
67     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
68       AC_REQUIRE([gl_FUNC_CEIL])
69       CEILL_LIBM="$CEIL_LIBM"
70     else
71       CEILL_LIBM=
72     fi
73   fi
74   AC_SUBST([CEILL_LIBM])
75 ])
76
77 # Determines the libraries needed to get the ceill() function.
78 # Sets CEILL_LIBM.
79 AC_DEFUN([gl_FUNC_CEILL_LIBS],
80 [
81   gl_CACHE_VAL_SILENT([gl_cv_func_ceill_libm], [
82     gl_cv_func_ceill_libm=?
83     AC_LINK_IFELSE(
84       [AC_LANG_PROGRAM(
85          [[#ifndef __NO_MATH_INLINES
86            # define __NO_MATH_INLINES 1 /* for glibc */
87            #endif
88            #include <math.h>
89            long double x;]],
90          [[x = ceill(x);]])],
91       [gl_cv_func_ceill_libm=])
92     if test "$gl_cv_func_ceill_libm" = "?"; then
93       save_LIBS="$LIBS"
94       LIBS="$LIBS -lm"
95       AC_LINK_IFELSE(
96         [AC_LANG_PROGRAM(
97            [[#ifndef __NO_MATH_INLINES
98              # define __NO_MATH_INLINES 1 /* for glibc */
99              #endif
100              #include <math.h>
101              long double x;]],
102            [[x = ceill(x);]])],
103         [gl_cv_func_ceill_libm="-lm"])
104       LIBS="$save_LIBS"
105     fi
106   ])
107   CEILL_LIBM="$gl_cv_func_ceill_libm"
108 ])