ldexp.m4 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # ldexp.m4 serial 1
  2. dnl Copyright (C) 2010-2023 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_LDEXP],
  7. [
  8. AC_REQUIRE([gl_CHECK_LDEXP_NO_LIBM])
  9. LDEXP_LIBM=
  10. if test $gl_cv_func_ldexp_no_libm = no; then
  11. AC_CACHE_CHECK([whether ldexp() can be used with libm],
  12. [gl_cv_func_ldexp_in_libm],
  13. [
  14. save_LIBS="$LIBS"
  15. LIBS="$LIBS -lm"
  16. AC_LINK_IFELSE(
  17. [AC_LANG_PROGRAM([[#ifndef __NO_MATH_INLINES
  18. # define __NO_MATH_INLINES 1 /* for glibc */
  19. #endif
  20. #include <math.h>
  21. double (*funcptr) (double, int) = ldexp;
  22. double x;]],
  23. [[return ldexp (x, -1) > 0;]])],
  24. [gl_cv_func_ldexp_in_libm=yes],
  25. [gl_cv_func_ldexp_in_libm=no])
  26. LIBS="$save_LIBS"
  27. ])
  28. if test $gl_cv_func_ldexp_in_libm = yes; then
  29. LDEXP_LIBM=-lm
  30. fi
  31. fi
  32. AC_SUBST([LDEXP_LIBM])
  33. ])
  34. dnl Test whether ldexp() can be used without linking with libm.
  35. dnl Set gl_cv_func_ldexp_no_libm to 'yes' or 'no' accordingly.
  36. AC_DEFUN([gl_CHECK_LDEXP_NO_LIBM],
  37. [
  38. AC_CACHE_CHECK([whether ldexp() can be used without linking with libm],
  39. [gl_cv_func_ldexp_no_libm],
  40. [
  41. AC_LINK_IFELSE(
  42. [AC_LANG_PROGRAM([[#ifndef __NO_MATH_INLINES
  43. # define __NO_MATH_INLINES 1 /* for glibc */
  44. #endif
  45. #include <math.h>
  46. double (*funcptr) (double, int) = ldexp;
  47. double x;]],
  48. [[return ldexp (x, -1) > 0;]])],
  49. [gl_cv_func_ldexp_no_libm=yes],
  50. [gl_cv_func_ldexp_no_libm=no])
  51. ])
  52. ])