~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to m4/signbit.m4

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# signbit.m4 serial 10
2
 
dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 
1
# signbit.m4 serial 13
 
2
dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
3
3
dnl This file is free software; the Free Software Foundation
4
4
dnl gives unlimited permission to copy and/or distribute it,
5
5
dnl with or without modifications, as long as this notice is preserved.
7
7
AC_DEFUN([gl_SIGNBIT],
8
8
[
9
9
  AC_REQUIRE([gl_MATH_H_DEFAULTS])
 
10
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
10
11
  AC_CACHE_CHECK([for signbit macro], [gl_cv_func_signbit],
11
12
    [
12
13
      AC_RUN_IFELSE(
27
28
])],
28
29
        [gl_cv_func_signbit=yes],
29
30
        [gl_cv_func_signbit=no],
30
 
        [gl_cv_func_signbit="guessing no"])
 
31
        [case "$host_os" in
 
32
                   # Guess yes on glibc systems.
 
33
           *-gnu*) gl_cv_func_signbit="guessing yes" ;;
 
34
                   # If we don't know, assume the worst.
 
35
           *)      gl_cv_func_signbit="guessing no" ;;
 
36
         esac
 
37
        ])
31
38
    ])
32
39
  dnl GCC 4.0 and newer provides three built-ins for signbit.
33
40
  dnl They can be used without warnings, also in C++, regardless of <math.h>.
50
57
])],
51
58
        [gl_cv_func_signbit_gcc=yes],
52
59
        [gl_cv_func_signbit_gcc=no],
53
 
        [gl_cv_func_signbit_gcc="guessing no"])
 
60
        [case "$host_os" in
 
61
                   # Guess yes on glibc systems.
 
62
           *-gnu*) gl_cv_func_signbit_gcc="guessing yes" ;;
 
63
                   # If we don't know, assume the worst.
 
64
           *)      gl_cv_func_signbit_gcc="guessing no" ;;
 
65
         esac
 
66
        ])
54
67
    ])
55
68
  dnl Use the compiler built-ins whenever possible, because they are more
56
69
  dnl efficient than the system library functions (if they exist).
57
 
  if test "$gl_cv_func_signbit_gcc" = yes; then
58
 
    REPLACE_SIGNBIT_USING_GCC=1
59
 
  else
60
 
    if test "$gl_cv_func_signbit" != yes; then
61
 
      dnl REPLACE_SIGNBIT=1 makes sure the signbit[fdl] functions get built.
62
 
      REPLACE_SIGNBIT=1
63
 
      gl_FLOAT_SIGN_LOCATION
64
 
      gl_DOUBLE_SIGN_LOCATION
65
 
      gl_LONG_DOUBLE_SIGN_LOCATION
66
 
      if test "$gl_cv_cc_float_signbit" = unknown; then
67
 
        dnl Test whether copysignf() is declared.
