annotate m4/frexpl.m4 @ 12762:410eaa89fb57

Avoid a link error due to the __printf__ symbol.
author Bruno Haible <bruno@clisp.org>
date Tue, 19 Jan 2010 03:15:05 +0100
parents c2cbabec01dd
children 399957a9c412
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11007
f6cba5a556ce many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents: 9655
diff changeset
1 # frexpl.m4 serial 9
12559
c2cbabec01dd update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents: 11007
diff changeset
2 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
8497
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_FREXPL],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 FREXPL_LIBM=
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 AC_CACHE_CHECK([whether frexpl() can be used without linking with libm],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 [gl_cv_func_frexpl_no_libm],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 [
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 AC_TRY_LINK([#include <math.h>
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 long double x;],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 [int e; return frexpl (x, &e) > 0;],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 [gl_cv_func_frexpl_no_libm=yes],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 [gl_cv_func_frexpl_no_libm=no])
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 ])
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 if test $gl_cv_func_frexpl_no_libm = no; then
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 AC_CACHE_CHECK([whether frexpl() can be used with libm],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 [gl_cv_func_frexpl_in_libm],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 [
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 save_LIBS="$LIBS"
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 LIBS="$LIBS -lm"
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 AC_TRY_LINK([#include <math.h>
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 long double x;],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 [int e; return frexpl (x, &e) > 0;],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 [gl_cv_func_frexpl_in_libm=yes],
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 [gl_cv_func_frexpl_in_libm=no])
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 LIBS="$save_LIBS"
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 ])
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 if test $gl_cv_func_frexpl_in_libm = yes; then
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 FREXPL_LIBM=-lm
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 fi
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 fi
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 if test $gl_cv_func_frexpl_no_libm = yes \
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 || test $gl_cv_func_frexpl_in_libm = yes; then
8547
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
39 save_LIBS="$LIBS"
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
40 LIBS="$LIBS $FREXPL_LIBM"
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
41 gl_FUNC_FREXPL_WORKS
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
42 LIBS="$save_LIBS"
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
43 case "$gl_cv_func_frexpl_works" in
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
44 *yes) gl_func_frexpl=yes ;;
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
45 *) gl_func_frexpl=no; REPLACE_FREXPL=1; FREXPL_LIBM= ;;
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
46 esac
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
47 else
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
48 gl_func_frexpl=no
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
49 fi
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
50 if test $gl_func_frexpl = yes; then
11007
f6cba5a556ce many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents: 9655
diff changeset
51 AC_DEFINE([HAVE_FREXPL], [1],
8497
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 [Define if the frexpl() function is available.])
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 dnl Also check whether it's declared.
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 dnl MacOS X 10.3 has frexpl() in libc but doesn't declare it in <math.h>.
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include <math.h>])
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 else
8601
a5c2fa01c945 Declare frexpl() when the system doesn't have it.
Bruno Haible <bruno@clisp.org>
parents: 8587
diff changeset
57 HAVE_DECL_FREXPL=0
8497
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 AC_LIBOBJ([frexpl])
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 fi
8627
fd0df3b4a14d Clarify the dependencies on libm.
Bruno Haible <bruno@clisp.org>
parents: 8601
diff changeset
60 AC_SUBST([FREXPL_LIBM])
8497
280cabcbb0ca New module 'frexpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 ])
8547
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
62
8827
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
63 AC_DEFUN([gl_FUNC_FREXPL_NO_LIBM],
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
64 [
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
65 AC_REQUIRE([gl_MATH_H_DEFAULTS])
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
66 AC_CACHE_CHECK([whether frexpl() can be used without linking with libm],
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
67 [gl_cv_func_frexpl_no_libm],
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
68 [
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
69 AC_TRY_LINK([#include <math.h>
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
70 long double x;],
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
71 [int e; return frexpl (x, &e) > 0;],
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
72 [gl_cv_func_frexpl_no_libm=yes],
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
73 [gl_cv_func_frexpl_no_libm=no])
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
74 ])
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
75 if test $gl_cv_func_frexpl_no_libm = yes; then
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
76 gl_FUNC_FREXPL_WORKS
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
77 case "$gl_cv_func_frexpl_works" in
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
78 *yes) gl_func_frexpl_no_libm=yes ;;
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
79 *) gl_func_frexpl_no_libm=no; REPLACE_FREXPL=1 ;;
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
80 esac
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
81 else
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
82 gl_func_frexpl_no_libm=no
8858
6ddd04703670 Avoid possible collision between gnulib frexpl and libm frexpl.
Bruno Haible <bruno@clisp.org>
parents: 8845
diff changeset
83 dnl Set REPLACE_FREXPL here because the system may have frexpl in libm.
6ddd04703670 Avoid possible collision between gnulib frexpl and libm frexpl.
Bruno Haible <bruno@clisp.org>
parents: 8845
diff changeset
84 REPLACE_FREXPL=1
8827
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
85 fi
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
86 if test $gl_func_frexpl_no_libm = yes; then
11007
f6cba5a556ce many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents: 9655
diff changeset
87 AC_DEFINE([HAVE_FREXPL_IN_LIBC], [1],
8827
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
88 [Define if the frexpl() function is available in libc.])
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
89 dnl Also check whether it's declared.
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
90 dnl MacOS X 10.3 has frexpl() in libc but doesn't declare it in <math.h>.
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
91 AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include <math.h>])
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
92 else
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
93 HAVE_DECL_FREXPL=0
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
94 AC_LIBOBJ([frexpl])
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
95 fi
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
96 ])
ef4a736e6bcc New module 'frexpl-nolibm'.
Bruno Haible <bruno@clisp.org>
parents: 8627
diff changeset
97
8983
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
98 dnl Test whether frexpl() works on finite numbers (this fails on
9625
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
99 dnl MacOS X 10.4/PowerPC, on AIX 5.1, and on BeOS), on denormalized numbers
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
100 dnl (this fails on MacOS X 10.5/i386), and also on infinite numbers (this
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
101 dnl fails e.g. on IRIX 6.5 and mingw).
8547
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
102 AC_DEFUN([gl_FUNC_FREXPL_WORKS],
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
103 [
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
104 AC_REQUIRE([AC_PROG_CC])
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
105 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
106 AC_CACHE_CHECK([whether frexpl works], [gl_cv_func_frexpl_works],
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
107 [
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
108 AC_TRY_RUN([
9655
54a6235c2b47 Fix autoconf test bug introduced on 2008-01-15.
Andreas Schwab <schwab@suse.de>
parents: 9625
diff changeset
109 #include <float.h>
8547
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
110 #include <math.h>
9655
54a6235c2b47 Fix autoconf test bug introduced on 2008-01-15.
Andreas Schwab <schwab@suse.de>
parents: 9625
diff changeset
111 /* Override the values of <float.h>, like done in float.in.h. */
54a6235c2b47 Fix autoconf test bug introduced on 2008-01-15.
Andreas Schwab <schwab@suse.de>
parents: 9625
diff changeset
112 #if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
54a6235c2b47 Fix autoconf test bug introduced on 2008-01-15.
Andreas Schwab <schwab@suse.de>
parents: 9625
diff changeset
113 # undef LDBL_MIN_EXP
54a6235c2b47 Fix autoconf test bug introduced on 2008-01-15.
Andreas Schwab <schwab@suse.de>
parents: 9625
diff changeset
114 # define LDBL_MIN_EXP (-16381)
54a6235c2b47 Fix autoconf test bug introduced on 2008-01-15.
Andreas Schwab <schwab@suse.de>
parents: 9625
diff changeset
115 #endif
8587
688b0729c8c0 Declare frexpl() in the test.
Bruno Haible <bruno@clisp.org>
parents: 8549
diff changeset
116 extern long double frexpl (long double, int *);
8547
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
117 int main()
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
118 {
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
119 volatile long double x;
8983
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
120 /* Test on finite numbers that fails on AIX 5.1. */
8845
6edec1d2af09 Fix syntax error in test.
Bruno Haible <bruno@clisp.org>
parents: 8827
diff changeset
121 x = 16.0L;
8549
a1851d3b4da6 Avoid the completely broken frexpl() function of AIX 5.1.
Bruno Haible <bruno@clisp.org>
parents: 8547
diff changeset
122 {
a1851d3b4da6 Avoid the completely broken frexpl() function of AIX 5.1.
Bruno Haible <bruno@clisp.org>
parents: 8547
diff changeset
123 int exp = -9999;
a1851d3b4da6 Avoid the completely broken frexpl() function of AIX 5.1.
Bruno Haible <bruno@clisp.org>
parents: 8547
diff changeset
124 frexpl (x, &exp);
a1851d3b4da6 Avoid the completely broken frexpl() function of AIX 5.1.
Bruno Haible <bruno@clisp.org>
parents: 8547
diff changeset
125 if (exp != 5)
a1851d3b4da6 Avoid the completely broken frexpl() function of AIX 5.1.
Bruno Haible <bruno@clisp.org>
parents: 8547
diff changeset
126 return 1;
a1851d3b4da6 Avoid the completely broken frexpl() function of AIX 5.1.
Bruno Haible <bruno@clisp.org>
parents: 8547
diff changeset
127 }
8983
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
128 /* Test on finite numbers that fails on MacOS X 10.4, because its frexpl
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
129 function returns an invalid (incorrectly normalized) value: it returns
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
130 y = { 0x3fe028f5, 0xc28f5c28, 0x3c9eb851, 0xeb851eb8 }
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
131 but the correct result is
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
132 0.505L = { 0x3fe028f5, 0xc28f5c29, 0xbc547ae1, 0x47ae1480 } */
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
133 x = 1.01L;
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
134 {
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
135 int exp = -9999;
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
136 long double y = frexpl (x, &exp);
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
137 if (!(exp == 1 && y == 0.505L))
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
138 return 1;
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
139 }
8862
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
140 /* Test on large finite numbers. This fails on BeOS at i = 16322, while
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
141 LDBL_MAX_EXP = 16384.
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
142 In the loop end test, we test x against Infinity, rather than comparing
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
143 i with LDBL_MAX_EXP, because BeOS <float.h> has a wrong LDBL_MAX_EXP. */
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
144 {
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
145 int i;
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
146 for (i = 1, x = 1.0L; x != x + x; i++, x *= 2.0L)
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
147 {
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
148 int exp = -9999;
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
149 frexpl (x, &exp);
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
150 if (exp != i)
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
151 return 1;
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
152 }
5900f6987283 Detect broken frexpl on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8858
diff changeset
153 }
9625
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
154 /* Test on denormalized numbers. */
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
155 {
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
156 int i;
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
157 for (i = 1, x = 1.0L; i >= LDBL_MIN_EXP; i--, x *= 0.5L)
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
158 ;
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
159 if (x > 0.0L)
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
160 {
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
161 int exp;
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
162 long double y = frexpl (x, &exp);
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
163 /* On machines with IEEE854 arithmetic: x = 1.68105e-4932,
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
164 exp = -16382, y = 0.5. On MacOS X 10.5: exp = -16384, y = 0.5. */
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
165 if (exp != LDBL_MIN_EXP - 1)
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
166 return 1;
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
167 }
a64830157230 Work around a MacOS X 10.5 bug in frexpl().
Bruno Haible <bruno@clisp.org>
parents: 8983
diff changeset
168 }
8547
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
169 /* Test on infinite numbers. */
8845
6edec1d2af09 Fix syntax error in test.
Bruno Haible <bruno@clisp.org>
parents: 8827
diff changeset
170 x = 1.0L / 0.0L;
8547
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
171 {
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
172 int exp;
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
173 long double y = frexpl (x, &exp);
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
174 if (y != x)
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
175 return 1;
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
176 }
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
177 return 0;
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
178 }], [gl_cv_func_frexpl_works=yes], [gl_cv_func_frexpl_works=no],
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
179 [case "$host_os" in
8983
5c190f3b839a Work around a buggy frexpl function on MacOS X 10.4/PowerPC.
Bruno Haible <bruno@clisp.org>
parents: 8909
diff changeset
180 aix* | beos* | darwin* | irix* | mingw* | pw*)
8909
dcf6f4e1ef96 Update after Eric Blake found that frexpl doesn't work right on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8906
diff changeset
181 gl_cv_func_frexpl_works="guessing no";;
dcf6f4e1ef96 Update after Eric Blake found that frexpl doesn't work right on mingw.
Bruno Haible <bruno@clisp.org>
parents: 8906
diff changeset
182 *) gl_cv_func_frexpl_works="guessing yes";;
8547
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
183 esac
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
184 ])
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
185 ])
658be4e4521a Provide a replacement for frexpl() if the system has it but it doesn't work.
Bruno Haible <bruno@clisp.org>
parents: 8497
diff changeset
186 ])