annotate m4/log.m4 @ 17921:58c1b50299a6

getopt: give accurate ambiguity diagnostic on mem exhaustion * lib/getopt.c (_getopt_internal_r): The previous commit broke out the loop too early, which could give a false indication of ambiguous options under memory exhaustion.
author Pádraig Brady <P@draigBrady.com>
date Wed, 18 Feb 2015 22:37:31 +0000
parents ab58d4870664
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16643
diff changeset
1 # log.m4 serial 4
17848
ab58d4870664 version-etc: new year
Paul Eggert <eggert@cs.ucla.edu>
parents: 17587
diff changeset
2 dnl Copyright (C) 2011-2015 Free Software Foundation, Inc.
15862
e369ba8115ea log: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
e369ba8115ea log: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
e369ba8115ea log: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
e369ba8115ea log: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
e369ba8115ea log: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_LOG],
e369ba8115ea log: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
16643
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
9 m4_divert_text([DEFAULTS], [gl_log_required=plain])
16636
521c2cde0e31 log: Fix bug introduced on 2012-03-09.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
521c2cde0e31 log: Fix bug introduced on 2012-03-09.
Bruno Haible <bruno@clisp.org>
parents: 16631
diff changeset
11
15862
e369ba8115ea log: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 dnl Determine LOG_LIBM.
e369ba8115ea log: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 gl_COMMON_DOUBLE_MATHFUNC([log])
16631
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
14
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
15 save_LIBS="$LIBS"
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
16 LIBS="$LIBS $LOG_LIBM"
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
17 gl_FUNC_LOG_WORKS
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
18 LIBS="$save_LIBS"
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
19 case "$gl_cv_func_log_works" in
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
20 *yes) ;;
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
21 *) REPLACE_LOG=1 ;;
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
22 esac
16643
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
23
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
24 m4_ifdef([gl_FUNC_LOG_IEEE], [
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
25 if test $gl_log_required = ieee && test $REPLACE_LOG = 0; then
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16643
diff changeset
26 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16643
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
27 AC_CACHE_CHECK([whether log works according to ISO C 99 with IEC 60559],
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
28 [gl_cv_func_log_ieee],
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
29 [
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
30 save_LIBS="$LIBS"
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
31 LIBS="$LIBS $LOG_LIBM"
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
32 AC_RUN_IFELSE(
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
33 [AC_LANG_SOURCE([[
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
34 #ifndef __NO_MATH_INLINES
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
35 # define __NO_MATH_INLINES 1 /* for glibc */
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
36 #endif
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
37 #include <math.h>
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
38 /* Compare two numbers with ==.
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
39 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
40 'x == x' test. */
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
41 static int
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
42 numeric_equal (double x, double y)
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
43 {
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
44 return x == y;
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
45 }
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
46 static double dummy (double x) { return 0; }
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
47 int main (int argc, char *argv[])
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
48 {
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
49 double (*my_log) (double) = argc ? log : dummy;
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
50 /* Test log(negative).
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
51 This test fails on NetBSD 5.1, Solaris 11 2011-11. */
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
52 double y = my_log (-1.0);
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
53 if (numeric_equal (y, y))
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
54 return 1;
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
55 return 0;
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
56 }
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
57 ]])],
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
58 [gl_cv_func_log_ieee=yes],
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
59 [gl_cv_func_log_ieee=no],
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16643
diff changeset
60 [case "$host_os" in
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16643
diff changeset
61 # Guess yes on glibc systems.
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16643
diff changeset
62 *-gnu*) gl_cv_func_log_ieee="guessing yes" ;;
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16643
diff changeset
63 # If we don't know, assume the worst.
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16643
diff changeset
64 *) gl_cv_func_log_ieee="guessing no" ;;
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16643
diff changeset
65 esac
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16643
diff changeset
66 ])
16643
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
67 LIBS="$save_LIBS"
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
68 ])
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
69 case "$gl_cv_func_log_ieee" in
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
70 *yes) ;;
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
71 *) REPLACE_LOG=1 ;;
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
72 esac
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
73 fi
90bb29c30680 log-ieee: Work around test failure on NetBSD 5.1 and Solaris 11.
Bruno Haible <bruno@clisp.org>
parents: 16636
diff changeset
74 ])
15862
e369ba8115ea log: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 ])
16631
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
76
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
77 dnl Test whether log() works.
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
78 dnl On OSF/1 5.1, log(-0.0) is NaN.
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
79 AC_DEFUN([gl_FUNC_LOG_WORKS],
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
80 [
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
81 AC_REQUIRE([AC_PROG_CC])
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
82 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
83 AC_CACHE_CHECK([whether log works], [gl_cv_func_log_works],
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
84 [
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
85 AC_RUN_IFELSE(
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
86 [AC_LANG_SOURCE([[
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
87 #include <math.h>
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
88 volatile double x;
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
89 double y;
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
90 int main ()
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
91 {
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
92 x = -0.0;
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
93 y = log (x);
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
94 if (!(y + y == y))
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
95 return 1;
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
96 return 0;
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
97 }
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
98 ]])],
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
99 [gl_cv_func_log_works=yes],
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
100 [gl_cv_func_log_works=no],
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
101 [case "$host_os" in
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
102 osf*) gl_cv_func_log_works="guessing no";;
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
103 *) gl_cv_func_log_works="guessing yes";;
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
104 esac
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
105 ])
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
106 ])
45443deebb7d log: Work around OSF/1 5.1 bug.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
107 ])