mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use C99-defined signbit macro
This commit is contained in:
parent
04be8e84db
commit
80c1faf076
Notes:
git
2021-08-27 15:41:06 +09:00
5 changed files with 1 additions and 43 deletions
|
@ -34,10 +34,6 @@
|
|||
#else
|
||||
static VALUE RFLOAT_0;
|
||||
#endif
|
||||
#if defined(HAVE_SIGNBIT) && defined(__GNUC__) && defined(__sun) && \
|
||||
!defined(signbit)
|
||||
extern int signbit(double);
|
||||
#endif
|
||||
|
||||
VALUE rb_cComplex;
|
||||
|
||||
|
|
12
configure.ac
12
configure.ac
|
@ -1916,17 +1916,7 @@ AS_CASE(["$target_os"],
|
|||
AC_CHECK_HEADERS(sys/pstat.h)
|
||||
|
||||
|
||||
AC_CACHE_CHECK(for signbit, rb_cv_have_signbit,
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <math.h>
|
||||
]], [[int v = signbit(-0.0);]])],
|
||||
rb_cv_have_signbit=yes,
|
||||
rb_cv_have_signbit=no)])
|
||||
AS_IF([test "$rb_cv_have_signbit" = yes], [
|
||||
AC_DEFINE(HAVE_SIGNBIT)
|
||||
], [
|
||||
AC_LIBOBJ([signbit])
|
||||
])
|
||||
AC_DEFINE(HAVE_SIGNBIT) # C99; backward compatibility
|
||||
|
||||
AC_FUNC_FORK
|
||||
|
||||
|
|
|
@ -198,10 +198,6 @@ RUBY_EXTERN size_t strlcpy(char *, const char*, size_t);
|
|||
RUBY_EXTERN size_t strlcat(char *, const char*, size_t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SIGNBIT
|
||||
RUBY_EXTERN int signbit(double x);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FFS
|
||||
RUBY_EXTERN int ffs(int);
|
||||
#endif
|
||||
|
|
5
math.c
5
math.c
|
@ -26,11 +26,6 @@
|
|||
#include "internal/object.h"
|
||||
#include "internal/vm.h"
|
||||
|
||||
#if defined(HAVE_SIGNBIT) && defined(__GNUC__) && defined(__sun) && \
|
||||
!defined(signbit)
|
||||
extern int signbit(double);
|
||||
#endif
|
||||
|
||||
#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
|
||||
|
||||
VALUE rb_mMath;
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#include <limits.h>
|
||||
#include "ruby.h"
|
||||
|
||||
int
|
||||
signbit(double x)
|
||||
{
|
||||
enum {double_per_long = sizeof(double) / sizeof(long)};
|
||||
enum {long_msb = sizeof(long) * CHAR_BIT - 1};
|
||||
union {double d; unsigned long i[double_per_long];} u;
|
||||
unsigned long l;
|
||||
|
||||
u.d = x;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
l = u.i[0];
|
||||
#else
|
||||
l = u.i[double_per_long - 1];
|
||||
#endif
|
||||
return (int)(l >> long_msb);
|
||||
}
|
Loading…
Reference in a new issue