Mercurial > hg > octave-shane > gnulib-hg
annotate m4/frexpf.m4 @ 16201:8250f2777afc
maint: update all copyright year number ranges
Run "make update-copyright".
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Sun, 01 Jan 2012 10:04:58 +0100 |
parents | 622d3734ca5a |
children | fdbe3125f81a |
rev | line source |
---|---|
15845
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
1 # frexpf.m4 serial 3 |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
15845
diff
changeset
|
2 dnl Copyright (C) 2011-2012 Free Software Foundation, Inc. |
15841 | 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_FREXPF], | |
8 [ | |
9 AC_REQUIRE([gl_MATH_H_DEFAULTS]) | |
10 AC_REQUIRE([gl_FUNC_FREXP]) | |
11 | |
15843
bc22a56bfa43
frexpf: Drop assumption about library that defines frexpf.
Bruno Haible <bruno@clisp.org>
parents:
15841
diff
changeset
|
12 dnl Test whether frexpf() exists. We cannot assume that frexpf(), if it |
bc22a56bfa43
frexpf: Drop assumption about library that defines frexpf.
Bruno Haible <bruno@clisp.org>
parents:
15841
diff
changeset
|
13 dnl exists, is defined in the same library as frexp(). This is not the case |
bc22a56bfa43
frexpf: Drop assumption about library that defines frexpf.
Bruno Haible <bruno@clisp.org>
parents:
15841
diff
changeset
|
14 dnl on NetBSD, OpenBSD. |
bc22a56bfa43
frexpf: Drop assumption about library that defines frexpf.
Bruno Haible <bruno@clisp.org>
parents:
15841
diff
changeset
|
15 gl_MATHFUNC([frexpf], [float], [(float, int *)]) |
15845
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
16 if test $gl_cv_func_frexpf_no_libm = yes \ |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
17 || test $gl_cv_func_frexpf_in_libm = yes; then |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
18 save_LIBS="$LIBS" |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
19 LIBS="$LIBS $FREXPF_LIBM" |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
20 gl_FUNC_FREXPF_WORKS |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
21 LIBS="$save_LIBS" |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
22 case "$gl_cv_func_frexpf_works" in |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
23 *yes) ;; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
24 *) REPLACE_FREXPF=1 ;; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
25 esac |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
26 else |
15841 | 27 HAVE_FREXPF=0 |
15845
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
28 fi |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
29 if test $HAVE_FREXPF = 0 || test $REPLACE_FREXPF = 1; then |
15841 | 30 FREXPF_LIBM="$FREXP_LIBM" |
31 fi | |
32 AC_SUBST([FREXPF_LIBM]) | |
33 ]) | |
15845
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
34 |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
35 dnl Test whether frexpf() works also on infinite numbers (this fails e.g. on |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
36 dnl IRIX 6.5 and mingw) and on negative zero (this fails e.g. on mingw). |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
37 AC_DEFUN([gl_FUNC_FREXPF_WORKS], |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
38 [ |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
39 AC_REQUIRE([AC_PROG_CC]) |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
40 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
41 AC_CACHE_CHECK([whether frexpf works], [gl_cv_func_frexpf_works], |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
42 [ |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
43 AC_RUN_IFELSE( |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
44 [AC_LANG_SOURCE([[ |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
45 #include <float.h> |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
46 #include <math.h> |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
47 #include <string.h> |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
48 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
49 ICC 10.0 has a bug when optimizing the expression -zero. |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
50 The expression -FLT_MIN * FLT_MIN does not work when cross-compiling |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
51 to PowerPC on MacOS X 10.5. */ |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
52 #if defined __hpux || defined __sgi || defined __ICC |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
53 static float |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
54 compute_minus_zero (void) |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
55 { |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
56 return -FLT_MIN * FLT_MIN; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
57 } |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
58 # define minus_zero compute_minus_zero () |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
59 #else |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
60 float minus_zero = -0.0f; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
61 #endif |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
62 int main() |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
63 { |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
64 int result = 0; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
65 volatile float x; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
66 float zero = 0.0f; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
67 /* Test on infinite numbers. */ |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
68 x = 1.0f / zero; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
69 { |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
70 int exp; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
71 float y = frexpf (x, &exp); |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
72 if (y != x) |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
73 result |= 1; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
74 } |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
75 /* Test on negative zero. */ |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
76 x = minus_zero; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
77 { |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
78 int exp; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
79 float y = frexpf (x, &exp); |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
80 if (memcmp (&y, &x, sizeof x)) |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
81 result |= 2; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
82 } |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
83 return result; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
84 }]])], |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
85 [gl_cv_func_frexpf_works=yes], |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
86 [gl_cv_func_frexpf_works=no], |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
87 [case "$host_os" in |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
88 irix* | mingw*) gl_cv_func_frexpf_works="guessing no";; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
89 *) gl_cv_func_frexpf_works="guessing yes";; |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
90 esac |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
91 ]) |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
92 ]) |
622d3734ca5a
frexpf: Work around problems on IRIX and mingw.
Bruno Haible <bruno@clisp.org>
parents:
15843
diff
changeset
|
93 ]) |