Changeset 30582 in project for release/4/numbers/trunk/numbers-c.c


Ignore:
Timestamp:
03/18/14 21:27:15 (7 years ago)
Author:
sjamaan
Message:

numbers: Minor simplification by cutting out the ability to turn off assertion checks specifically for bignums. Remove ancient constants BIG_FREE and FORCE_FINALIZERS (which go all the way back to the gmp implementation)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/numbers/trunk/numbers-c.c

    r30581 r30582  
    3737 */
    3838
     39#include <assert.h>
    3940#include <errno.h>
    4041
     
    116117  C_word result;
    117118 
    118   BIGNUM_ASSERT(b != BIGNUM_OUT_OF_BAND);
     119  assert(b != BIGNUM_OUT_OF_BAND);
    119120
    120121  switch(BIGNUM_LENGTH(b)) {
     
    206207bignum_allocate_zeroed(bignum_length_type length, int negative_p)
    207208{
    208   BIGNUM_ASSERT ((length >= 0) || (length < BIGNUM_RADIX));
     209  assert((length >= 0) || (length < BIGNUM_RADIX));
    209210  {
    210211    bignum_type result;
     
    478479        int r_neg_p = BIGNUM_NEGATIVE_P (numerator) ? 1 : 0;
    479480       
    480         BIGNUM_ASSERT(BIGNUM_LENGTH(denominator) > 1);
     481        assert(BIGNUM_LENGTH(denominator) > 1);
    481482        bignum_divide_unsigned_large_denominator
    482483          (numerator, denominator, (&quotient), (&remainder), q_neg_p, r_neg_p);
     
    573574  bignum_type bigx = big_of(x), bigy = big_of(y), bigr;
    574575
    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);
    577578 
    578579  switch(bignum_compare_unsigned (bigx, bigy)) {
     
    605606  bigy = bigr;
    606607  /* 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));
    609610  /* 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));
    612613
    613614  switch (BIGNUM_LENGTH(bigy)) {
     
    638639
    639640  /* Assume that bignums coming from outside are never length 1 */
    640   BIGNUM_ASSERT(bigx != big_of(y));
     641  assert(bigx != big_of(y));
    641642 
    642643  while(BIGNUM_LENGTH(bigy) > 1) {
     
    862863              }
    863864          }
    864       BIGNUM_ASSERT (borrow == 0);
     865      assert(borrow == 0);
    865866      while (scan_x < end_x)
    866867        (*scan_r++) = (*scan_x++);
     
    879880               : (BIGNUM_NEGATIVE_P (bigy)));
    880881  /* 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);
    883884  C_return_bignum(k, bignum_multiply_unsigned(bigx, bigy, neg_p));
    884885}
     
    10501051#define product_high carry
    10511052  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));
    10531054  while (scan < end)
    10541055    {
     
    10661067     never happen.
    10671068   */
    1068   BIGNUM_ASSERT (carry == 0);
     1069  assert(carry == 0);
    10691070  return;
    10701071#undef product_high
     
    11181119  bignum_type u = (bignum_allocate (length_n, r_negative_p));
    11191120  int shift = 0;
    1120   BIGNUM_ASSERT (length_d > 1);
     1121  assert(length_d > 1);
    11211122  {
    11221123    bignum_digit_type v1 = (BIGNUM_REF ((denominator), (length_d - 1)));
     
    13891390    (*scan_target) = carry;
    13901391  else
    1391     BIGNUM_ASSERT (carry == 0);
     1392    assert(carry == 0);
    13921393  return;
    13931394}
     
    14251426      carry = ((digit & mask) << shift_left);
    14261427    }
    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);
    14301431  BIGNUM_SET_HEADER
    14311432    (bignum, length, (BIGNUM_NEGATIVE_P (bignum)));
     
    15981599  bignum_digit_type * start = (BIGNUM_START_PTR (bignum));
    15991600  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));
    16011602  while (start < scan)
    16021603    {
     
    16201621  bignum_digit_type * scan = (start + (BIGNUM_LENGTH (n)));
    16211622  bignum_digit_type r = 0;
    1622   BIGNUM_ASSERT ((d > 1) && (d < BIGNUM_RADIX_ROOT));
     1623  assert((d > 1) && (d < BIGNUM_RADIX_ROOT));
    16231624  while (start < scan)
    16241625    {
     
    17761777      {
    17771778        bignum_type quotient;
    1778         BIGNUM_ASSERT(BIGNUM_LENGTH(denominator) > 1);
     1779        assert(BIGNUM_LENGTH(denominator) > 1);
    17791780        bignum_divide_unsigned_large_denominator
    17801781          (numerator, denominator, (&quotient), ((bignum_type *) 0), neg_p, 0);
     
    18021803       C_kontinue(k, C_fix(0));
    18031804     /* 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);
    18051806     
    18061807     bigy = bignum_allocate_from_fixnum(y);
     
    20492050
    20502051  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 */
    20522053
    20532054  if (n > 0) {
     
    23012302  radix = C_unfix(radix);
    23022303 
    2303   BIGNUM_ASSERT ((radix > 1) && (radix <= BIGNUM_RADIX_ROOT));
     2304  assert((radix > 1) && (radix <= BIGNUM_RADIX_ROOT));
    23042305  if (! (BIGNUM_ZERO_P (bignum)))
    23052306    {
     
    23612362   (((x) >= (int)'a') ?((x) - (int)'a' + 10) : ((x) - (int)'0')))
    23622363
    2363   BIGNUM_ASSERT ((radix > 1) && (radix < BIGNUM_RADIX_ROOT));
     2364  assert((radix > 1) && (radix < BIGNUM_RADIX_ROOT));
    23642365  if (n_digits == 0)
    23652366    C_kontinue(k, C_SCHEME_FALSE);
Note: See TracChangeset for help on using the changeset viewer.