~ubuntu-branches/ubuntu/vivid/gzip/vivid

« back to all changes in this revision

Viewing changes to m4/frexpl.m4

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-10-19 11:42:42 UTC
  • mfrom: (4.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20111019114242-d8wiiu8kbvdtgmgj
Tags: 1.4-1ubuntu1
* Merge with Debian testing.  Remaining Ubuntu changes:
  - debian/{control,rules}: Remove the Win32 build and mingw64
    build-dependency, since mingw is in universe, and will remain so for
    the forseeable future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# frexpl.m4 serial 9
 
2
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 
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_FREXPL],
 
8
[
 
9
  AC_REQUIRE([gl_MATH_H_DEFAULTS])
 
10
  FREXPL_LIBM=
 
11
  AC_CACHE_CHECK([whether frexpl() can be used without linking with libm],
 
12
    [gl_cv_func_frexpl_no_libm],
 
13
    [
 
14
      AC_TRY_LINK([#include <math.h>
 
15
                   long double x;],
 
16
                  [int e; return frexpl (x, &e) > 0;],
 
17
        [gl_cv_func_frexpl_no_libm=yes],
 
18
        [gl_cv_func_frexpl_no_libm=no])
 
19
    ])
 
20
  if test $gl_cv_func_frexpl_no_libm = no; then
 
21
    AC_CACHE_CHECK([whether frexpl() can be used with libm],
 
22
      [gl_cv_func_frexpl_in_libm],
 
23
      [
 
24
        save_LIBS="$LIBS"
 
25
        LIBS="$LIBS -lm"
 
26
        AC_TRY_LINK([#include <math.h>
 
27
                     long double x;],
 
28
                    [int e; return frexpl (x, &e) > 0;],
 
29
          [gl_cv_func_frexpl_in_libm=yes],
 
30
          [gl_cv_func_frexpl_in_libm=no])
 
31
        LIBS="$save_LIBS"
 
32
      ])
 
33
    if test $gl_cv_func_frexpl_in_libm = yes; then
 
34
      FREXPL_LIBM=-lm
 
35
    fi
 
36
  fi
 
37
  if test $gl_cv_func_frexpl_no_libm = yes \
 
38
     || test $gl_cv_func_frexpl_in_libm = yes; then
 
39
    save_LIBS="$LIBS"
 
40
    LIBS="$LIBS $FREXPL_LIBM"
 
41
    gl_FUNC_FREXPL_WORKS
 
42
    LIBS="$save_LIBS"
 
43
    case "$gl_cv_func_frexpl_works" in
 
44
      *yes) gl_func_frexpl=yes ;;
 
45
      *)    gl_func_frexpl=no; REPLACE_FREXPL=1; FREXPL_LIBM= ;;
 
46
    esac
 
47
  else
 
48
    gl_func_frexpl=no
 
49
  fi
 
50
  if test $gl_func_frexpl = yes; then
 
51
    AC_DEFINE([HAVE_FREXPL], [1],
 
52
      [Define if the frexpl() function is available.])
 
53
    dnl Also check whether it's declared.
 
54
    dnl MacOS X 10.3 has frexpl() in libc but doesn't declare it in <math.h>.
 
55
    AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include <math.h>])
 
56
  else
 
57
    HAVE_DECL_FREXPL=0
 
58
    AC_LIBOBJ([frexpl])
 
59
  fi
 
60
  AC_SUBST([FREXPL_LIBM])
 
61
])
 
62
 
 
63
AC_DEFUN([gl_FUNC_FREXPL_NO_LIBM],
 
64
[
 
65
  AC_REQUIRE([gl_MATH_H_DEFAULTS])
 
66
  AC_CACHE_CHECK([whether frexpl() can be used without linking with libm],
 
67
    [gl_cv_func_frexpl_no_libm],
 
68
    [
 
69
      AC_TRY_LINK([#include <math.h>
 
70
                   long double x;],
 
71
                  [int e; return frexpl (x, &e) > 0;],
 
72
        [gl_cv_func_frexpl_no_libm=yes],
 
73
        [gl_cv_func_frexpl_no_libm=no])
 
74
    ])
 
75
  if test $gl_cv_func_frexpl_no_libm = yes; then
 
76
    gl_FUNC_FREXPL_WORKS
 
77
    case "$gl_cv_func_frexpl_works" in
 
78
      *yes) gl_func_frexpl_no_libm=yes ;;
 
79
      *)    gl_func_frexpl_no_libm=no; REPLACE_FREXPL=1 ;;
 
80
    esac
 
81
  else
 
82
    gl_func_frexpl_no_libm=no
 
83
    dnl Set REPLACE_FREXPL here because the system may have frexpl in libm.
 
84
    REPLACE_FREXPL=1
 
85
  fi
 
