Mercurial > gnulib
annotate m4/remainder.m4 @ 39194:a84ae461a2f6
Add cross-compilation results for GNU/Hurd.
* m4/calloc.m4: Add GNU/Hurd guess.
* m4/cbrtl.m4: Likewise.
* m4/ceil.m4: Likewise.
* m4/ceilf.m4: Likewise.
* m4/ceill.m4: Likewise.
* m4/chown.m4: Likewise.
* m4/duplocale.m4: Likewise.
* m4/exp2l.m4: Likewise.
* m4/expm1.m4: Likewise.
* m4/fchdir.m4: Likewise.
* m4/floor.m4: Likewise.
* m4/floorf.m4: Likewise.
* m4/fmod.m4: Likewise.
* m4/fmodf.m4: Likewise.
* m4/fmodl.m4: Likewise.
* m4/getcwd.m4: Likewise.
* m4/getgroups.m4: Likewise.
* m4/gettimeofday.m4: Likewise.
* m4/hypot.m4: Likewise.
* m4/hypotf.m4: Likewise.
* m4/hypotl.m4: Likewise.
* m4/link-follow.m4: Likewise.
* m4/link.m4: Likewise.
* m4/linkat.m4: Likewise.
* m4/log.m4: Likewise.
* m4/log10.m4: Likewise.
* m4/log10f.m4: Likewise.
* m4/log1p.m4: Likewise.
* m4/log1pf.m4: Likewise.
* m4/log1pl.m4: Likewise.
* m4/log2.m4: Likewise.
* m4/log2f.m4: Likewise.
* m4/logf.m4: Likewise.
* m4/lstat.m4: Likewise.
* m4/malloc.m4: Likewise.
* m4/mbrlen.m4: Likewise.
* m4/mbrtowc.m4: Likewise.
* m4/mkdir.m4: Likewise.
* m4/mkfifo.m4: Likewise.
* m4/mknod.m4: Likewise.
* m4/mkstemp.m4: Likewise.
* m4/modf.m4: Likewise.
* m4/modff.m4: Likewise.
* m4/modfl.m4: Likewise.
* m4/printf.m4: Likewise.
* m4/pselect.m4: Likewise.
* m4/ptsname.m4: Likewise.
* m4/putenv.m4: Likewise.
* m4/readlink.m4: Likewise.
* m4/realloc.m4: Likewise.
* m4/remainder.m4: Likewise.
* m4/remainderf.m4: Likewise.
* m4/remainderl.m4: Likewise.
* m4/rmdir.m4: Likewise.
* m4/round.m4: Likewise.
* m4/roundf.m4: Likewise.
* m4/roundl.m4: Likewise.
* m4/select.m4: Likewise.
* m4/setenv.m4: Likewise.
* m4/signbit.m4: Likewise.
* m4/sleep.m4: Likewise.
* m4/stat.m4: Likewise.
* m4/strerror.m4: Likewise.
* m4/strtok_r.m4: Likewise.
* m4/symlink.m4: Likewise.
* m4/symlinkat.m4: Likewise.
* m4/trunc.m4: Likewise.
* m4/truncf.m4: Likewise.
* m4/truncl.m4: Likewise.
* m4/tzset.m4: Likewise.
* m4/ungetc.m4: Likewise.
* m4/usleep.m4: Likewise.
* m4/wcwidth.m4: Likewise.
author | Samuel Thibault <samuel.thibault@gnu.org> |
---|---|
date | Fri, 29 Dec 2017 17:30:07 +0100 |
parents | 5c951c71f25c |
children | 10eb9086bea0 |
rev | line source |
---|---|
39194
a84ae461a2f6
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
38672
diff
changeset
|
1 # remainder.m4 serial 6 |
38305 | 2 dnl Copyright (C) 2012-2017 Free Software Foundation, Inc. |
36103 | 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_REMAINDER], | |
8 [ | |
36188
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
9 m4_divert_text([DEFAULTS], [gl_remainder_required=plain]) |
36103 | 10 AC_REQUIRE([gl_MATH_H_DEFAULTS]) |
11 | |
12 dnl Test whether remainder() is declared. On IRIX 5.3 it is not declared. | |
13 AC_CHECK_DECL([remainder], , [HAVE_DECL_REMAINDER=0], [[#include <math.h>]]) | |
14 | |
15 REMAINDER_LIBM= | |
16 AC_CACHE_CHECK([whether remainder() can be used without linking with libm], | |
17 [gl_cv_func_remainder_no_libm], | |
18 [ | |
19 AC_LINK_IFELSE( | |
20 [AC_LANG_PROGRAM( | |
21 [[#ifndef __NO_MATH_INLINES | |
22 # define __NO_MATH_INLINES 1 /* for glibc */ | |
23 #endif | |
24 #include <math.h> | |
25 double x; | |
26 double y;]], | |
27 [[return remainder (x, y) > 1;]])], | |
28 [gl_cv_func_remainder_no_libm=yes], | |
29 [gl_cv_func_remainder_no_libm=no]) | |
30 ]) | |
31 if test $gl_cv_func_remainder_no_libm = no; then | |
32 AC_CACHE_CHECK([whether remainder() can be used with libm], | |
33 [gl_cv_func_remainder_in_libm], | |
34 [ | |
35 save_LIBS="$LIBS" | |
36 LIBS="$LIBS -lm" | |
37 AC_LINK_IFELSE( | |
38 [AC_LANG_PROGRAM( | |
39 [[#ifndef __NO_MATH_INLINES | |
40 # define __NO_MATH_INLINES 1 /* for glibc */ | |
41 #endif | |
42 #include <math.h> | |
43 double x; | |
44 double y;]], | |
45 [[return remainder (x, y) > 1;]])], | |
46 [gl_cv_func_remainder_in_libm=yes], | |
47 [gl_cv_func_remainder_in_libm=no]) | |
48 LIBS="$save_LIBS" | |
49 ]) | |
50 if test $gl_cv_func_remainder_in_libm = yes; then | |
51 REMAINDER_LIBM=-lm | |
52 fi | |
53 fi | |
36188
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
54 if test $gl_cv_func_remainder_no_libm = yes \ |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
55 || test $gl_cv_func_remainder_in_libm = yes; then |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
56 : |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
57 m4_ifdef([gl_FUNC_REMAINDER_IEEE], [ |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
58 if test $gl_remainder_required = ieee && test $REPLACE_REMAINDER = 0; then |
36502
36d151b6b180
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
36259
diff
changeset
|
59 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
36188
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
60 AC_CACHE_CHECK([whether remainder works according to ISO C 99 with IEC 60559], |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
61 [gl_cv_func_remainder_ieee], |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
62 [ |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
63 save_LIBS="$LIBS" |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
64 LIBS="$LIBS $REMAINDER_LIBM" |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
65 AC_RUN_IFELSE( |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
66 [AC_LANG_SOURCE([[ |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
67 #ifndef __NO_MATH_INLINES |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
68 # define __NO_MATH_INLINES 1 /* for glibc */ |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
69 #endif |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
70 #include <math.h> |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
71 /* Compare two numbers with ==. |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
72 This is a separate function because IRIX 6.5 "cc -O" miscompiles an |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
73 'x == x' test. */ |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
74 static int |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
75 numeric_equal (double x, double y) |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
76 { |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
77 return x == y; |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
78 } |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
79 static double dummy (double x, double y) { return 0; } |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
80 int main (int argc, char *argv[]) |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
81 { |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
82 double (*my_remainder) (double, double) = argc ? remainder : dummy; |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
83 double f; |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
84 /* Test remainder(...,0.0). |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
85 This test fails on OSF/1 5.1. */ |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
86 f = my_remainder (2.0, 0.0); |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
87 if (numeric_equal (f, f)) |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
88 return 1; |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
89 return 0; |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
90 } |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
91 ]])], |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
92 [gl_cv_func_remainder_ieee=yes], |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
93 [gl_cv_func_remainder_ieee=no], |
36502
36d151b6b180
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
36259
diff
changeset
|
94 [case "$host_os" in |
39194
a84ae461a2f6
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
38672
diff
changeset
|
95 # Guess yes on glibc systems. |
a84ae461a2f6
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
38672
diff
changeset
|
96 *-gnu* | gnu*) gl_cv_func_remainder_ieee="guessing yes" ;; |
a84ae461a2f6
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
38672
diff
changeset
|
97 # Guess yes on native Windows. |
a84ae461a2f6
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
38672
diff
changeset
|
98 mingw*) gl_cv_func_remainder_ieee="guessing yes" ;; |
a84ae461a2f6
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
38672
diff
changeset
|
99 # If we don't know, assume the worst. |
a84ae461a2f6
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
38672
diff
changeset
|
100 *) gl_cv_func_remainder_ieee="guessing no" ;; |
36502
36d151b6b180
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
36259
diff
changeset
|
101 esac |
36d151b6b180
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
36259
diff
changeset
|
102 ]) |
36188
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
103 LIBS="$save_LIBS" |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
104 ]) |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
105 case "$gl_cv_func_remainder_ieee" in |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
106 *yes) ;; |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
107 *) REPLACE_REMAINDER=1 ;; |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
108 esac |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
109 fi |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
110 ]) |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
111 else |
36103 | 112 HAVE_REMAINDER=0 |
36188
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
113 fi |
f1355fba4bcf
remainder-ieee: Work around test failure on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
36103
diff
changeset
|
114 if test $HAVE_REMAINDER = 0 || test $REPLACE_REMAINDER = 1; then |
36103 | 115 dnl Find libraries needed to link lib/remainder.c. |
36259
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
116 AC_REQUIRE([gl_FUNC_FABS]) |
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
117 AC_REQUIRE([gl_FUNC_FMOD]) |
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
118 AC_REQUIRE([gl_FUNC_ISNAND]) |
36103 | 119 REMAINDER_LIBM= |
36259
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
120 dnl Append $FABS_LIBM to REMAINDER_LIBM, avoiding gratuitous duplicates. |
36103 | 121 case " $REMAINDER_LIBM " in |
36259
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
122 *" $FABS_LIBM "*) ;; |
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
123 *) REMAINDER_LIBM="$REMAINDER_LIBM $FABS_LIBM" ;; |
36103 | 124 esac |
36259
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
125 dnl Append $FMOD_LIBM to REMAINDER_LIBM, avoiding gratuitous duplicates. |
36103 | 126 case " $REMAINDER_LIBM " in |
36259
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
127 *" $FMOD_LIBM "*) ;; |
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
128 *) REMAINDER_LIBM="$REMAINDER_LIBM $FMOD_LIBM" ;; |
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
129 esac |
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
130 dnl Append $ISNAND_LIBM to REMAINDER_LIBM, avoiding gratuitous duplicates. |
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
131 case " $REMAINDER_LIBM " in |
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
132 *" $ISNAND_LIBM "*) ;; |
5d42cf3681cf
remainder, remainderf, remainderl: Fix computation for large quotients.
Bruno Haible <bruno@clisp.org>
parents:
36214
diff
changeset
|
133 *) REMAINDER_LIBM="$REMAINDER_LIBM $ISNAND_LIBM" ;; |
36103 | 134 esac |
135 fi | |
136 AC_SUBST([REMAINDER_LIBM]) | |
137 ]) |