Mercurial > gnulib
annotate m4/modff.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 |
rev | line source |
---|---|
19479
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
1 # modff.m4 serial 7 |
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. |
15838 | 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_MODFF], | |
8 [ | |
16468
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
9 m4_divert_text([DEFAULTS], [gl_modff_required=plain]) |
15838 | 10 AC_REQUIRE([gl_MATH_H_DEFAULTS]) |
11 AC_REQUIRE([gl_FUNC_MODF]) | |
12 | |
16580
fdbe3125f81a
math: Ensure declarations of math functions.
Bruno Haible <bruno@clisp.org>
parents:
16490
diff
changeset
|
13 dnl Persuade glibc <math.h> to declare modff(). |
fdbe3125f81a
math: Ensure declarations of math functions.
Bruno Haible <bruno@clisp.org>
parents:
16490
diff
changeset
|
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
fdbe3125f81a
math: Ensure declarations of math functions.
Bruno Haible <bruno@clisp.org>
parents:
16490
diff
changeset
|
15 |
15850
8acd9d76c20c
modff: Drop assumption about library that defines modff.
Bruno Haible <bruno@clisp.org>
parents:
15838
diff
changeset
|
16 dnl Test whether modff() exists. We cannot assume that modff(), if it |
8acd9d76c20c
modff: Drop assumption about library that defines modff.
Bruno Haible <bruno@clisp.org>
parents:
15838
diff
changeset
|
17 dnl exists, is defined in the same library as modf(). This is not the case |
8acd9d76c20c
modff: Drop assumption about library that defines modff.
Bruno Haible <bruno@clisp.org>
parents:
15838
diff
changeset
|
18 dnl on FreeBSD, NetBSD, OpenBSD. |
8acd9d76c20c
modff: Drop assumption about library that defines modff.
Bruno Haible <bruno@clisp.org>
parents:
15838
diff
changeset
|
19 gl_MATHFUNC([modff], [float], [(float, float *)]) |
16468
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
20 if test $gl_cv_func_modff_no_libm = yes \ |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
21 || test $gl_cv_func_modff_in_libm = yes; then |
16490
0d1fd31a3ea0
modff, modfl: Fix configure syntax error.
Bruno Haible <bruno@clisp.org>
parents:
16468
diff
changeset
|
22 : |
16468
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
23 m4_ifdef([gl_FUNC_MODFF_IEEE], [ |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
24 if test $gl_modff_required = ieee && test $REPLACE_MODFF = 0; then |
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16580
diff
changeset
|
25 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
16468
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
26 AC_CACHE_CHECK([whether modff works according to ISO C 99 with IEC 60559], |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
27 [gl_cv_func_modff_ieee], |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
28 [ |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
29 save_LIBS="$LIBS" |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
30 LIBS="$LIBS $MODFF_LIBM" |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
31 AC_RUN_IFELSE( |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
32 [AC_LANG_SOURCE([[ |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
33 #ifndef __NO_MATH_INLINES |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
34 # define __NO_MATH_INLINES 1 /* for glibc */ |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
35 #endif |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
36 #include <math.h> |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
37 ]gl_FLOAT_MINUS_ZERO_CODE[ |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
38 ]gl_FLOAT_SIGNBIT_CODE[ |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
39 /* Compare two numbers with ==. |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
40 This is a separate function because IRIX 6.5 "cc -O" miscompiles an |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
41 'x == x' test. */ |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
42 static int |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
43 numeric_equal (float x, float y) |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
44 { |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
45 return x == y; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
46 } |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
47 static float dummy (float x, float *iptr) { return 0; } |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
48 float zero; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
49 float minus_one = - 1.0f; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
50 int main (int argc, char *argv[]) |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
51 { |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
52 float (*my_modff) (float, float *) = argc ? modff : dummy; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
53 int result = 0; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
54 float i; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
55 float f; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
56 /* Test modff(NaN,...). |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
57 This test fails on NetBSD 5.1, OpenBSD 4.9, Solaris 9, Cygwin. */ |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
58 f = my_modff (zero / zero, &i); |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
59 if (numeric_equal (f, f)) |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
60 result |= 1; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
61 /* Test modff(-Inf,...). |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
62 This test fails on IRIX 6.5, OSF/1 5.1, mingw. */ |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
63 f = my_modff (minus_one / zero, &i); |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
64 if (!(f == 0.0f) || (signbitf (minus_zerof) && !signbitf (f))) |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
65 result |= 2; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
66 return result; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
67 } |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
68 ]])], |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
69 [gl_cv_func_modff_ieee=yes], |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
70 [gl_cv_func_modff_ieee=no], |
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16580
diff
changeset
|
71 [case "$host_os" in |
19479
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
72 # Guess yes on glibc systems. |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
73 *-gnu* | gnu*) gl_cv_func_modff_ieee="guessing yes" ;; |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
74 # 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
|
75 mingw*) AC_EGREP_CPP([Known], [ |
18993
a75cfc731331
Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
76 #ifdef _MSC_VER |
a75cfc731331
Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
77 Known |
a75cfc731331
Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
78 #endif |
19479
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
79 ], |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
80 [gl_cv_func_modff_ieee="guessing yes"], |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
81 [gl_cv_func_modff_ieee="guessing no"]) |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
82 ;; |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
83 # 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
|
84 *) gl_cv_func_modff_ieee="guessing no" ;; |
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16580
diff
changeset
|
85 esac |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16580
diff
changeset
|
86 ]) |
16468
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
87 LIBS="$save_LIBS" |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
88 ]) |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
89 case "$gl_cv_func_modff_ieee" in |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
90 *yes) ;; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
91 *) REPLACE_MODFF=1 ;; |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
92 esac |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
93 fi |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
94 ]) |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
95 else |
15838 | 96 HAVE_MODFF=0 |
16468
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
97 fi |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
98 if test $HAVE_MODFF = 0 || test $REPLACE_MODFF = 1; then |
5ad3cc13d9c3
modff-ieee: Work around test failures on *BSD, IRIX, OSF/1, etc.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
99 dnl Find libraries needed to link lib/modff.c. |
15838 | 100 MODFF_LIBM="$MODF_LIBM" |
101 fi | |
102 AC_SUBST([MODFF_LIBM]) | |
103 ]) |