ceil.m4 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # ceil.m4 serial 5
  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. AC_DEFUN([gl_FUNC_CEIL],
  7. [
  8. m4_divert_text([DEFAULTS], [gl_ceil_required=plain])
  9. AC_REQUIRE([gl_MATH_H_DEFAULTS])
  10. dnl Test whether ceil() can be used without libm.
  11. gl_FUNC_CEIL_LIBS
  12. if test "$CEIL_LIBM" = "?"; then
  13. CEIL_LIBM=
  14. fi
  15. m4_ifdef([gl_FUNC_CEIL_IEEE], [
  16. if test $gl_ceil_required = ieee && test $REPLACE_CEIL = 0; then
  17. AC_CACHE_CHECK([whether ceil works according to ISO C 99 with IEC 60559],
  18. [gl_cv_func_ceil_ieee],
  19. [
  20. save_LIBS="$LIBS"
  21. LIBS="$LIBS $CEIL_LIBM"
  22. AC_RUN_IFELSE(
  23. [AC_LANG_SOURCE([[
  24. #ifndef __NO_MATH_INLINES
  25. # define __NO_MATH_INLINES 1 /* for glibc */
  26. #endif
  27. #include <math.h>
  28. ]gl_DOUBLE_MINUS_ZERO_CODE[
  29. ]gl_DOUBLE_SIGNBIT_CODE[
  30. int main()
  31. {
  32. /* Test whether ceil (-0.0) is -0.0. */
  33. if (signbitd (minus_zerod) && !signbitd (ceil (minus_zerod)))
  34. return 1;
  35. return 0;
  36. }
  37. ]])],
  38. [gl_cv_func_ceil_ieee=yes],
  39. [gl_cv_func_ceil_ieee=no],
  40. [gl_cv_func_ceil_ieee="guessing no"])
  41. LIBS="$save_LIBS"
  42. ])
  43. case "$gl_cv_func_ceil_ieee" in
  44. *yes) ;;
  45. *) REPLACE_CEIL=1 ;;
  46. esac
  47. fi
  48. ])
  49. if test $REPLACE_CEIL = 1; then
  50. AC_LIBOBJ([ceil])
  51. CEIL_LIBM=
  52. fi
  53. AC_SUBST([CEIL_LIBM])
  54. ])
  55. # Determines the libraries needed to get the ceil() function.
  56. # Sets CEIL_LIBM.
  57. AC_DEFUN([gl_FUNC_CEIL_LIBS],
  58. [
  59. gl_CACHE_VAL_SILENT([gl_cv_func_ceil_libm], [
  60. gl_cv_func_ceil_libm=?
  61. AC_LINK_IFELSE(
  62. [AC_LANG_PROGRAM(
  63. [[#ifndef __NO_MATH_INLINES
  64. # define __NO_MATH_INLINES 1 /* for glibc */
  65. #endif
  66. #include <math.h>
  67. double x;]],
  68. [[x = ceil(x);]])],
  69. [gl_cv_func_ceil_libm=])
  70. if test "$gl_cv_func_ceil_libm" = "?"; then
  71. save_LIBS="$LIBS"
  72. LIBS="$LIBS -lm"
  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. double x;]],
  80. [[x = ceil(x);]])],
  81. [gl_cv_func_ceil_libm="-lm"])
  82. LIBS="$save_LIBS"
  83. fi
  84. ])
  85. CEIL_LIBM="$gl_cv_func_ceil_libm"
  86. ])