comparison m4/expm1.m4 @ 16588:6312b64c2c23

New module 'expm1-ieee'. * modules/expm1-ieee: New file. * m4/expm1-ieee.m4: New file. * m4/expm1.m4 (gl_FUNC_EXPM1): If gl_FUNC_EXPM1_IEEE is present, test whether expm1 works with a minus zero argument. Replace it if not. * lib/math.in.h (expm1): Override if REPLACE_EXPM1 is 1. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_EXPM1. * modules/math (Makefile.am): Substitute REPLACE_EXPM1. * modules/expm1 (configure.ac): Consider REPLACE_EXPM1. (Depends-on): Update conditions. * doc/posix-functions/expm1.texi: Mention the expm1-ieee module and the AIX problem.
author Bruno Haible <bruno@clisp.org>
date Wed, 07 Mar 2012 00:38:50 +0100
parents 8e7ddab445f4
children b187fc49964b
comparison
equal deleted inserted replaced
16587:d71dacc1f7e0 16588:6312b64c2c23
1 # expm1.m4 serial 1 1 # expm1.m4 serial 2
2 dnl Copyright (C) 2010-2012 Free Software Foundation, Inc. 2 dnl Copyright (C) 2010-2012 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
7 AC_DEFUN([gl_FUNC_EXPM1], 7 AC_DEFUN([gl_FUNC_EXPM1],
8 [ 8 [
9 m4_divert_text([DEFAULTS], [gl_expm1_required=plain])
9 AC_REQUIRE([gl_MATH_H_DEFAULTS]) 10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 11
11 dnl Persuade glibc <math.h> to declare expm1(). 12 dnl Persuade glibc <math.h> to declare expm1().
12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
13 14
50 ]) 51 ])
51 if test $gl_cv_func_expm1_in_libm = yes; then 52 if test $gl_cv_func_expm1_in_libm = yes; then
52 EXPM1_LIBM=-lm 53 EXPM1_LIBM=-lm
53 fi 54 fi
54 fi 55 fi
55 if test $gl_cv_func_expm1_no_libm = no \ 56 if test $gl_cv_func_expm1_no_libm = yes \
56 && test $gl_cv_func_expm1_in_libm = no; then 57 || test $gl_cv_func_expm1_in_libm = yes; then
58 :
59 m4_ifdef([gl_FUNC_EXPM1_IEEE], [
60 if test $gl_expm1_required = ieee && test $REPLACE_EXPM1 = 0; then
61 AC_CACHE_CHECK([whether expm1 works according to ISO C 99 with IEC 60559],
62 [gl_cv_func_expm1_ieee],
63 [
64 save_LIBS="$LIBS"
65 LIBS="$LIBS $EXPM1_LIBM"
66 AC_RUN_IFELSE(
67 [AC_LANG_SOURCE([[
68 #ifndef __NO_MATH_INLINES
69 # define __NO_MATH_INLINES 1 /* for glibc */
70 #endif
71 #include <math.h>
72 ]gl_DOUBLE_MINUS_ZERO_CODE[
73 ]gl_DOUBLE_SIGNBIT_CODE[
74 static double dummy (double x) { return 0; }
75 int main (int argc, char *argv[])
76 {
77 double (*my_expm1) (double) = argc ? expm1 : dummy;
78 double y = my_expm1 (minus_zerod);
79 if (!(y == 0.0) || (signbitd (minus_zerod) && !signbitd (y)))
80 return 1;
81 return 0;
82 }
83 ]])],
84 [gl_cv_func_expm1_ieee=yes],
85 [gl_cv_func_expm1_ieee=no],
86 [gl_cv_func_expm1_ieee="guessing no"])
87 LIBS="$save_LIBS"
88 ])
89 case "$gl_cv_func_expm1_ieee" in
90 *yes) ;;
91 *) REPLACE_EXPM1=1 ;;
92 esac
93 fi
94 ])
95 else
57 HAVE_EXPM1=0 96 HAVE_EXPM1=0
97 fi
98 if test $HAVE_EXPM1 = 0 || test $REPLACE_EXPM1 = 1; then
58 dnl Find libraries needed to link lib/expm1.c. 99 dnl Find libraries needed to link lib/expm1.c.
59 AC_REQUIRE([gl_FUNC_ISNAND]) 100 AC_REQUIRE([gl_FUNC_ISNAND])
60 AC_REQUIRE([gl_FUNC_EXP]) 101 AC_REQUIRE([gl_FUNC_EXP])
61 AC_REQUIRE([gl_FUNC_ROUND]) 102 AC_REQUIRE([gl_FUNC_ROUND])
62 AC_REQUIRE([gl_FUNC_LDEXP]) 103 AC_REQUIRE([gl_FUNC_LDEXP])