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