16753
|
1 # logbf.m4 serial 1 |
17848
|
2 dnl Copyright (C) 2012-2015 Free Software Foundation, Inc. |
16753
|
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_LOGBF], |
|
8 [ |
|
9 AC_REQUIRE([gl_MATH_H_DEFAULTS]) |
|
10 |
|
11 dnl Persuade glibc <math.h> to declare logbf(). |
|
12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
|
13 |
|
14 dnl Determine LOGBF_LIBM. |
|
15 gl_MATHFUNC([logbf], [float], [(float)]) |
|
16 if test $gl_cv_func_logbf_no_libm = yes \ |
|
17 || test $gl_cv_func_logbf_in_libm = yes; then |
|
18 save_LIBS="$LIBS" |
|
19 LIBS="$LIBS $LOGBF_LIBM" |
|
20 gl_FUNC_LOGBF_WORKS |
|
21 LIBS="$save_LIBS" |
|
22 case "$gl_cv_func_logbf_works" in |
|
23 *yes) ;; |
|
24 *) REPLACE_LOGBF=1 ;; |
|
25 esac |
|
26 else |
|
27 HAVE_LOGBF=0 |
|
28 fi |
|
29 if test $HAVE_LOGBF = 0 || test $REPLACE_LOGBF = 1; then |
|
30 dnl Find libraries needed to link lib/logbf.c. |
|
31 AC_REQUIRE([gl_FUNC_FREXPF]) |
|
32 AC_REQUIRE([gl_FUNC_ISNANF]) |
|
33 LOGBF_LIBM= |
|
34 dnl Append $FREXPF_LIBM to LOGBF_LIBM, avoiding gratuitous duplicates. |
|
35 case " $LOGBF_LIBM " in |
|
36 *" $FREXPF_LIBM "*) ;; |
|
37 *) LOGBF_LIBM="$LOGBF_LIBM $FREXPF_LIBM" ;; |
|
38 esac |
|
39 dnl Append $ISNANF_LIBM to LOGBF_LIBM, avoiding gratuitous duplicates. |
|
40 case " $LOGBF_LIBM " in |
|
41 *" $ISNANF_LIBM "*) ;; |
|
42 *) LOGBF_LIBM="$LOGBF_LIBM $ISNANF_LIBM" ;; |
|
43 esac |
|
44 fi |
|
45 AC_SUBST([LOGBF_LIBM]) |
|
46 ]) |
|
47 |
|
48 dnl Test whether logbf() works. |
|
49 dnl On glibc 2.11/ppc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 10/SPARC, |
|
50 dnl the return value for subnormal (denormalized) arguments is too large. |
|
51 AC_DEFUN([gl_FUNC_LOGBF_WORKS], |
|
52 [ |
|
53 AC_REQUIRE([AC_PROG_CC]) |
|
54 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
|
55 AC_CACHE_CHECK([whether logbf works], [gl_cv_func_logbf_works], |
|
56 [ |
|
57 AC_RUN_IFELSE( |
|
58 [AC_LANG_SOURCE([[ |
|
59 #include <float.h> |
|
60 #include <math.h> |
|
61 volatile float x; |
|
62 int main () |
|
63 { |
|
64 int i; |
|
65 for (i = 1, x = 1.0f; i >= FLT_MIN_EXP; i--, x *= 0.5f) |
|
66 ; |
|
67 /* Here i = FLT_MIN_EXP - 1. Either x = 2^(i-1) is subnormal or x = 0.0. */ |
|
68 if (x > 0.0f && !(logbf (x) == (float)(i - 1))) |
|
69 return 1; |
|
70 return 0; |
|
71 } |
|
72 ]])], |
|
73 [gl_cv_func_logbf_works=yes], |
|
74 [gl_cv_func_logbf_works=no], |
|
75 [case "$host_os" in |
|
76 *gnu* | solaris*) gl_cv_func_logbf_works="guessing no";; |
|
77 *) gl_cv_func_logbf_works="guessing yes";; |
|
78 esac |
|
79 ]) |
|
80 ]) |
|
81 ]) |