diff options
author | Stephen Kitt <skitt@debian.org> | 2016-05-27 10:11:04 +0200 |
---|---|---|
committer | Manuel A. Fernandez Montecelo <manuel.montezelo@gmail.com> | 2016-05-27 14:28:33 +0100 |
commit | 752fd7247bc223bcea35bd89cf56d1c08ead9ba6 (patch) | |
tree | b4a428f847a963738faaf24c8eff070fdb03a3a5 /gnulib-m4/signbit.m4 | |
parent | 9f7d4fa477ff2a51d7c932b13d57ac22dc033105 (diff) | |
parent | a9a31b1de5776a3b08a82101a4fa711294f0dd1d (diff) |
Imported Debian patch 0.9.6+really0.9.3-0.1debian/0.9.6+really0.9.3-0.1
Diffstat (limited to 'gnulib-m4/signbit.m4')
-rw-r--r-- | gnulib-m4/signbit.m4 | 274 |
1 files changed, 98 insertions, 176 deletions
diff --git a/gnulib-m4/signbit.m4 b/gnulib-m4/signbit.m4 index 21b9bf5e..56ff825f 100644 --- a/gnulib-m4/signbit.m4 +++ b/gnulib-m4/signbit.m4 @@ -1,5 +1,5 @@ -# signbit.m4 serial 13 -dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. +# signbit.m4 serial 6 +dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -7,11 +7,9 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_SIGNBIT], [ AC_REQUIRE([gl_MATH_H_DEFAULTS]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([for signbit macro], [gl_cv_func_signbit], [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ + AC_TRY_RUN([ #include <math.h> /* If signbit is defined as a function, don't use it, since calling it for 'float' or 'long double' arguments would involve conversions. @@ -25,16 +23,8 @@ AC_DEFUN([gl_SIGNBIT], #endif #include <string.h> ]gl_SIGNBIT_TEST_PROGRAM -])], - [gl_cv_func_signbit=yes], - [gl_cv_func_signbit=no], - [case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_signbit="guessing yes" ;; - # If we don't know, assume the worst. - *) gl_cv_func_signbit="guessing no" ;; - esac - ]) +, [gl_cv_func_signbit=yes], [gl_cv_func_signbit=no], + [gl_cv_func_signbit="guessing no"]) ]) dnl GCC 4.0 and newer provides three built-ins for signbit. dnl They can be used without warnings, also in C++, regardless of <math.h>. @@ -42,8 +32,7 @@ AC_DEFUN([gl_SIGNBIT], dnl libc. AC_CACHE_CHECK([for signbit compiler built-ins], [gl_cv_func_signbit_gcc], [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ + AC_TRY_RUN([ #if __GNUC__ >= 4 # define signbit(x) \ (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ @@ -54,102 +43,84 @@ AC_DEFUN([gl_SIGNBIT], #endif #include <string.h> ]gl_SIGNBIT_TEST_PROGRAM -])], - [gl_cv_func_signbit_gcc=yes], - [gl_cv_func_signbit_gcc=no], - [case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_signbit_gcc="guessing yes" ;; - # If we don't know, assume the worst. - *) gl_cv_func_signbit_gcc="guessing no" ;; - esac - ]) +, [gl_cv_func_signbit_gcc=yes], [gl_cv_func_signbit_gcc=no], + [gl_cv_func_signbit_gcc="guessing no"]) ]) dnl Use the compiler built-ins whenever possible, because they are more dnl efficient than the system library functions (if they exist). - case "$gl_cv_func_signbit_gcc" in - *yes) - REPLACE_SIGNBIT_USING_GCC=1 - ;; - *) - case "$gl_cv_func_signbit" in - *yes) ;; - *) - dnl REPLACE_SIGNBIT=1 makes sure the signbit[fdl] functions get built. - REPLACE_SIGNBIT=1 - gl_FLOAT_SIGN_LOCATION - gl_DOUBLE_SIGN_LOCATION - gl_LONG_DOUBLE_SIGN_LOCATION - if test "$gl_cv_cc_float_signbit" = unknown; then - dnl Test whether copysignf() is declared. - AC_CHECK_DECLS([copysignf], , , [[#include <math.h>]]) - if test "$ac_cv_have_decl_copysignf" = yes; then - dnl Test whether copysignf() can be used without libm. - AC_CACHE_CHECK([whether copysignf can be used without linking with libm], - [gl_cv_func_copysignf_no_libm], - [ - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include <math.h> - float x, y;]], - [[return copysignf (x, y) < 0;]])], - [gl_cv_func_copysignf_no_libm=yes], - [gl_cv_func_copysignf_no_libm=no]) - ]) - if test $gl_cv_func_copysignf_no_libm = yes; then - AC_DEFINE([HAVE_COPYSIGNF_IN_LIBC], [1], - [Define if the copysignf function is declared in <math.h> and available in libc.]) - fi - fi + if test "$gl_cv_func_signbit_gcc" = yes; then + REPLACE_SIGNBIT_USING_GCC=1 + else + if test "$gl_cv_func_signbit" != yes; then + REPLACE_SIGNBIT=1 + AC_LIBOBJ([signbitf]) + AC_LIBOBJ([signbitd]) + AC_LIBOBJ([signbitl]) + gl_FLOAT_SIGN_LOCATION + gl_DOUBLE_SIGN_LOCATION + gl_LONG_DOUBLE_SIGN_LOCATION + if test "$gl_cv_cc_float_signbit" = unknown; then + dnl Test whether copysignf() is declared. + AC_CHECK_DECLS([copysignf], , , [#include <math.h>]) + if test "$ac_cv_have_decl_copysignf" = yes; then + dnl Test whether copysignf() can be used without libm. + AC_CACHE_CHECK([whether copysignf can be used without linking with libm], + [gl_cv_func_copysignf_no_libm], + [ + AC_TRY_LINK([#include <math.h> + float x, y;], + [return copysignf (x, y) < 0;], + [gl_cv_func_copysignf_no_libm=yes], + [gl_cv_func_copysignf_no_libm=no]) + ]) + if test $gl_cv_func_copysignf_no_libm = yes; then + AC_DEFINE([HAVE_COPYSIGNF_IN_LIBC], [1], + [Define if the copysignf function is declared in <math.h> and available in libc.]) fi - if test "$gl_cv_cc_double_signbit" = unknown; then - dnl Test whether copysign() is declared. - AC_CHECK_DECLS([copysign], , , [[#include <math.h>]]) - if test "$ac_cv_have_decl_copysign" = yes; then - dnl Test whether copysign() can be used without libm. - AC_CACHE_CHECK([whether copysign can be used without linking with libm], - [gl_cv_func_copysign_no_libm], - [ - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include <math.h> - double x, y;]], - [[return copysign (x, y) < 0;]])], - [gl_cv_func_copysign_no_libm=yes], - [gl_cv_func_copysign_no_libm=no]) - ]) - if test $gl_cv_func_copysign_no_libm = yes; then - AC_DEFINE([HAVE_COPYSIGN_IN_LIBC], [1], - [Define if the copysign function is declared in <math.h> and available in libc.]) - fi - fi + fi + fi + if test "$gl_cv_cc_double_signbit" = unknown; then + dnl Test whether copysign() is declared. + AC_CHECK_DECLS([copysign], , , [#include <math.h>]) + if test "$ac_cv_have_decl_copysign" = yes; then + dnl Test whether copysign() can be used without libm. + AC_CACHE_CHECK([whether copysign can be used without linking with libm], + [gl_cv_func_copysign_no_libm], + [ + AC_TRY_LINK([#include <math.h> + double x, y;], + [return copysign (x, y) < 0;], + [gl_cv_func_copysign_no_libm=yes], + [gl_cv_func_copysign_no_libm=no]) + ]) + if test $gl_cv_func_copysign_no_libm = yes; then + AC_DEFINE([HAVE_COPYSIGN_IN_LIBC], [1], + [Define if the copysign function is declared in <math.h> and available in libc.]) fi - if test "$gl_cv_cc_long_double_signbit" = unknown; then - dnl Test whether copysignl() is declared. - AC_CHECK_DECLS([copysignl], , , [[#include <math.h>]]) - if test "$ac_cv_have_decl_copysignl" = yes; then - dnl Test whether copysignl() can be used without libm. - AC_CACHE_CHECK([whether copysignl can be used without linking with libm], - [gl_cv_func_copysignl_no_libm], - [ - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include <math.h> - long double x, y;]], - [[return copysignl (x, y) < 0;]])], - [gl_cv_func_copysignl_no_libm=yes], - [gl_cv_func_copysignl_no_libm=no]) - ]) - if test $gl_cv_func_copysignl_no_libm = yes; then - AC_DEFINE([HAVE_COPYSIGNL_IN_LIBC], [1], - [Define if the copysignl function is declared in <math.h> and available in libc.]) - fi - fi + fi + fi + if test "$gl_cv_cc_long_double_signbit" = unknown; then + dnl Test whether copysignl() is declared. + AC_CHECK_DECLS([copysignl], , , [#include <math.h>]) + if test "$ac_cv_have_decl_copysignl" = yes; then + dnl Test whether copysignl() can be used without libm. + AC_CACHE_CHECK([whether copysignl can be used without linking with libm], + [gl_cv_func_copysignl_no_libm], + [ + AC_TRY_LINK([#include <math.h> + long double x, y;], + [return copysignl (x, y) < 0;], + [gl_cv_func_copysignl_no_libm=yes], + [gl_cv_func_copysignl_no_libm=no]) + ]) + if test $gl_cv_func_copysignl_no_libm = yes; then + AC_DEFINE([HAVE_COPYSIGNL_IN_LIBC], [1], + [Define if the copysignl function is declared in <math.h> and available in libc.]) fi - ;; - esac - ;; - esac + fi + fi + fi + fi ]) AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [[ @@ -170,15 +141,14 @@ double m0d = -p0d; /* On HP-UX 10.20, negating 0.0L does not yield -0.0L. So we use another constant expression instead. But that expression does not work on other platforms, such as when - cross-compiling to PowerPC on Mac OS X 10.5. */ + cross-compiling to PowerPC on MacOS X 10.5. */ long double p0l = 0.0L; #if defined __hpux || defined __sgi long double m0l = -LDBL_MIN * LDBL_MIN; #else long double m0l = -p0l; #endif - int result = 0; - if (signbit (vf)) /* link check */ + if (signbit (vf)) vf++; { float plus_inf = 1.0f / p0f; @@ -189,9 +159,9 @@ long double m0l = -p0l; && (memcmp (&m0f, &p0f, sizeof (float)) == 0 || signbit (m0f)) && !signbit (plus_inf) && signbit (minus_inf))) - result |= 1; + return 1; } - if (signbit (vd)) /* link check */ + if (signbit (vd)) vd++; { double plus_inf = 1.0 / p0d; @@ -202,27 +172,22 @@ long double m0l = -p0l; && (memcmp (&m0d, &p0d, sizeof (double)) == 0 || signbit (m0d)) && !signbit (plus_inf) && signbit (minus_inf))) - result |= 2; + return 1; } - if (signbit (vl)) /* link check */ + if (signbit (vl)) vl++; { long double plus_inf = 1.0L / p0l; long double minus_inf = -1.0L / p0l; - if (signbit (255.0L)) - result |= 4; - if (!signbit (-255.0L)) - result |= 4; - if (signbit (p0l)) - result |= 8; - if (!(memcmp (&m0l, &p0l, sizeof (long double)) == 0 || signbit (m0l))) - result |= 16; - if (signbit (plus_inf)) - result |= 32; - if (!signbit (minus_inf)) - result |= 64; + if (!(!signbit (255.0L) + && signbit (-255.0L) + && !signbit (p0l) + && (memcmp (&m0l, &p0l, sizeof (long double)) == 0 || signbit (m0l)) + && !signbit (plus_inf) + && signbit (minus_inf))) + return 1; } - return result; + return 0; } ]]) @@ -246,8 +211,7 @@ AC_DEFUN([gl_FLOATTYPE_SIGN_LOCATION], AC_CACHE_CHECK([where to find the sign bit in a '$1'], [$2], [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ + AC_TRY_RUN([ #include <stddef.h> #include <stdio.h> #define NWORDS \ @@ -272,7 +236,7 @@ int main () { /* More than one bit difference. */ fprintf (fp, "unknown"); - return 2; + return 1; } if (x) { @@ -284,7 +248,7 @@ int main () { /* No difference. */ fprintf (fp, "unknown"); - return 3; + return 1; } /* Now m = plus.word[k] ^ ~minus.word[k]. */ if (plus.word[k] & ~minus.word[k]) @@ -292,17 +256,15 @@ int main () /* Oh? The sign bit is set in the positive and cleared in the negative numbers? */ fprintf (fp, "unknown"); - return 4; + return 1; } for (i = 0; ; i++) if ((m >> i) & 1) break; fprintf (fp, "word %d bit %d", (int) k, (int) i); - if (fclose (fp) != 0) - return 5; - return 0; + return (fclose (fp) != 0); } - ]])], + ], [$2=`cat conftest.out`], [$2="unknown"], [ @@ -323,43 +285,3 @@ int main () ;; esac ]) - -# Expands to code that defines a function signbitf(float). -# It extracts the sign bit of a non-NaN value. -AC_DEFUN([gl_FLOAT_SIGNBIT_CODE], -[ - gl_FLOATTYPE_SIGNBIT_CODE([float], [f], [f]) -]) - -# Expands to code that defines a function signbitd(double). -# It extracts the sign bit of a non-NaN value. -AC_DEFUN([gl_DOUBLE_SIGNBIT_CODE], -[ - gl_FLOATTYPE_SIGNBIT_CODE([double], [d], []) -]) - -# Expands to code that defines a function signbitl(long double). -# It extracts the sign bit of a non-NaN value. -AC_DEFUN([gl_LONG_DOUBLE_SIGNBIT_CODE], -[ - gl_FLOATTYPE_SIGNBIT_CODE([long double], [l], [L]) -]) - -AC_DEFUN([gl_FLOATTYPE_SIGNBIT_CODE], -[[ -static int -signbit$2 ($1 value) -{ - typedef union { $1 f; unsigned char b[sizeof ($1)]; } float_union; - static float_union plus_one = { 1.0$3 }; /* unused bits are zero here */ - static float_union minus_one = { -1.0$3 }; /* unused bits are zero here */ - /* Compute the sign bit mask as the XOR of plus_one and minus_one. */ - float_union u; - unsigned int i; - u.f = value; - for (i = 0; i < sizeof ($1); i++) - if (u.b[i] & (plus_one.b[i] ^ minus_one.b[i])) - return 1; - return 0; -} -]]) |