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

ruby-changes:29286

From: akr <ko1@a...>
Date: Sun, 16 Jun 2013 23:16:45 +0900 (JST)
Subject: [ruby-changes:29286] akr:r41338 (trunk): * bignum.c (BARY_ADD): New macro.

akr	2013-06-16 23:16:33 +0900 (Sun, 16 Jun 2013)

  New Revision: 41338

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

  Log:
    * bignum.c (BARY_ADD): New macro.
      (BARY_SUB): Ditto.
      (BARY_MUL): Ditto.
      (BARY_DIVMOD): Ditto.
      (BARY_ZERO_P): Ditto.
      (absint_numwords_generic): Use these macros.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41337)
+++ ChangeLog	(revision 41338)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jun 16 23:14:58 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (BARY_ADD): New macro.
+	  (BARY_SUB): Ditto.
+	  (BARY_MUL): Ditto.
+	  (BARY_DIVMOD): Ditto.
+	  (BARY_ZERO_P): Ditto.
+	  (absint_numwords_generic): Use these macros.
+
 Sun Jun 16 21:41:39 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c (bary_2comp): Extracted from get2comp.
Index: bignum.c
===================================================================
--- bignum.c	(revision 41337)
+++ bignum.c	(revision 41338)
@@ -55,6 +55,12 @@ static VALUE big_three = Qnil; https://github.com/ruby/ruby/blob/trunk/bignum.c#L55
 #define bdigit_roomof(n) roomof(n, sizeof(BDIGIT))
 #define BARY_ARGS(ary) ary, numberof(ary)
 
+#define BARY_ADD(z, x, y) bary_add(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))
+#define BARY_SUB(z, x, y) bary_sub(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))
+#define BARY_MUL(z, x, y) bary_mul(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))
+#define BARY_DIVMOD(q, r, x, y) bary_divmod(BARY_ARGS(q), BARY_ARGS(r), BARY_ARGS(x), BARY_ARGS(y))
+#define BARY_ZERO_P(x) bary_zero_p(BARY_ARGS(x))
+
 static int nlz(BDIGIT x);
 static BDIGIT bdigs_small_lshift(BDIGIT *zds, BDIGIT *xds, long n, int shift);
 static void bdigs_small_rshift(BDIGIT *zds, BDIGIT *xds, long n, int shift, int sign_bit);
@@ -639,17 +645,17 @@ absint_numwords_generic(size_t numbytes, https://github.com/ruby/ruby/blob/trunk/bignum.c#L645
 
     bary_unpack(BARY_ARGS(numbytes_bary), &numbytes, 1, sizeof(numbytes), 0,
         INTEGER_PACK_NATIVE_BYTE_ORDER);
-    bary_mul(BARY_ARGS(val_numbits_bary), BARY_ARGS(numbytes_bary), BARY_ARGS(char_bit));
+    BARY_MUL(val_numbits_bary, numbytes_bary, char_bit);
     if (nlz_bits_in_msbyte)
-        bary_sub(BARY_ARGS(val_numbits_bary), BARY_ARGS(val_numbits_bary), BARY_ARGS(nlz_bits_in_msbyte_bary));
+        BARY_SUB(val_numbits_bary, val_numbits_bary, nlz_bits_in_msbyte_bary);
     bary_unpack(BARY_ARGS(word_numbits_bary), &word_numbits, 1, sizeof(word_numbits), 0,
         INTEGER_PACK_NATIVE_BYTE_ORDER);
-    bary_divmod(BARY_ARGS(div_bary), BARY_ARGS(mod_bary), BARY_ARGS(val_numbits_bary), BARY_ARGS(word_numbits_bary));
-    if (bary_zero_p(BARY_ARGS(mod_bary))) {
+    BARY_DIVMOD(div_bary, mod_bary, val_numbits_bary, word_numbits_bary);
+    if (BARY_ZERO_P(mod_bary)) {
         nlz_bits = 0;
     }
     else {
-        bary_add(BARY_ARGS(div_bary), BARY_ARGS(div_bary), BARY_ARGS(one));
+        BARY_ADD(div_bary, div_bary, one);
         bary_pack(+1, BARY_ARGS(mod_bary), &mod, 1, sizeof(mod), 0,
             INTEGER_PACK_NATIVE_BYTE_ORDER);
         nlz_bits = word_numbits - mod;

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

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