44
55
#include <string.h>
45
56
]gl_SIGNBIT_TEST_PROGRAM
46
, [gl_cv_func_signbit_gcc=yes], [gl_cv_func_signbit_gcc=no],
47
[gl_cv_func_signbit_gcc="guessing no"])
58
[gl_cv_func_signbit_gcc=yes],
59
[gl_cv_func_signbit_gcc=no],
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" ;;
49
68
dnl Use the compiler built-ins whenever possible, because they are more
50
69
dnl efficient than the system library functions (if they exist).
51
if test "$gl_cv_func_signbit_gcc" = yes; then
52
REPLACE_SIGNBIT_USING_GCC=1
54
if test "$gl_cv_func_signbit" != yes; then
59
gl_FLOAT_SIGN_LOCATION
60
gl_DOUBLE_SIGN_LOCATION
61
gl_LONG_DOUBLE_SIGN_LOCATION
62
if test "$gl_cv_cc_float_signbit" = unknown; then
63
dnl Test whether copysignf() is declared.
64
AC_CHECK_DECLS([copysignf], , , [#include <math.h>])
65
if test "$ac_cv_have_decl_copysignf" = yes; then
66
dnl Test whether copysignf() can be used without libm.
67
AC_CACHE_CHECK([whether copysignf can be used without linking with libm],
68
[gl_cv_func_copysignf_no_libm],
70
AC_TRY_LINK([#include <math.h>
72
[return copysignf (x, y) < 0;],
73
[gl_cv_func_copysignf_no_libm=yes],
74
[gl_cv_func_copysignf_no_libm=no])
76
if test $gl_cv_func_copysignf_no_libm = yes; then
77
AC_DEFINE([HAVE_COPYSIGNF_IN_LIBC], [1],
78
[Define if the copysignf function is declared in <math.h> and available in libc.])
82
if test "$gl_cv_cc_double_signbit" = unknown; then
83
dnl Test whether copysign() is declared.
84
AC_CHECK_DECLS([copysign], , , [#include <math.h>])
85
if test "$ac_cv_have_decl_copysign" = yes; then
86
dnl Test whether copysign() can be used without libm.
87
AC_CACHE_CHECK([whether copysign can be used without linking with libm],
88
[gl_cv_func_copysign_no_libm],
90
AC_TRY_LINK([#include <math.h>
92
[return copysign (x, y) < 0;],
93
[gl_cv_func_copysign_no_libm=yes],
94
[gl_cv_func_copysign_no_libm=no])
96
if test $gl_cv_func_copysign_no_libm = yes; then
97
AC_DEFINE([HAVE_COPYSIGN_IN_LIBC], [1],
98
[Define if the copysign function is declared in <math.h> and available in libc.])
102
if test "$gl_cv_cc_long_double_signbit" = unknown; then
103
dnl Test whether copysignl() is declared.
104
AC_CHECK_DECLS([copysignl], , , [#include <math.h>])
105
if test "$ac_cv_have_decl_copysignl" = yes; then
106
dnl Test whether copysignl() can be used without libm.
107
AC_CACHE_CHECK([whether copysignl can be used without linking with libm],
108
[gl_cv_func_copysignl_no_libm],
110
AC_TRY_LINK([#include <math.h>
112
[return copysignl (x, y) < 0;],
113
[gl_cv_func_copysignl_no_libm=yes],
114
[gl_cv_func_copysignl_no_libm=no])
116
if test $gl_cv_func_copysignl_no_libm = yes; then
117
AC_DEFINE([HAVE_COPYSIGNL_IN_LIBC], [1],
118
[Define if the copysignl function is declared in <math.h> and available in libc.])
70
case "$gl_cv_func_signbit_gcc" in
72
REPLACE_SIGNBIT_USING_GCC=1
75
case "$gl_cv_func_signbit" in
78
dnl REPLACE_SIGNBIT=1 makes sure the signbit[fdl] functions get built.
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],
95
[[return copysignf (x, y) < 0;]])],
96
[gl_cv_func_copysignf_no_libm=yes],
97
[gl_cv_func_copysignf_no_libm=no])
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.])
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],
117
[[return copysign (x, y) < 0;]])],
118
[gl_cv_func_copysign_no_libm=yes],
119
[gl_cv_func_copysign_no_libm=no])
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.])
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],
139
[[return copysignl (x, y) < 0;]])],
140
[gl_cv_func_copysignl_no_libm=yes],
141
[gl_cv_func_copysignl_no_libm=no])
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.])
126
155
AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [[
327
# Expands to code that defines a function signbitf(float).
328
# It extracts the sign bit of a non-NaN value.
329
AC_DEFUN([gl_FLOAT_SIGNBIT_CODE],
331
gl_FLOATTYPE_SIGNBIT_CODE([float], [f], [f])
334
# Expands to code that defines a function signbitd(double).
335
# It extracts the sign bit of a non-NaN value.
336
AC_DEFUN([gl_DOUBLE_SIGNBIT_CODE],
338
gl_FLOATTYPE_SIGNBIT_CODE([double], [d], [])
341
# Expands to code that defines a function signbitl(long double).
342
# It extracts the sign bit of a non-NaN value.
343
AC_DEFUN([gl_LONG_DOUBLE_SIGNBIT_CODE],
345
gl_FLOATTYPE_SIGNBIT_CODE([long double], [l], [L])
348
AC_DEFUN([gl_FLOATTYPE_SIGNBIT_CODE],
353
typedef union { $1 f; unsigned char b[sizeof ($1)]; } float_union;
354
static float_union plus_one = { 1.0$3 }; /* unused bits are zero here */
355
static float_union minus_one = { -1.0$3 }; /* unused bits are zero here */
356
/* Compute the sign bit mask as the XOR of plus_one and minus_one. */
360
for (i = 0; i < sizeof ($1); i++)
361
if (u.b[i] & (plus_one.b[i] ^ minus_one.b[i]))