Project

General

Profile

Feature #8509 ยป int128-bignum.patch

akr (Akira Tanaka), 06/10/2013 09:59 PM

View differences:

include/ruby/defines.h (working copy)
# define SIZEOF_LONG_LONG SIZEOF___INT64
#endif
#if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
#if defined(HAVE_INT64_T) && defined(HAVE_INT128_T)
# define BDIGIT uint64_t
# define SIZEOF_BDIGITS SIZEOF_INT64_T
# define BDIGIT_DBL uint128_t
# define BDIGIT_DBL_SIGNED int128_t
# define PRI_BDIGIT_PREFIX PRI_64_PREFIX
#elif SIZEOF_INT*2 <= SIZEOF_LONG_LONG
# define BDIGIT unsigned int
# define SIZEOF_BDIGITS SIZEOF_INT
# define BDIGIT_DBL unsigned LONG_LONG
include/ruby/ruby.h (working copy)
#define PRI_LONG_PREFIX "l"
#endif
#if SIZEOF_LONG == 8
#define PRI_64_PREFIX PRI_LONG_PREFIX
#elif SIZEOF_LONG_LONG == 8
#define PRI_64_PREFIX PRI_LL_PREFIX
#endif
#if defined PRIdPTR && !defined PRI_VALUE_PREFIX
#define PRIdVALUE PRIdPTR
#define PRIoVALUE PRIoPTR
configure.in (working copy)
RUBY_CHECK_SIZEOF(long, [int], [ILP LP])
RUBY_CHECK_SIZEOF(long long)
RUBY_CHECK_SIZEOF(__int64)
RUBY_CHECK_SIZEOF(__int128)
RUBY_CHECK_SIZEOF(off_t)
RUBY_CHECK_SIZEOF(void*, [int long "long long"], [ILP LP LLP])
RUBY_CHECK_SIZEOF(float)
......
["$ac_cv_sizeof_long"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long"],
["$ac_cv_sizeof_long_long"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long long"],
["$ac_cv_sizeof___int64"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])__int64"],
["$ac_cv_sizeof___int128"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])__int128"],
[ rb_cv_type_$1=no])])])
if test "${rb_cv_type_$1}" != no; then
AC_DEFINE([HAVE_]AS_TR_CPP($1), 1)
bignum.c (working copy)
SIGNED_VALUE mask;
const long xlen = RBIGNUM_LEN(x);
const long xbits = BITSPERDIG*xlen - nlz(RBIGNUM_DIGITS(x)[xlen-1]);
const long BIGLEN_LIMIT = BITSPERDIG*1024*1024;
const long BIGLEN_LIMIT = 32*1024*1024;
if ((xbits > BIGLEN_LIMIT) || (xbits * yy > BIGLEN_LIMIT)) {
rb_warn("in a**b, b may be too big");
    (1-1/1)