86
  if test $gl_func_frexpl_no_libm = yes; then
 
87
    AC_DEFINE([HAVE_FREXPL_IN_LIBC], [1],
 
88
      [Define if the frexpl() function is available in libc.])
 
89
    dnl Also check whether it's declared.
 
90
    dnl MacOS X 10.3 has frexpl() in libc but doesn't declare it in <math.h>.
 
91
    AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include <math.h>])
 
92
  else
 
93
    HAVE_DECL_FREXPL=0
 
94
    AC_LIBOBJ([frexpl])
 
95
  fi
 
96
])
 
97
 
 
98
dnl Test whether frexpl() works on finite numbers (this fails on
 
99
dnl MacOS X 10.4/PowerPC, on AIX 5.1, and on BeOS), on denormalized numbers
 
100
dnl (this fails on MacOS X 10.5/i386), and also on infinite numbers (this
 
101
dnl fails e.g. on IRIX 6.5 and mingw).
 
102
AC_DEFUN([gl_FUNC_FREXPL_WORKS],
 
103
[
 
104
  AC_REQUIRE([AC_PROG_CC])
 
105
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
106
  AC_CACHE_CHECK([whether frexpl works], [gl_cv_func_frexpl_works],
 
107
    [
 
108
      AC_TRY_RUN([
 
109
#include <float.h>
 
110
#include <math.h>
 
111
/* Override the values of <float.h>, like done in float.in.h.  */
 
112
#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
 
113
# undef LDBL_MIN_EXP
 
114
# define LDBL_MIN_EXP    (-16381)
 
115
#endif
 
116
extern long double frexpl (long double, int *);
 
117
int main()
 
118
{
 
119
  volatile long double x;
 
120
  /* Test on finite numbers that fails on AIX 5.1.  */
 
121
  x = 16.0L;
 
122
  {
 
123
    int exp = -9999;
 
124
    frexpl (x, &exp);
 
125
    if (exp != 5)
 
126
      return 1;
 
127
  }
 
128
  /* Test on finite numbers that fails on MacOS X 10.4, because its frexpl
 
129
     function returns an invalid (incorrectly normalized) value: it returns
 
130
               y = { 0x3fe028f5, 0xc28f5c28, 0x3c9eb851, 0xeb851eb8 }
 
131
     but the correct result is
 
132
          0.505L = { 0x3fe028f5, 0xc28f5c29, 0xbc547ae1, 0x47ae1480 }  */
 
133
  x = 1.01L;
 
134
  {
 
135
    int exp = -9999;
 
136
    long double y = frexpl (x, &exp);
 
137
    if (!(exp == 1 && y == 0.505L))
 
138
      return 1;
 
139
  }
 
140
  /* Test on large finite numbers.  This fails on BeOS at i = 16322, while
 
141
     LDBL_MAX_EXP = 16384.
 
142
     In the loop end test, we test x against Infinity, rather than comparing
 
143
     i with LDBL_MAX_EXP, because BeOS <float.h> has a wrong LDBL_MAX_EXP.  */
 
144
  {
 
145
    int i;
 
146
    for (i = 1, x = 1.0L; x != x + x; i++, x *= 2.0L)
 
147
      {
 
148
        int exp = -9999;
 
149
        frexpl (x, &exp);
 
150
        if (exp != i)
 
151
          return 1;
 
152
      }
 
153
  }
 
154
  /* Test on denormalized numbers.  */
 
155
  {
 
156
    int i;
 
157
    for (i = 1, x = 1.0L; i >= LDBL_MIN_EXP; i--, x *= 0.5L)
 
158
      ;
 
159
    if (x > 0.0L)
 
160
      {
 
161
        int exp;
 
162
        long double y = frexpl (x, &exp);
 
163
        /* On machines with IEEE854 arithmetic: x = 1.68105e-4932,
 
164
           exp = -16382, y = 0.5.  On MacOS X 10.5: exp = -16384, y = 0.5.  */
 
165
        if (exp != LDBL_MIN_EXP - 1)
 
166
          return 1;
 
167
      }
 
168
  }
 
169
  /* Test on infinite numbers.  */
 
170
  x = 1.0L / 0.0L;
 
171
  {
 
172
    int exp;
 
173
    long double y = frexpl (x, &exp);
 
174
    if (y != x)
 
175
      return 1;
 
176
  }
 
177
  return 0;
 
178
}], [gl_cv_func_frexpl_works=yes], [gl_cv_func_frexpl_works=no],
 
179
      [case "$host_os" in
 
180
         aix* | beos* | darwin* | irix* | mingw* | pw*)
 
181
            gl_cv_func_frexpl_works="guessing no";;
 
182
         *) gl_cv_func_frexpl_works="guessing yes";;
 
183
       esac
 
184
      ])
 
185
    ])
 
186
])