Use C99-defined signbit macro
This commit is contained in:
parent
04be8e84db
commit
80c1faf076
Notes:
git
2021-08-27 15:41:06 +09:00
@ -34,10 +34,6 @@
|
|||||||
#else
|
#else
|
||||||
static VALUE RFLOAT_0;
|
static VALUE RFLOAT_0;
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_SIGNBIT) && defined(__GNUC__) && defined(__sun) && \
|
|
||||||
!defined(signbit)
|
|
||||||
extern int signbit(double);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
VALUE rb_cComplex;
|
VALUE rb_cComplex;
|
||||||
|
|
||||||
|
12
configure.ac
12
configure.ac
@ -1916,17 +1916,7 @@ AS_CASE(["$target_os"],
|
|||||||
AC_CHECK_HEADERS(sys/pstat.h)
|
AC_CHECK_HEADERS(sys/pstat.h)
|
||||||
|
|
||||||
|
|
||||||
AC_CACHE_CHECK(for signbit, rb_cv_have_signbit,
|
AC_DEFINE(HAVE_SIGNBIT) # C99; backward compatibility
|
||||||
[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_FUNC_FORK
|
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);
|
RUBY_EXTERN size_t strlcat(char *, const char*, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SIGNBIT
|
|
||||||
RUBY_EXTERN int signbit(double x);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_FFS
|
#ifndef HAVE_FFS
|
||||||
RUBY_EXTERN int ffs(int);
|
RUBY_EXTERN int ffs(int);
|
||||||
#endif
|
#endif
|
||||||
|
5
math.c
5
math.c
@ -26,11 +26,6 @@
|
|||||||
#include "internal/object.h"
|
#include "internal/object.h"
|
||||||
#include "internal/vm.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)
|
#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
|
||||||
|
|
||||||
VALUE rb_mMath;
|
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…
x
Reference in New Issue
Block a user