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