From 8e1293730e372b0cb5ebad818129f7bbe295477d Mon Sep 17 00:00:00 2001 From: mrkn Date: Sat, 10 Dec 2016 07:49:15 +0000 Subject: bigdecimal: import version 1.3.0.pre Import bigdecimal version 1.3.0.pre. The full commit log of this changes can be found at: https://github.com/ruby/bigdecimal/compare/5c43a9e...v1.3.0.pre git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/bigdecimal/bigdecimal.h | 56 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) (limited to 'ext/bigdecimal/bigdecimal.h') diff --git a/ext/bigdecimal/bigdecimal.h b/ext/bigdecimal/bigdecimal.h index f85c3e55ad..fcfeb9c3c3 100644 --- a/ext/bigdecimal/bigdecimal.h +++ b/ext/bigdecimal/bigdecimal.h @@ -90,6 +90,56 @@ llabs(LONG_LONG const x) } #endif +#ifndef HAVE_FINITE +static int +finite(double) +{ + return !isnan(n) && !isinf(n); +} +#endif + +#ifndef isfinite +# ifndef HAVE_ISFINITE +# define HAVE_ISFINITE 1 +# define isfinite(x) finite(x) +# endif +#endif + +#ifndef FIX_CONST_VALUE_PTR +# if defined(__fcc__) || defined(__fcc_version) || \ + defined(__FCC__) || defined(__FCC_VERSION) +/* workaround for old version of Fujitsu C Compiler (fcc) */ +# define FIX_CONST_VALUE_PTR(x) ((const VALUE *)(x)) +# else +# define FIX_CONST_VALUE_PTR(x) (x) +# endif +#endif + +#ifndef HAVE_RB_ARRAY_CONST_PTR +static inline const VALUE * +rb_array_const_ptr(VALUE a) +{ + return FIX_CONST_VALUE_PTR((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ? + RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr); +} +#endif + +#ifndef RARRAY_CONST_PTR +# define RARRAY_CONST_PTR(a) rb_array_const_ptr(a) +#endif + +#ifndef RARRAY_AREF +# define RARRAY_AREF(a, i) (RARRAY_CONST_PTR(a)[i]) +#endif + +#ifndef HAVE_RB_SYM2STR +static inline VALUE +rb_sym2str(VALUE sym) +{ + return rb_id2str(SYM2ID(sym)); +} +#endif + #ifdef vabs # undef vabs #endif @@ -182,11 +232,11 @@ extern VALUE rb_cBigDecimal; typedef struct { VALUE obj; /* Back pointer(VALUE) for Ruby object. */ size_t MaxPrec; /* Maximum precision size */ - /* This is the actual size of pfrac[] */ + /* This is the actual size of frac[] */ /*(frac[0] to frac[MaxPrec] are available). */ size_t Prec; /* Current precision size. */ - /* This indicates how much the. */ - /* the array frac[] is actually used. */ + /* This indicates how much the */ + /* array frac[] is actually used. */ SIGNED_VALUE exponent; /* Exponent part. */ short sign; /* Attributes of the value. */ /* -- cgit v1.2.3