[前][次][番号順一覧][スレッド一覧]

ruby-changes:29926

From: nobu <ko1@a...>
Date: Mon, 15 Jul 2013 11:11:25 +0900 (JST)
Subject: [ruby-changes:29926] nobu:r41978 (trunk): bignum.c: suppress warnings

nobu	2013-07-15 11:11:15 +0900 (Mon, 15 Jul 2013)

  New Revision: 41978

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41978

  Log:
    bignum.c: suppress warnings
    
    * bignum.c (big_shift2, rb_big_lshift, rb_big_rshift): cast explicitly
      to suppress warnings.

  Modified files:
    trunk/bignum.c

Index: bignum.c
===================================================================
--- bignum.c	(revision 41977)
+++ bignum.c	(revision 41978)
@@ -62,6 +62,9 @@ STATIC_ASSERT(rbignum_embed_len_max, RBI https://github.com/ruby/ruby/blob/trunk/bignum.c#L62
 
 #define BDIGITS(x) (RBIGNUM_DIGITS(x))
 #define BITSPERDIG (SIZEOF_BDIGITS*CHAR_BIT)
+#if BITSPERDIG >= INT_MAX
+# error incredible BDIGIT
+#endif
 #define BIGRAD ((BDIGIT_DBL)1 << BITSPERDIG)
 #define BIGRAD_HALF ((BDIGIT)(BIGRAD >> 1))
 #define BDIGIT_MSB(d) (((d) & BIGRAD_HALF) != 0)
@@ -3308,7 +3311,7 @@ big_shift2(VALUE x, int lshift_p, VALUE https://github.com/ruby/ruby/blob/trunk/bignum.c#L3311
         if (1 < sign || CHAR_BIT <= lens[1])
             return RBIGNUM_POSITIVE_P(x) ? INT2FIX(0) : INT2FIX(-1);
     }
-    shift_numbits = lens[0] & (BITSPERDIG-1);
+    shift_numbits = (int)(lens[0] & (BITSPERDIG-1));
     shift_numdigits = (lens[0] >> bitsize(BITSPERDIG-1)) |
       (lens[1] << (CHAR_BIT*SIZEOF_SIZE_T - bitsize(BITSPERDIG-1)));
     return big_shift3(x, lshift_p, shift_numdigits, shift_numbits);
@@ -5770,7 +5773,7 @@ rb_big_lshift(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L5773
 		lshift_p = 0;
 		shift = 1+(unsigned long)(-(l+1));
 	    }
-            shift_numbits = shift & (BITSPERDIG-1);
+            shift_numbits = (int)(shift & (BITSPERDIG-1));
             shift_numdigits = shift >> bitsize(BITSPERDIG-1);
             return bignorm(big_shift3(x, lshift_p, shift_numdigits, shift_numbits));
 	}
@@ -5808,7 +5811,7 @@ rb_big_rshift(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L5811
                 lshift_p = 1;
 		shift = 1+(unsigned long)(-(l+1));
 	    }
-            shift_numbits = shift & (BITSPERDIG-1);
+            shift_numbits = (int)(shift & (BITSPERDIG-1));
             shift_numdigits = shift >> bitsize(BITSPERDIG-1);
             return bignorm(big_shift3(x, lshift_p, shift_numdigits, shift_numbits));
 	}

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]