Changeset 31308 in project


Ignore:
Timestamp:
08/29/14 20:48:26 (5 years ago)
Author:
sjamaan
Message:

numbers: Add missing forward declaration for bignum_digits_destructive_scale_up and rename C_u_i_bignum_size to C_bignum_size and make it return an integer that isn't wrapped as a fixnum

Location:
release/4/numbers/trunk
Files:
2 edited

Legend:

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

    r31304 r31308  
    22522252static void bignum_negate_2(C_word c, C_word self, C_word new_big);
    22532253static void allocate_bignum_2(C_word c, C_word self, C_word bigvec);
     2254static void bignum_digits_destructive_scale_up(C_word big, C_word fix_factor);
    22542255static void bignum_times_halfdigit_fixnum(C_word k, C_word bigx, C_word fixy, C_word negp);
    22552256static void bignum_times_halfdigit_fixnum_2(C_word c, C_word self, C_word new_big);
     
    23202321  k2 = C_closure(&ka, 3, (C_word)bignum_negate_2, k, x);
    23212322 
    2322   size = C_u_i_bignum_size(x);
     2323  size = C_fix(C_bignum_size(x));
    23232324  C_allocate_bignum(3, (C_word)NULL, k2, size, negp, C_SCHEME_FALSE);
    23242325}
     
    23722373{
    23732374  C_word *start = C_bignum_digits(big);
    2374   C_word *last_digit = start + C_unfix(C_u_i_bignum_size(big));
     2375  C_word *last_digit = start + C_bignum_size(big);
    23752376  C_word *scan = last_digit;
    23762377
     
    23922393C_bignum_normalize(C_word big)
    23932394{
    2394   switch (C_u_i_bignum_size(big)) {
    2395   case C_fix(0):
     2395  switch (C_bignum_size(big)) {
     2396  case 0:
    23962397    return C_fix(0);
    2397   case C_fix(1):
     2398  case 1:
    23982399    return C_fix(C_truep(C_u_i_bignum_negativep(big)) ?
    23992400                 -C_bignum_digits(big)[0] :
    24002401                 C_bignum_digits(big)[0]);
    2401   case C_fix(2):
     2402  case 2:
    24022403    if (C_truep(C_u_i_bignum_negativep(big)) &&
    24032404        C_bignum_digits(big)[1] == 1 && C_bignum_digits(big)[0] == 0)
    24042405      return C_fix(C_MOST_NEGATIVE_FIXNUM);
    2405   }
    2406   return big;
    2407 }
    2408 
    2409 C_inline void
     2406  default:
     2407    return big;
     2408  }
     2409}
     2410
     2411static void
    24102412bignum_digits_destructive_scale_up(C_word big, C_word fix_factor)
    24112413{
    24122414  C_word digit, product_hi, product_lo, carry = 0;
    24132415  C_word *scan = C_bignum_digits(big);
    2414   C_word *last_digit = scan + C_unfix(C_u_i_bignum_size(big));
     2416  C_word *last_digit = scan + C_bignum_size(big);
    24152417  C_word factor = C_unfix(fix_factor);
    24162418
     
    24352437                 k, bigx, fixy);
    24362438
    2437   size = C_u_i_bignum_size(bigx) + 1; /* Needs _at most_ one more digit */
     2439  size = C_fix(C_bignum_size(bigx) + 1); /* Needs _at most_ one more digit */
    24382440  C_allocate_bignum(3, (C_word)NULL, k2, size, negp, C_SCHEME_FALSE);
    24392441}
     
    24542456
    24552457  /* Most significant digit is not initialised; set it to 0. */
    2456   C_bignum_digits(new_big)[C_unfix(C_u_i_bignum_size(old_bigx))] = 0;
     2458  C_bignum_digits(new_big)[C_bignum_size(old_bigx)] = 0;
    24572459
    24582460  /* Scale up, and sanitise the result. TODO: make normalization one op? */
  • release/4/numbers/trunk/numbers-c.h

    r31304 r31308  
    204204 * So, for now we'll live with back and forth byte<->word conversion.
    205205 */
    206 #define C_u_i_bignum_size(b)            (C_fix(C_bytestowords(C_header_size(C_internal_bignum(b)))-1))
     206#define C_bignum_size(b)                (C_bytestowords(C_header_size(C_internal_bignum(b)))-1)
    207207
    208208void C_ccall C_allocate_bignum(C_word c, C_word self, C_word k, C_word size, C_word negp, C_word initp);
Note: See TracChangeset for help on using the changeset viewer.