Changeset 32721 in project


Ignore:
Timestamp:
08/21/15 17:26:25 (4 years ago)
Author:
sjamaan
Message:

numbers: Convert unary CPS procedures and calls to support argvector

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

Legend:

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

    r32720 r32721  
    874874}
    875875
    876 void C_ccall
    877 C_basic_abs(C_word c, C_word self, C_word k, C_word x)
    878 {
     876void C_ccall CPS_PROC1(C_basic_abs, c, self, k, x)
     877{
     878  CPS_BODY1(c, self, k, x);
    879879  if (c != 3) {
    880880    C_bad_argc_2(c, 3, self);
     
    888888    C_kontinue(k, C_a_i_flonum_abs(&a, 1, x));
    889889  } else if (C_IS_BIGNUM_TYPE(x)) {
    890     C_u_integer_abs(3, (C_word)NULL, k, x);
     890    CPS_CALL(C_u_integer_abs, 3, (C_word)NULL, k, x);
    891891  } else {
    892892    try_extended_number("numbers#@extended-abs", 2, k, x);
     
    894894}
    895895
    896 void C_ccall
    897 C_u_integer_abs(C_word c, C_word self, C_word k, C_word x)
    898 {
     896void C_ccall CPS_PROC1(C_u_integer_abs, c, self, k, x)
     897{
     898  CPS_BODY1(c, self, k, x);
    899899  if (x & C_FIXNUM_BIT) {
    900900    C_word *a = C_alloc(C_SIZEOF_FIX_BIGNUM);
    901901    C_kontinue(k, C_a_u_i_fixnum_abs(&a, 1, x));
    902902  } else if (C_bignum_negativep(x)) {
    903     C_u_integer_negate(3, (C_word)NULL, k, x);
     903    CPS_CALL(C_u_integer_negate, 3, (C_word)NULL, k, x);
    904904  } else {
    905905    C_kontinue(k, x);
     
    907907}
    908908
    909 void C_ccall
    910 C_basic_signum(C_word c, C_word self, C_word k, C_word x)
    911 {
     909void C_ccall CPS_PROC1(C_basic_signum, c, self, k, x)
     910{
     911  CPS_BODY1(c, self, k, x);
    912912  if (c != 3) {
    913913    C_bad_argc_2(c, 3, self);
     
    984984}
    985985
    986 void C_ccall
    987 C_basic_negate(C_word c, C_word self, C_word k, C_word x)
    988 {
     986void C_ccall CPS_PROC1(C_basic_negate, c, self, k, x)
     987{
     988  CPS_BODY1(c, self, k, x);
    989989  if (x & C_FIXNUM_BIT) {
    990990    C_word *a = C_alloc(C_SIZEOF_FIX_BIGNUM);
     
    996996    C_kontinue(k, C_a_i_flonum_negate(&a, 1, x));
    997997  } else if (C_IS_BIGNUM_TYPE(x)) {
    998     C_u_integer_negate(3, (C_word)NULL, k, x);
     998    CPS_CALL(C_u_integer_negate, 3, (C_word)NULL, k, x);
    999999  } else {
    10001000    try_extended_number("numbers#@extended-negate", 2, k, x);
     
    10021002}
    10031003
    1004 void C_ccall
    1005 C_u_integer_negate(C_word c, C_word self, C_word k, C_word x)
    1006 {
     1004void C_ccall CPS_PROC1(C_u_integer_negate, c, self, k, x)
     1005{
     1006  CPS_BODY1(c, self, k, x);
    10071007  if (x & C_FIXNUM_BIT) {
    10081008    C_word *a = C_alloc(C_SIZEOF_FIX_BIGNUM);
     
    18801880    C_kontinue(k, x);
    18811881  } else if (y == C_fix(-1)) {
    1882     C_u_integer_negate(3, (C_word)NULL, k, x);
     1882    CPS_CALL(C_u_integer_negate, 3, (C_word)NULL, k, x);
    18831883  } else if (y & C_FIXNUM_BIT) { /* Any other fixnum */
    18841884    C_word absy = (y & C_INT_SIGN_BIT) ? -C_unfix(y) : C_unfix(y),
     
    24672467}
    24682468
    2469 void C_ccall
    2470 C_u_flo_to_int(C_word c, C_word self, C_word k, C_word x)
    2471 {
     2469void C_ccall CPS_PROC1(C_u_flo_to_int, c, self, k, x)
     2470{
     2471  CPS_BODY1(c, self, k, x);
    24722472  int exponent;
    24732473  double significand = frexp(C_flonum_magnitude(x), &exponent);
     
    27152715}
    27162716
    2717 void C_ccall
    2718 C_u_integer_random(C_word c, C_word self, C_word k, C_word max)
    2719 {
     2717void C_ccall CPS_PROC1(C_u_integer_random, c, self, k, max)
     2718{
     2719  CPS_BODY1(c, self, k, max);
    27202720  /* TODO: for consistency C_random_fixnum should be called C_u_i_fixnum_random */
    27212721  if (max & C_FIXNUM_BIT) {
     
    31303130    } else if (y == C_fix(-1)) {
    31313131      C_word *ka, k2;
    3132       ka = C_alloc(C_SIZEOF_CLOSURE(4));     
     3132      ka = C_alloc(C_SIZEOF_CLOSURE(4));
    31333133      k2 = C_closure(&ka, 4, (C_word)bignum_divrem_fixnum_2,
    31343134                     k, return_q, return_r);
    3135       C_u_integer_negate(3, (C_word)NULL, k2, x);
     3135      CPS_CALL(C_u_integer_negate, 3, (C_word)NULL, k2, x);
    31363136    } else if (C_fitsinbignumhalfdigitp(absy) ||
    31373137               ((((C_uword)1 << (C_ilen(absy)-1)) == absy) &&
  • release/4/numbers/trunk/numbers-c.h

    r32720 r32721  
    2424# define CONT_BODY(s, a1) C_word s = __av[0]; C_word a1 = __av[1];
    2525# define CONT_PROC(name, c, s, a1)   name(C_word c, C_word *__av)
     26/* cpsproc() can't easily be used in prototype and definition */
     27# define CPS_PROC1(name, c, s, k, a1) name(C_word c, C_word *__av)
     28# define CPS_PROC2(name, c, s, k, a1, a2) name(C_word c, C_word *__av)
     29# define CPS_BODY1(c, s, k, a1) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0;
     30# define CPS_BODY2(c, s, k, a1, a2) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0; C_word a2 = c >= 2 ? __av[3] : 0;
     31# define CPS_CALL(fn, c, s, k, ...) do { C_word avk[] = {s,k,__VA_ARGS__}; fn(c, avk); } while(0)
    2632#else
    2733# define C_kontinue2(k, r1, r2) C_values(4,C_SCHEME_UNDEFINED,k,r1,r2)
    2834# define CONT_BODY(s, a1) /* Nothing */
    2935# define CONT_PROC(name, c, s, a1)   name(C_word c, C_word s, C_word a1)
     36# define CPS_PROC1(name, c, s, k, a1) name(C_word c, C_word s, C_word k, C_word a1)
     37# define CPS_PROC2(name, c, s, k, a1, a2) name(C_word c, C_word s, C_word k, C_word a1, C_word a2)
     38# define CPS_BODY1(c, s, k, a1) /* Nothing */
     39# define CPS_BODY2(c, s, k, a1, a2) /* Nothing */
     40# define CPS_CALL(fn, c, s, k, ...)  fn(c, s, k, __VA_ARGS__);
    3041#endif
    3142
     
    142153void C_ccall C_u_2_integer_plus(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    143154
    144 void C_ccall C_basic_abs(C_word c, C_word self, C_word k, C_word x) C_noret;
    145 void C_ccall C_u_integer_abs(C_word c, C_word self, C_word k, C_word x) C_noret;
    146 
    147 void C_ccall C_basic_signum(C_word c, C_word self, C_word k, C_word x) C_noret;
     155void C_ccall CPS_PROC1(C_basic_abs, c, self, k, x) C_noret;
     156void C_ccall CPS_PROC1(C_u_integer_abs, c, self, k, x) C_noret;
     157
     158void C_ccall CPS_PROC1(C_basic_signum, c, self, k, x) C_noret;
    148159C_regparm C_word C_fcall C_u_i_integer_signum(C_word x);
    149160
    150 void C_ccall C_basic_negate(C_word c, C_word self, C_word k, C_word x) C_noret;
    151 void C_ccall C_u_integer_negate(C_word c, C_word self, C_word k, C_word x) C_noret;
     161void C_ccall CPS_PROC1(C_basic_negate, c, self, k, x) C_noret;
     162void C_ccall CPS_PROC1(C_u_integer_negate, c, self, k, x) C_noret;
    152163C_regparm C_word C_fcall C_a_u_i_fixnum_negate(C_word **ptr, C_word n, C_word x);
    153164
     
    198209
    199210C_regparm C_word C_ccall C_u_i_integer_randomize(C_word seed);
    200 void C_ccall C_u_integer_random(C_word c, C_word self, C_word k, C_word max) C_noret;
     211void C_ccall CPS_PROC1(C_u_integer_random, c, self, k, max) C_noret;
    201212
    202213void C_ccall C_digits_to_integer(C_word c, C_word self, C_word k, C_word n, C_word start, C_word end, C_word radix, C_word negp) C_noret;
     
    206217void C_ccall C_u_integer_to_string(C_word c, C_word self, C_word k, C_word num, C_word radix) C_noret;
    207218void C_ccall C_u_fixnum_to_string(C_word c, C_word self, C_word k, C_word num, C_word radix) C_noret;
    208 void C_ccall C_u_flo_to_int(C_word c, C_word self, C_word k, C_word x) C_noret;
     219void C_ccall CPS_PROC1(C_u_flo_to_int, c, self, k, x) C_noret;
    209220C_word C_ccall C_u_i_integer_bit_setp(C_word n, C_word i);
    210221C_word C_ccall C_u_i_integer_length(C_word x);
Note: See TracChangeset for help on using the changeset viewer.