@@ -4,6 +4,9 @@ VALUE cMysql2Statement;
44extern VALUE mMysql2 , cMysql2Error , cBigDecimal , cDateTime , cDate ;
55static VALUE sym_stream , intern_new_with_args , intern_each ;
66static 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
710
811#define GET_STATEMENT (self ) \
912 mysql_stmt_wrapper *stmt_wrapper; \
@@ -209,8 +212,8 @@ static int my_big2ll(VALUE bignum, LONG_LONG *ptr)
209212{
210213 unsigned LONG_LONG num ;
211214 size_t len ;
212- int nlz_bits = 0 ;
213215#ifdef HAVE_RB_ABSINT_SIZE
216+ int nlz_bits = 0 ;
214217 len = rb_absint_size (bignum , & nlz_bits );
215218#else
216219 len = RBIGNUM_LEN (bignum ) * SIZEOF_BDIGITS ;
@@ -223,14 +226,17 @@ static int my_big2ll(VALUE bignum, LONG_LONG *ptr)
223226 * ptr = num ;
224227 }
225228 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 )
227234 /* only -0x8000000000000000 is safe if `len == 8 && nlz_bits == 0` */
228- #ifdef HAVE_RB_ABSINT_SINGLEBIT_P
229235 !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 )
233237 rb_big_cmp (bignum , LL2NUM (LLONG_MIN )) == INT2FIX (-1 )
238+ #else
239+ rb_funcall (bignum , intern_cmp , 1 , LL2NUM (LLONG_MIN )) == INT2FIX (-1 )
234240#endif
235241 ) {
236242 goto overflow ;
@@ -553,4 +559,7 @@ void init_mysql2_statement() {
553559 intern_year = rb_intern ("year" );
554560
555561 intern_to_s = rb_intern ("to_s" );
562+ #ifndef HAVE_RB_BIG_CMP
563+ id_cmp = rb_intern ("cmp" );
564+ #endif
556565}
0 commit comments