Changeset 31287 in project


Ignore:
Timestamp:
08/25/14 19:40:39 (7 years ago)
Author:
sjamaan
Message:

numbers: Convert negative? and odd? for bignums to the new naming conventions

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

Legend:

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

    r31286 r31287  
    4646#define fix_to_flo(p, n, f)       C_flonum(p, C_unfix(f))
    4747#define big_of(v)                 ((bignum_type)C_data_pointer(C_block_item(v, 1)))
    48 #define big_negp(b)               C_mk_bool(BIGNUM_NEGATIVE_P(big_of(b)))
    49 #define big_oddp(b)               C_mk_bool(BIGNUM_REF(big_of(b), 0) & 1)
    5048
    5149static C_word
  • release/4/numbers/trunk/numbers-c.h

    r31286 r31287  
    164164#define C_SIZEOF_STRUCTURE(n)           ((n)+2) /* missing from chicken.h */
    165165#define C_SIZEOF_BIGNUM(n)              (C_SIZEOF_VECTOR((n)+1)+C_SIZEOF_STRUCTURE(2))
    166 #define C_a_i_bignum2(a,n,negp,d1,d2)   C_bignum2((a),(n),C_truep(negp),(C_uword)C_unfix(d1),(C_uword)C_unfix(d2))
    167166
    168167/* CHAR_BIT is from <limits.h>, and it equals the number of bits in a char */
     
    179178#endif
    180179
     180#define C_a_i_bignum2(a,n,negp,d1,d2)   C_bignum2((a),(n),C_truep(negp),(C_uword)C_unfix(d1),(C_uword)C_unfix(d2))
     181
     182#define C_bignum_header(b)              (*(C_word *)C_data_pointer(C_block_item(b,1)))
     183#define C_bignum_digits(b)              (((C_word *)C_data_pointer(C_block_item(b,1)))+1)
     184#define C_u_i_bignum_negativep(b)       C_mk_bool(C_bignum_header(b) & C_BIGNUM_HEADER_SIGN_BIT)
     185#define C_u_i_bignum_oddp(b)            C_mk_bool(C_bignum_digits(b)[0] & 1)
     186
    181187/* TODO: low to high, or high to low? (ie, big or little endian?) */
    182188C_inline C_word C_bignum2(C_word **ptr, int negp, C_uword d1, C_uword d2)
  • release/4/numbers/trunk/numbers.scm

    r31285 r31287  
    173173(define %big-abs (##core#primitive "big_abs"))
    174174
    175 (define-inline (%big-odd? x) (##core#inline "big_oddp" x))
    176 (define-inline (%big-negative? x) (##core#inline "big_negp" x))
     175(define-inline (%big-odd? x) (##core#inline "C_u_i_bignum_oddp" x))
     176(define-inline (%big-negative? x) (##core#inline "C_u_i_bignum_negativep" x))
    177177
    178178(define %%expt-0 (##core#primitive "C_expt"))
Note: See TracChangeset for help on using the changeset viewer.