Changeset 30582 in project
 Timestamp:
 03/18/14 21:27:15 (7 years ago)
 Location:
 release/4/numbers/trunk
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

release/4/numbers/trunk/numbersc.c
r30581 r30582 37 37 */ 38 38 39 #include <assert.h> 39 40 #include <errno.h> 40 41 … … 116 117 C_word result; 117 118 118 BIGNUM_ASSERT(b != BIGNUM_OUT_OF_BAND);119 assert(b != BIGNUM_OUT_OF_BAND); 119 120 120 121 switch(BIGNUM_LENGTH(b)) { … … 206 207 bignum_allocate_zeroed(bignum_length_type length, int negative_p) 207 208 { 208 BIGNUM_ASSERT((length >= 0)  (length < BIGNUM_RADIX));209 assert((length >= 0)  (length < BIGNUM_RADIX)); 209 210 { 210 211 bignum_type result; … … 478 479 int r_neg_p = BIGNUM_NEGATIVE_P (numerator) ? 1 : 0; 479 480 480 BIGNUM_ASSERT(BIGNUM_LENGTH(denominator) > 1);481 assert(BIGNUM_LENGTH(denominator) > 1); 481 482 bignum_divide_unsigned_large_denominator 482 483 (numerator, denominator, ("ient), (&remainder), q_neg_p, r_neg_p); … … 573 574 bignum_type bigx = big_of(x), bigy = big_of(y), bigr; 574 575 575 BIGNUM_ASSERT(BIGNUM_LENGTH(bigx) > 1);576 BIGNUM_ASSERT(BIGNUM_LENGTH(bigy) > 1);576 assert(BIGNUM_LENGTH(bigx) > 1); 577 assert(BIGNUM_LENGTH(bigy) > 1); 577 578 578 579 switch(bignum_compare_unsigned (bigx, bigy)) { … … 605 606 bigy = bigr; 606 607 /* Original bigx is forgotten now */ 607 BIGNUM_ASSERT(bigx != big_of(x));608 BIGNUM_ASSERT(bigy != big_of(x));608 assert(bigx != big_of(x)); 609 assert(bigy != big_of(x)); 609 610 /* Only bigx points to y */ 610 BIGNUM_ASSERT(bigy != big_of(y));611 BIGNUM_ASSERT(bigx == big_of(y));611 assert(bigy != big_of(y)); 612 assert(bigx == big_of(y)); 612 613 613 614 switch (BIGNUM_LENGTH(bigy)) { … … 638 639 639 640 /* Assume that bignums coming from outside are never length 1 */ 640 BIGNUM_ASSERT(bigx != big_of(y));641 assert(bigx != big_of(y)); 641 642 642 643 while(BIGNUM_LENGTH(bigy) > 1) { … … 862 863 } 863 864 } 864 BIGNUM_ASSERT(borrow == 0);865 assert(borrow == 0); 865 866 while (scan_x < end_x) 866 867 (*scan_r++) = (*scan_x++); … … 879 880 : (BIGNUM_NEGATIVE_P (bigy))); 880 881 /* If length 1 or 0, it should be a fixnum */ 881 BIGNUM_ASSERT(BIGNUM_LENGTH(bigx) > 1);882 BIGNUM_ASSERT(BIGNUM_LENGTH(bigy) > 1);882 assert(BIGNUM_LENGTH(bigx) > 1); 883 assert(BIGNUM_LENGTH(bigy) > 1); 883 884 C_return_bignum(k, bignum_multiply_unsigned(bigx, bigy, neg_p)); 884 885 } … … 1050 1051 #define product_high carry 1051 1052 bignum_digit_type * end = (scan + (BIGNUM_LENGTH (bignum))); 1052 BIGNUM_ASSERT((factor > 1) && (factor < BIGNUM_RADIX_ROOT));1053 assert((factor > 1) && (factor < BIGNUM_RADIX_ROOT)); 1053 1054 while (scan < end) 1054 1055 { … … 1066 1067 never happen. 1067 1068 */ 1068 BIGNUM_ASSERT(carry == 0);1069 assert(carry == 0); 1069 1070 return; 1070 1071 #undef product_high … … 1118 1119 bignum_type u = (bignum_allocate (length_n, r_negative_p)); 1119 1120 int shift = 0; 1120 BIGNUM_ASSERT(length_d > 1);1121 assert(length_d > 1); 1121 1122 { 1122 1123 bignum_digit_type v1 = (BIGNUM_REF ((denominator), (length_d  1))); … … 1389 1390 (*scan_target) = carry; 1390 1391 else 1391 BIGNUM_ASSERT(carry == 0);1392 assert(carry == 0); 1392 1393 return; 1393 1394 } … … 1425 1426 carry = ((digit & mask) << shift_left); 1426 1427 } 1427 BIGNUM_ASSERT(carry == 0);1428 BIGNUM_ASSERT(BIGNUM_LENGTH(bignum) != length);1429 BIGNUM_ASSERT(length != 1  BIGNUM_REF(bignum, 0) != 0);1428 assert(carry == 0); 1429 assert(BIGNUM_LENGTH(bignum) != length); 1430 assert(length != 1  BIGNUM_REF(bignum, 0) != 0); 1430 1431 BIGNUM_SET_HEADER 1431 1432 (bignum, length, (BIGNUM_NEGATIVE_P (bignum))); … … 1598 1599 bignum_digit_type * start = (BIGNUM_START_PTR (bignum)); 1599 1600 bignum_digit_type * scan = (start + (BIGNUM_LENGTH (bignum))); 1600 BIGNUM_ASSERT((denominator > 1) && (denominator < BIGNUM_RADIX_ROOT));1601 assert((denominator > 1) && (denominator < BIGNUM_RADIX_ROOT)); 1601 1602 while (start < scan) 1602 1603 { … … 1620 1621 bignum_digit_type * scan = (start + (BIGNUM_LENGTH (n))); 1621 1622 bignum_digit_type r = 0; 1622 BIGNUM_ASSERT((d > 1) && (d < BIGNUM_RADIX_ROOT));1623 assert((d > 1) && (d < BIGNUM_RADIX_ROOT)); 1623 1624 while (start < scan) 1624 1625 { … … 1776 1777 { 1777 1778 bignum_type quotient; 1778 BIGNUM_ASSERT(BIGNUM_LENGTH(denominator) > 1);1779 assert(BIGNUM_LENGTH(denominator) > 1); 1779 1780 bignum_divide_unsigned_large_denominator 1780 1781 (numerator, denominator, ("ient), ((bignum_type *) 0), neg_p, 0); … … 1802 1803 C_kontinue(k, C_fix(0)); 1803 1804 /* Don't handle 0 <= length(bigx) <= 1 since then it should be a fixnum */ 1804 BIGNUM_ASSERT(BIGNUM_LENGTH(bigx) >= 2);1805 assert(BIGNUM_LENGTH(bigx) >= 2); 1805 1806 1806 1807 bigy = bignum_allocate_from_fixnum(y); … … 2049 2050 2050 2051 C_word digit_offset,bit_offset; 2051 BIGNUM_ASSERT(n != 0); /* int_shift_fix checks this */2052 assert(n != 0); /* int_shift_fix checks this */ 2052 2053 2053 2054 if (n > 0) { … … 2301 2302 radix = C_unfix(radix); 2302 2303 2303 BIGNUM_ASSERT((radix > 1) && (radix <= BIGNUM_RADIX_ROOT));2304 assert((radix > 1) && (radix <= BIGNUM_RADIX_ROOT)); 2304 2305 if (! (BIGNUM_ZERO_P (bignum))) 2305 2306 { … … 2361 2362 (((x) >= (int)'a') ?((x)  (int)'a' + 10) : ((x)  (int)'0'))) 2362 2363 2363 BIGNUM_ASSERT((radix > 1) && (radix < BIGNUM_RADIX_ROOT));2364 assert((radix > 1) && (radix < BIGNUM_RADIX_ROOT)); 2364 2365 if (n_digits == 0) 2365 2366 C_kontinue(k, C_SCHEME_FALSE); 
release/4/numbers/trunk/numbersc.h
r26420 r30582 14 14 #define RAT_TAG 1 15 15 #define COMP_TAG 2 16 17 #define BIG_FREE 318 19 #define FORCE_FINALIZERS 420 16 21 17 enum bignum_bitwise_ops … … 158 154 #define BIGNUM_BITS_TO_DIGITS(n) \ 159 155 (((n) + (BIGNUM_DIGIT_LENGTH  1)) / BIGNUM_DIGIT_LENGTH) 160 161 #ifndef BIGNUM_DISABLE_ASSERTION_CHECKS162 163 #define BIGNUM_EXCEPTION abort164 165 #define BIGNUM_ASSERT(expression) \166 { \167 if (! (expression)) \168 BIGNUM_EXCEPTION (); \169 }170 171 #else172 173 #define BIGNUM_ASSERT(expression)174 175 #endif /* BIGNUM_DISABLE_ASSERTION_CHECKS */176 177 /* Chickenspecific */178 #define BIGNUM_FITS_IN_FIXNUM_P(b) \179 ((BIGNUM_LENGTH(b)) == 0  (BIGNUM_LENGTH(b)) == 1 && BIGNUM_REF())
Note: See TracChangeset
for help on using the changeset viewer.