Mercurial > hg > octave-shane > gnulib-hg
annotate m4/modf.m4 @ 17252:7a29ec33d6c5
missing @item
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Tue, 01 Jan 2013 09:17:08 -0800 |
parents | e542fd46ad6f |
children | 344018b6e5d7 |
rev | line source |
---|---|
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16467
diff
changeset
|
1 # modf.m4 serial 3 |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16811
diff
changeset
|
2 dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. |
15836 | 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_MODF], | |
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 | 12 dnl Determine MODF_LIBM. |
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 |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16467
diff
changeset
|
64 # Guess yes on glibc systems. |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16467
diff
changeset
|
65 *-gnu*) gl_cv_func_modf_ieee="guessing yes" ;; |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16467
diff
changeset
|
66 # 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:
16467
diff
changeset
|
67 *) gl_cv_func_modf_ieee="guessing no" ;; |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16467
diff
changeset
|
68 esac |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16467
diff
changeset
|
69 ]) |
16467
c5b61bdb6da4
modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
70 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
|
71 ]) |
c5b61bdb6da4
modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
72 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
|
73 *yes) ;; |
c5b61bdb6da4
modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
74 *) 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
|
75 esac |
c5b61bdb6da4
modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
76 fi |
c5b61bdb6da4
modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
77 ]) |
c5b61bdb6da4
modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
78 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
|
79 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
|
80 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
|
81 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
|
82 fi |
15836 | 83 ]) |