annotate m4/modf.m4 @ 40057:b06060465f09

maint: Run 'make update-copyright'
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2019 00:25:11 +0100
parents 10eb9086bea0
children e2e6dc79463b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19479
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
1 # modf.m4 serial 5
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc.
15836
46afe93343fd modf: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
46afe93343fd modf: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
46afe93343fd modf: 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.
46afe93343fd modf: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
46afe93343fd modf: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_MODF],
46afe93343fd modf: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
16467
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
9 m4_divert_text([DEFAULTS], [gl_modf_required=plain])
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
11
15836
46afe93343fd modf: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 dnl Determine MODF_LIBM.
46afe93343fd modf: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 gl_MATHFUNC([modf], [double], [(double, double *)])
16467
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
14
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
15 m4_ifdef([gl_FUNC_MODF_IEEE], [
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
16 if test $gl_modf_required = ieee && test $REPLACE_MODF = 0; then
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16467
diff changeset
17 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16467
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
18 AC_CACHE_CHECK([whether modf works according to ISO C 99 with IEC 60559],
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
19 [gl_cv_func_modf_ieee],
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
20 [
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
21 save_LIBS="$LIBS"
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
22 LIBS="$LIBS $MODF_LIBM"
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
23 AC_RUN_IFELSE(
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
24 [AC_LANG_SOURCE([[
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
25 #ifndef __NO_MATH_INLINES
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
26 # define __NO_MATH_INLINES 1 /* for glibc */
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
27 #endif
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
28 #include <math.h>
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
29 ]gl_DOUBLE_MINUS_ZERO_CODE[
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
30 ]gl_DOUBLE_SIGNBIT_CODE[
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
31 /* Compare two numbers with ==.
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
32 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
33 'x == x' test. */
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
34 static int
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
35 numeric_equal (double x, double y)
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
36 {
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
37 return x == y;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
38 }
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
39 static double dummy (double x, double *iptr) { return 0; }
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
40 double zero;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
41 double minus_one = - 1.0;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
42 int main (int argc, char *argv[])
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
43 {
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
44 double (*my_modf) (double, double *) = argc ? modf : dummy;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
45 int result = 0;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
46 double i;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
47 double f;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
48 /* Test modf(NaN,...).
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
49 This test fails on NetBSD 5.1, Cygwin. */
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
50 f = my_modf (zero / zero, &i);
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
51 if (numeric_equal (f, f))
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
52 result |= 1;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
53 /* Test modf(-Inf,...).
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
54 This test fails on FreeBSD 6.4, OpenBSD 4.9, IRIX 6.5, OSF/1 5.1. */
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
55 f = my_modf (minus_one / zero, &i);
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
56 if (!(f == 0.0) || (signbitd (minus_zerod) && !signbitd (f)))
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
57 result |= 2;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
58 return result;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
59 }
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
60 ]])],
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
61 [gl_cv_func_modf_ieee=yes],
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
62 [gl_cv_func_modf_ieee=no],
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16467
diff changeset
63 [case "$host_os" in
19479
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
64 # Guess yes on glibc systems.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
65 *-gnu* | gnu*) gl_cv_func_modf_ieee="guessing yes" ;;
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
66 # Guess yes on MSVC, no on mingw.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
67 mingw*) AC_EGREP_CPP([Known], [
18993
a75cfc731331 Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
68 #ifdef _MSC_VER
a75cfc731331 Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
69 Known
a75cfc731331 Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
70 #endif
19479
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
71 ],
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
72 [gl_cv_func_modf_ieee="guessing yes"],
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
73 [gl_cv_func_modf_ieee="guessing no"])
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
74 ;;
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
75 # If we don't know, assume the worst.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
76 *) gl_cv_func_modf_ieee="guessing no" ;;
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16467
diff changeset
77 esac
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16467
diff changeset
78 ])
16467
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
79 LIBS="$save_LIBS"
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
80 ])
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
81 case "$gl_cv_func_modf_ieee" in
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
82 *yes) ;;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
83 *) REPLACE_MODF=1 ;;
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
84 esac
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
85 fi
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
86 ])
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
87 if test $REPLACE_MODF = 1; then
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
88 dnl Find libraries needed to link lib/modf.c.
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
89 AC_REQUIRE([gl_FUNC_TRUNC])
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
90 MODF_LIBM="$TRUNC_LIBM"
c5b61bdb6da4 modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
91 fi
15836
46afe93343fd modf: Use a .m4 file.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 ])