@@ -4,6 +4,9 @@ VALUE cMysql2Statement;
4
4
extern VALUE mMysql2 , cMysql2Error , cBigDecimal , cDateTime , cDate ;
5
5
static VALUE sym_stream , intern_new_with_args , intern_each ;
6
6
static VALUE intern_usec , intern_sec , intern_min , intern_hour , intern_day , intern_month , intern_year , intern_to_s ;
7
+ #ifndef HAVE_RB_BIG_CMP
8
+ static ID id_cmp ;
9
+ #endif
7
10
8
11
#define GET_STATEMENT (self ) \
9
12
mysql_stmt_wrapper *stmt_wrapper; \
@@ -209,8 +212,8 @@ static int my_big2ll(VALUE bignum, LONG_LONG *ptr)
209
212
{
210
213
unsigned LONG_LONG num ;
211
214
size_t len ;
212
- int nlz_bits = 0 ;
213
215
#ifdef HAVE_RB_ABSINT_SIZE
216
+ int nlz_bits = 0 ;
214
217
len = rb_absint_size (bignum , & nlz_bits );
215
218
#else
216
219
len = RBIGNUM_LEN (bignum ) * SIZEOF_BDIGITS ;
@@ -223,14 +226,17 @@ static int my_big2ll(VALUE bignum, LONG_LONG *ptr)
223
226
* ptr = num ;
224
227
}
225
228
else {
226
- if (len == 8 && nlz_bits == 0 &&
229
+ if (len == 8 &&
230
+ #ifdef HAVE_RB_ABSINT_SIZE
231
+ nlz_bits == 0 &&
232
+ #endif
233
+ #if defined(HAVE_RB_ABSINT_SIZE ) && defined(HAVE_RB_ABSINT_SINGLEBIT_P )
227
234
/* only -0x8000000000000000 is safe if `len == 8 && nlz_bits == 0` */
228
- #ifdef HAVE_RB_ABSINT_SINGLEBIT_P
229
235
!rb_absint_singlebit_p (bignum )
230
- #elif defined(HAVE_RB_BIG_AND )
231
- rb_big_and (bignum , LL2NUM (LLONG_MAX )) != INT2FIX (0 )
232
- #else
236
+ #elif defined(HAVE_RB_BIG_CMP )
233
237
rb_big_cmp (bignum , LL2NUM (LLONG_MIN )) == INT2FIX (-1 )
238
+ #else
239
+ rb_funcall (bignum , intern_cmp , 1 , LL2NUM (LLONG_MIN )) == INT2FIX (-1 )
234
240
#endif
235
241
) {
236
242
goto overflow ;
@@ -553,4 +559,7 @@ void init_mysql2_statement() {
553
559
intern_year = rb_intern ("year" );
554
560
555
561
intern_to_s = rb_intern ("to_s" );
562
+ #ifndef HAVE_RB_BIG_CMP
563
+ id_cmp = rb_intern ("cmp" );
564
+ #endif
556
565
}
0 commit comments