68
 
        AC_CHECK_DECLS([copysignf], , , [#include <math.h>])
69
 
        if test "$ac_cv_have_decl_copysignf" = yes; then
70
 
          dnl Test whether copysignf() can be used without libm.
71
 
          AC_CACHE_CHECK([whether copysignf can be used without linking with libm],
72
 
            [gl_cv_func_copysignf_no_libm],
73
 
            [
74
 
              AC_LINK_IFELSE(
75
 
                [AC_LANG_PROGRAM(
76
 
                   [[#include <math.h>
77
 
                     float x, y;]],
78
 
                   [[return copysignf (x, y) < 0;]])],
79
 
                [gl_cv_func_copysignf_no_libm=yes],
80
 
                [gl_cv_func_copysignf_no_libm=no])
81
 
            ])
82
 
          if test $gl_cv_func_copysignf_no_libm = yes; then
83
 
            AC_DEFINE([HAVE_COPYSIGNF_IN_LIBC], [1],
84
 
              [Define if the copysignf function is declared in <math.h> and available in libc.])
85
 
          fi
86
 
        fi
87
 
      fi
88
 
      if test "$gl_cv_cc_double_signbit" = unknown; then
89
 
        dnl Test whether copysign() is declared.
90
 
        AC_CHECK_DECLS([copysign], , , [#include <math.h>])
91
 
        if test "$ac_cv_have_decl_copysign" = yes; then
92
 
          dnl Test whether copysign() can be used without libm.
93
 
          AC_CACHE_CHECK([whether copysign can be used without linking with libm],
94
 
            [gl_cv_func_copysign_no_libm],
95
 
            [
96
 
              AC_LINK_IFELSE(
97
 
                [AC_LANG_PROGRAM(
98
 
                   [[#include <math.h>
99
 
                     double x, y;]],
100
 
                   [[return copysign (x, y) < 0;]])],
101
 
                [gl_cv_func_copysign_no_libm=yes],
102
 
                [gl_cv_func_copysign_no_libm=no])
103
 
            ])
104
 
          if test $gl_cv_func_copysign_no_libm = yes; then
105
 
            AC_DEFINE([HAVE_COPYSIGN_IN_LIBC], [1],
106
 
              [Define if the copysign function is declared in <math.h> and available in libc.])
107
 
          fi
108
 
        fi
109
 
      fi
110
 
      if test "$gl_cv_cc_long_double_signbit" = unknown; then
111
 
        dnl Test whether copysignl() is declared.
112
 
        AC_CHECK_DECLS([copysignl], , , [#include <math.h>])
113
 
        if test "$ac_cv_have_decl_copysignl" = yes; then
114
 
          dnl Test whether copysignl() can be used without libm.
115
 
          AC_CACHE_CHECK([whether copysignl can be used without linking with libm],
116
 
            [gl_cv_func_copysignl_no_libm],
117
 
            [
118
 
              AC_LINK_IFELSE(
119
 
                [AC_LANG_PROGRAM(
120
 
                   [[#include <math.h>
121
 
                     long double x, y;]],
122
 
                   [[return copysignl (x, y) < 0;]])],
123
 
                [gl_cv_func_copysignl_no_libm=yes],
124
 
                [gl_cv_func_copysignl_no_libm=no])
125
 
            ])
126
 
          if test $gl_cv_func_copysignl_no_libm = yes; then
127
 
            AC_DEFINE([HAVE_COPYSIGNL_IN_LIBC], [1],
128
 
              [Define if the copysignl function is declared in <math.h> and available in libc.])
129
 
          fi
130
 
        fi
131
 
      fi
132
 
    fi
133
 
  fi
 
70
  case "$gl_cv_func_signbit_gcc" in
 
71
    *yes)
 
72
      REPLACE_SIGNBIT_USING_GCC=1
 
73
      ;;
 
74
    *)
 
75
      case "$gl_cv_func_signbit" in
 
76
        *yes) ;;
 
77
        *)
 
78
          dnl REPLACE_SIGNBIT=1 makes sure the signbit[fdl] functions get built.
 
79
          REPLACE_SIGNBIT=1
 
80
          gl_FLOAT_SIGN_LOCATION
 
81
          gl_DOUBLE_SIGN_LOCATION
 
82
          gl_LONG_DOUBLE_SIGN_LOCATION
 
83
          if test "$gl_cv_cc_float_signbit" = unknown; then
 
84
            dnl Test whether copysignf() is declared.
 
85
            AC_CHECK_DECLS([copysignf], , , [[#include <math.h>]])
 
86
            if test "$ac_cv_have_decl_copysignf" = yes; then
 
87
              dnl Test whether copysignf() can be used without libm.
 
88
              AC_CACHE_CHECK([whether copysignf can be used without linking with libm],
 
89
                [gl_cv_func_copysignf_no_libm],
 
90
                [
 
91
                  AC_LINK_IFELSE(
 
92
                    [AC_LANG_PROGRAM(
 
93
                       [[#include <math.h>
 
94
                         float x, y;]],
 
95
                       [[return copysignf (x, y) < 0;]])],
 
96
                    [gl_cv_func_copysignf_no_libm=yes],
 
97
                    [gl_cv_func_copysignf_no_libm=no])
 
98
                ])
 
99
              if test $gl_cv_func_copysignf_no_libm = yes; then
 
100
                AC_DEFINE([HAVE_COPYSIGNF_IN_LIBC], [1],
 
101
                  [Define if the copysignf function is declared in <math.h> and available in libc.])
 
102
              fi
 
103
            fi
 
104
          fi
 
105
          if test "$gl_cv_cc_double_signbit" = unknown; then
 
106
            dnl Test whether copysign() is declared.
 
107
            AC_CHECK_DECLS([copysign], , , [[#include <math.h>]])
 
108
            if test "$ac_cv_have_decl_copysign" = yes; then
 
109
              dnl Test whether copysign() can be used without libm.
 
110
              AC_CACHE_CHECK([whether copysign can be used without linking with libm],
 
111
                [gl_cv_func_copysign_no_libm],
 
112
                [
 
113
                  AC_LINK_IFELSE(
 
114
                    [AC_LANG_PROGRAM(
 
115
                       [[#include <math.h>
 
116
                         double x, y;]],
 
117
                       [[return copysign (x, y) < 0;]])],
 
118
                    [gl_cv_func_copysign_no_libm=yes],
 
119
                    [gl_cv_func_copysign_no_libm=no])
 
120
                ])
 
121
              if test $gl_cv_func_copysign_no_libm = yes; then
 
122
                AC_DEFINE([HAVE_COPYSIGN_IN_LIBC], [1],
 
123
                  [Define if the copysign function is declared in <math.h> and available in libc.])
 
124
              fi
 
125
            fi
 
126
          fi
 
127
          if test "$gl_cv_cc_long_double_signbit" = unknown; then
 
128
            dnl Test whether copysignl() is declared.
 
129
            AC_CHECK_DECLS([copysignl], , , [[#include <math.h>]])
 
130
            if test "$ac_cv_have_decl_copysignl" = yes; then
 
131
              dnl Test whether copysignl() can be used without libm.
 
132
              AC_CACHE_CHECK([whether copysignl can be used without linking with libm],
 
133
                [gl_cv_func_copysignl_no_libm],
 
134
                [
 
135
                  AC_LINK_IFELSE(
 
136
                    [AC_LANG_PROGRAM(
 
137
                       [[#include <math.h>
 
138
                         long double x, y;]],
 
139
                       [[return copysignl (x, y) < 0;]])],
 
140
                    [gl_cv_func_copysignl_no_libm=yes],
 
141
                    [gl_cv_func_copysignl_no_libm=no])
 
142
                ])
 
143
              if test $gl_cv_func_copysignl_no_libm = yes; then
 
144
                AC_DEFINE([HAVE_COPYSIGNL_IN_LIBC], [1],
 
145
                  [Define if the copysignl function is declared in <math.h> and available in libc.])
 
146
              fi
 
147
            fi
 
148
          fi
 
149
          ;;
 
150
      esac
 
151
      ;;
 
152
  esac
134
153
])
135
154
 
136
155
AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [[
151
170
/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
152
171
   So we use another constant expression instead.
153
172
   But that expression does not work on other platforms, such as when
154
 
   cross-compiling to PowerPC on MacOS X 10.5.  */
 
173
   cross-compiling to PowerPC on Mac OS X 10.5.  */
155
174
long double p0l = 0.0L;
156
175
#if defined __hpux || defined __sgi
157
176
long double m0l = -LDBL_MIN * LDBL_MIN;