int128-bignum.patch

Akira Tanaka, 06/10/2013 09:59 PM

Download (2.69 KB)

View differences:

include/ruby/defines.h (working copy)
141 141
# define SIZEOF_LONG_LONG SIZEOF___INT64
142 142
#endif
143 143

  
144
#if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
144
#if defined(HAVE_INT64_T) && defined(HAVE_INT128_T)
145
# define BDIGIT uint64_t
146
# define SIZEOF_BDIGITS SIZEOF_INT64_T
147
# define BDIGIT_DBL uint128_t
148
# define BDIGIT_DBL_SIGNED int128_t
149
# define PRI_BDIGIT_PREFIX PRI_64_PREFIX
150
#elif SIZEOF_INT*2 <= SIZEOF_LONG_LONG
145 151
# define BDIGIT unsigned int
146 152
# define SIZEOF_BDIGITS SIZEOF_INT
147 153
# define BDIGIT_DBL unsigned LONG_LONG
include/ruby/ruby.h (working copy)
115 115
#define PRI_LONG_PREFIX "l"
116 116
#endif
117 117

  
118
#if SIZEOF_LONG == 8
119
#define PRI_64_PREFIX PRI_LONG_PREFIX
120
#elif SIZEOF_LONG_LONG == 8
121
#define PRI_64_PREFIX PRI_LL_PREFIX
122
#endif
123

  
118 124
#if defined PRIdPTR && !defined PRI_VALUE_PREFIX
119 125
#define PRIdVALUE PRIdPTR
120 126
#define PRIoVALUE PRIoPTR
configure.in (working copy)
1150 1150
RUBY_CHECK_SIZEOF(long, [int], [ILP LP])
1151 1151
RUBY_CHECK_SIZEOF(long long)
1152 1152
RUBY_CHECK_SIZEOF(__int64)
1153
RUBY_CHECK_SIZEOF(__int128)
1153 1154
RUBY_CHECK_SIZEOF(off_t)
1154 1155
RUBY_CHECK_SIZEOF(void*, [int long "long long"], [ILP LP LLP])
1155 1156
RUBY_CHECK_SIZEOF(float)
......
1572 1573
    ["$ac_cv_sizeof_long"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long"],
1573 1574
    ["$ac_cv_sizeof_long_long"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])long long"],
1574 1575
    ["$ac_cv_sizeof___int64"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])__int64"],
1576
    ["$ac_cv_sizeof___int128"], [ rb_cv_type_$1="m4_if([$3], [], [], [$3 ])__int128"],
1575 1577
    [ rb_cv_type_$1=no])])])
1576 1578
if test "${rb_cv_type_$1}" != no; then
1577 1579
    AC_DEFINE([HAVE_]AS_TR_CPP($1), 1)
bignum.c (working copy)
3967 3967
	    SIGNED_VALUE mask;
3968 3968
	    const long xlen = RBIGNUM_LEN(x);
3969 3969
            const long xbits = BITSPERDIG*xlen - nlz(RBIGNUM_DIGITS(x)[xlen-1]);
3970
	    const long BIGLEN_LIMIT = BITSPERDIG*1024*1024;
3970
	    const long BIGLEN_LIMIT = 32*1024*1024;
3971 3971

  
3972 3972
	    if ((xbits > BIGLEN_LIMIT) || (xbits * yy > BIGLEN_LIMIT)) {
3973 3973
		rb_warn("in a**b, b may be too big");