Mercurial > hg > octave-kai > gnulib-hg
annotate m4/frexp.m4 @ 15857:6b8400199763
New module 'sqrtf'.
* lib/math.in.h (sqrtf): New declaration.
* lib/sqrtf.c: New file.
* m4/sqrtf.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether sqrtf is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_SQRTF, HAVE_SQRTF.
* modules/math (Makefile.am): Substitute GNULIB_SQRTF, HAVE_SQRTF.
* modules/sqrtf: New file.
* tests/test-math-c++.cc: Check the declaration of sqrtf.
* doc/posix-functions/sqrtf.texi: Mention the new module.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 08 Oct 2011 21:16:48 +0200 |
parents | 328819af1c02 |
children | 916745fe55a6 |
rev | line source |
---|---|
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15356
diff
changeset
|
1 # frexp.m4 serial 12 |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
13918
diff
changeset
|
2 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. |
8491 | 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_FREXP], | |
8 [ | |
9 AC_REQUIRE([gl_MATH_H_DEFAULTS]) | |
13460
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
10 AC_REQUIRE([gl_CHECK_FREXP_NO_LIBM]) |
8491 | 11 FREXP_LIBM= |
12 if test $gl_cv_func_frexp_no_libm = no; then | |
13 AC_CACHE_CHECK([whether frexp() can be used with libm], | |
14 [gl_cv_func_frexp_in_libm], | |
15 [ | |
16 save_LIBS="$LIBS" | |
17 LIBS="$LIBS -lm" | |
13578
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13460
diff
changeset
|
18 AC_LINK_IFELSE( |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13460
diff
changeset
|
19 [AC_LANG_PROGRAM( |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13460
diff
changeset
|
20 [[#include <math.h> |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13460
diff
changeset
|
21 double x;]], |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13460
diff
changeset
|
22 [[int e; return frexp (x, &e) > 0;]])], |
8491 | 23 [gl_cv_func_frexp_in_libm=yes], |
24 [gl_cv_func_frexp_in_libm=no]) | |
25 LIBS="$save_LIBS" | |
26 ]) | |
27 if test $gl_cv_func_frexp_in_libm = yes; then | |
28 FREXP_LIBM=-lm | |
29 fi | |
30 fi | |
31 if test $gl_cv_func_frexp_no_libm = yes \ | |
32 || test $gl_cv_func_frexp_in_libm = yes; then | |
33 save_LIBS="$LIBS" | |
34 LIBS="$LIBS $FREXP_LIBM" | |
35 gl_FUNC_FREXP_WORKS | |
36 LIBS="$save_LIBS" | |
37 case "$gl_cv_func_frexp_works" in | |
38 *yes) gl_func_frexp=yes ;; | |
39 *) gl_func_frexp=no; REPLACE_FREXP=1; FREXP_LIBM= ;; | |
40 esac | |
41 else | |
42 gl_func_frexp=no | |
43 fi | |
44 if test $gl_func_frexp = yes; then | |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
10418
diff
changeset
|
45 AC_DEFINE([HAVE_FREXP], [1], |
8491 | 46 [Define if the frexp() function is available and works.]) |
47 fi | |
8627
fd0df3b4a14d
Clarify the dependencies on libm.
Bruno Haible <bruno@clisp.org>
parents:
8546
diff
changeset
|
48 AC_SUBST([FREXP_LIBM]) |
8491 | 49 ]) |
50 | |
9440 | 51 AC_DEFUN([gl_FUNC_FREXP_NO_LIBM], |
52 [ | |
53 AC_REQUIRE([gl_MATH_H_DEFAULTS]) | |
13460
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
54 AC_REQUIRE([gl_CHECK_FREXP_NO_LIBM]) |
9440 | 55 if test $gl_cv_func_frexp_no_libm = yes; then |
56 gl_FUNC_FREXP_WORKS | |
57 case "$gl_cv_func_frexp_works" in | |
58 *yes) gl_func_frexp_no_libm=yes ;; | |
59 *) gl_func_frexp_no_libm=no; REPLACE_FREXP=1 ;; | |
60 esac | |
61 else | |
62 gl_func_frexp_no_libm=no | |
63 dnl Set REPLACE_FREXP here because the system may have frexp in libm. | |
64 REPLACE_FREXP=1 | |
65 fi | |
66 if test $gl_func_frexp_no_libm = yes; then | |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
10418
diff
changeset
|
67 AC_DEFINE([HAVE_FREXP_IN_LIBC], [1], |
9440 | 68 [Define if the frexp() function is available in libc.]) |
69 fi | |
70 ]) | |
71 | |
13460
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
72 dnl Test whether frexp() can be used without linking with libm. |
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
73 dnl Set gl_cv_func_frexp_no_libm to 'yes' or 'no' accordingly. |
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
74 AC_DEFUN([gl_CHECK_FREXP_NO_LIBM], |
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
75 [ |
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
76 AC_CACHE_CHECK([whether frexp() can be used without linking with libm], |
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
77 [gl_cv_func_frexp_no_libm], |
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
78 [ |
13578
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13460
diff
changeset
|
79 AC_LINK_IFELSE( |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13460
diff
changeset
|
80 [AC_LANG_PROGRAM( |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13460
diff
changeset
|
81 [[#include <math.h> |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13460
diff
changeset
|
82 double x;]], |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13460
diff
changeset
|
83 [[int e; return frexp (x, &e) > 0;]])], |
13460
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
84 [gl_cv_func_frexp_no_libm=yes], |
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
85 [gl_cv_func_frexp_no_libm=no]) |
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
86 ]) |
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
87 ]) |
54037f4be4a4
Unify tests that set gl_cv_func_frexp_no_libm.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
88 |
8546
d03503ff8d69
Check against a bug of frexp() on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8493
diff
changeset
|
89 dnl Test whether frexp() works also on denormalized numbers (this fails e.g. on |
10418
1e251b3d489c
frexp: test for NetBSD failure on -0.0
Eric Blake <ebb9@byu.net>
parents:
9508
diff
changeset
|
90 dnl NetBSD 3.0), on infinite numbers (this fails e.g. on IRIX 6.5 and mingw), |
15356 | 91 dnl and on negative zero (this fails e.g. on NetBSD 4.99 and mingw). |
8491 | 92 AC_DEFUN([gl_FUNC_FREXP_WORKS], |
93 [ | |
94 AC_REQUIRE([AC_PROG_CC]) | |
95 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | |
96 AC_CACHE_CHECK([whether frexp works], [gl_cv_func_frexp_works], | |
97 [ | |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13578
diff
changeset
|
98 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13578
diff
changeset
|
99 [AC_LANG_SOURCE([[ |
8491 | 100 #include <float.h> |
101 #include <math.h> | |
10418
1e251b3d489c
frexp: test for NetBSD failure on -0.0
Eric Blake <ebb9@byu.net>
parents:
9508
diff
changeset
|
102 #include <string.h> |
13834
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
103 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
104 ICC 10.0 has a bug when optimizing the expression -zero. |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
105 The expression -DBL_MIN * DBL_MIN does not work when cross-compiling |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
106 to PowerPC on MacOS X 10.5. */ |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
107 #if defined __hpux || defined __sgi || defined __ICC |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
108 static double |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
109 compute_minus_zero (void) |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
110 { |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
111 return -DBL_MIN * DBL_MIN; |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
112 } |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
113 # define minus_zero compute_minus_zero () |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
114 #else |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
115 double minus_zero = -0.0; |
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
116 #endif |
8491 | 117 int main() |
118 { | |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13834
diff
changeset
|
119 int result = 0; |
8491 | 120 int i; |
121 volatile double x; | |
10418
1e251b3d489c
frexp: test for NetBSD failure on -0.0
Eric Blake <ebb9@byu.net>
parents:
9508
diff
changeset
|
122 double zero = 0.0; |
8546
d03503ff8d69
Check against a bug of frexp() on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8493
diff
changeset
|
123 /* Test on denormalized numbers. */ |
8491 | 124 for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5) |
125 ; | |
126 if (x > 0.0) | |
127 { | |
128 int exp; | |
129 double y = frexp (x, &exp); | |
130 /* On machines with IEEE754 arithmetic: x = 1.11254e-308, exp = -1022. | |
131 On NetBSD: y = 0.75. Correct: y = 0.5. */ | |
132 if (y != 0.5) | |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13834
diff
changeset
|
133 result |= 1; |
8491 | 134 } |
8546
d03503ff8d69
Check against a bug of frexp() on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8493
diff
changeset
|
135 /* Test on infinite numbers. */ |
15595
328819af1c02
Support for MSVC compiler: Avoid division by a literal 0.
Bruno Haible <bruno@clisp.org>
parents:
15356
diff
changeset
|
136 x = 1.0 / zero; |
8546
d03503ff8d69
Check against a bug of frexp() on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8493
diff
changeset
|
137 { |
d03503ff8d69
Check against a bug of frexp() on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8493
diff
changeset
|
138 int exp; |
d03503ff8d69
Check against a bug of frexp() on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8493
diff
changeset
|
139 double y = frexp (x, &exp); |
d03503ff8d69
Check against a bug of frexp() on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8493
diff
changeset
|
140 if (y != x) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13834
diff
changeset
|
141 result |= 2; |
8546
d03503ff8d69
Check against a bug of frexp() on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents:
8493
diff
changeset
|
142 } |
10418
1e251b3d489c
frexp: test for NetBSD failure on -0.0
Eric Blake <ebb9@byu.net>
parents:
9508
diff
changeset
|
143 /* Test on negative zero. */ |
13834
108bbfd6f03b
frexp, tests: work around ICC bug with -zero
Eric Blake <eblake@redhat.com>
parents:
13579
diff
changeset
|
144 x = minus_zero; |
10418
1e251b3d489c
frexp: test for NetBSD failure on -0.0
Eric Blake <ebb9@byu.net>
parents:
9508
diff
changeset
|
145 { |
1e251b3d489c
frexp: test for NetBSD failure on -0.0
Eric Blake <ebb9@byu.net>
parents:
9508
diff
changeset
|
146 int exp; |
1e251b3d489c
frexp: test for NetBSD failure on -0.0
Eric Blake <ebb9@byu.net>
parents:
9508
diff
changeset
|
147 double y = frexp (x, &exp); |
1e251b3d489c
frexp: test for NetBSD failure on -0.0
Eric Blake <ebb9@byu.net>
parents:
9508
diff
changeset
|
148 if (memcmp (&y, &x, sizeof x)) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13834
diff
changeset
|
149 result |= 4; |
10418
1e251b3d489c
frexp: test for NetBSD failure on -0.0
Eric Blake <ebb9@byu.net>
parents:
9508
diff
changeset
|
150 } |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13834
diff
changeset
|
151 return result; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13578
diff
changeset
|
152 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13578
diff
changeset
|
153 [gl_cv_func_frexp_works=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13578
diff
changeset
|
154 [gl_cv_func_frexp_works=no], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13578
diff
changeset
|
155 [case "$host_os" in |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13578
diff
changeset
|
156 netbsd* | irix* | mingw*) gl_cv_func_frexp_works="guessing no";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13578
diff
changeset
|
157 *) gl_cv_func_frexp_works="guessing yes";; |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13578
diff
changeset
|
158 esac |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13578
diff
changeset
|
159 ]) |
8491 | 160 ]) |
161 ]) |