Changeset 32725 in project


Ignore:
Timestamp:
08/21/15 19:59:38 (5 years ago)
Author:
sjamaan
Message:

numbers: Convert remaining simple (non-vararg) functions to work with argvector and non-argvector CHICKENs

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

Legend:

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

    r32724 r32725  
    507507}
    508508
    509 void C_ccall
    510 C_2_basic_plus(C_word c, C_word self, C_word k, C_word x, C_word y)
    511 {
     509void C_ccall CPS_PROC2(C_2_basic_plus, c, self, k, x, y)
     510{
     511  CPS_BODY2(c, self, k, x, y);
    512512  if (x & C_FIXNUM_BIT) {
    513513    if (y & C_FIXNUM_BIT) {
     
    520520      C_kontinue(k, C_flonum(&a, (double)C_unfix(x) + C_flonum_magnitude(y)));
    521521    } else if (C_IS_BIGNUM_TYPE(y)) {
    522       C_u_2_integer_plus(4, (C_word)NULL, k, x, y);
     522      CPS_CALL(C_u_2_integer_plus, 4, (C_word)NULL, k, x, y);
    523523    } else {
    524524      try_extended_number("numbers#@extended-2-plus", 3, k, x, y);
     
    541541  } else if (C_IS_BIGNUM_TYPE(x)) {
    542542    if (y & C_FIXNUM_BIT) {
    543       C_u_2_integer_plus(4, (C_word)NULL, k, x, y);
     543      CPS_CALL(C_u_2_integer_plus, 4, (C_word)NULL, k, x, y);
    544544    } else if (C_immediatep(y)) {
    545545      barf(C_BAD_ARGUMENT_TYPE_NO_NUMBER_ERROR, "+", y);
     
    548548      C_kontinue(k, C_flonum(&a, C_bignum_to_double(x)+C_flonum_magnitude(y)));
    549549    } else if (C_IS_BIGNUM_TYPE(y)) {
    550       C_u_2_integer_plus(4, (C_word)NULL, k, x, y);
     550      CPS_CALL(C_u_2_integer_plus, 4, (C_word)NULL, k, x, y);
    551551    } else {
    552552      try_extended_number("numbers#@extended-2-plus", 3, k, x, y);
     
    557557}
    558558
    559 void C_ccall
    560 C_u_2_integer_plus(C_word c, C_word self, C_word k, C_word x, C_word y)
    561 {
     559void C_ccall CPS_PROC2(C_u_2_integer_plus, c, self, k, x, y)
     560{
     561  CPS_BODY2(c, self, k, x, y);
    562562  if ((x & y) & C_FIXNUM_BIT) {
    563563    C_word ab[C_SIZEOF_FIX_BIGNUM], *a = ab;
     
    598598}
    599599
    600 void C_ccall
    601 C_2_basic_minus(C_word c, C_word self, C_word k, C_word x, C_word y)
    602 {
     600void C_ccall CPS_PROC2(C_2_basic_minus, c, self, k, x, y)
     601{
     602  CPS_BODY2(c, self, k, x, y);
    603603  if (x & C_FIXNUM_BIT) {
    604604    if (y & C_FIXNUM_BIT) {
     
    611611      C_kontinue(k, C_flonum(&a, (double)C_unfix(x) - C_flonum_magnitude(y)));
    612612    } else if (C_IS_BIGNUM_TYPE(y)) {
    613       C_u_2_integer_minus(4, (C_word)NULL, k, x, y);
     613      CPS_CALL(C_u_2_integer_minus, 4, (C_word)NULL, k, x, y);
    614614    } else {
    615615      try_extended_number("numbers#@extended-2-minus", 3, k, x, y);
     
    632632  } else if (C_IS_BIGNUM_TYPE(x)) {
    633633    if (y & C_FIXNUM_BIT) {
    634       C_u_2_integer_minus(4, (C_word)NULL, k, x, y);
     634      CPS_CALL(C_u_2_integer_minus, 4, (C_word)NULL, k, x, y);
    635635    } else if (C_immediatep(y)) {
    636636      barf(C_BAD_ARGUMENT_TYPE_NO_NUMBER_ERROR, "-", y);
     
    639639      C_kontinue(k, C_flonum(&a, C_bignum_to_double(x)-C_flonum_magnitude(y)));
    640640    } else if (C_IS_BIGNUM_TYPE(y)) {
    641       C_u_2_integer_minus(4, (C_word)NULL, k, x, y);
     641      CPS_CALL(C_u_2_integer_minus, 4, (C_word)NULL, k, x, y);
    642642    } else {
    643643      try_extended_number("numbers#@extended-2-minus", 3, k, x, y);
     
    648648}
    649649
    650 void C_ccall
    651 C_u_2_integer_minus(C_word c, C_word self, C_word k, C_word x, C_word y)
    652 {
     650void C_ccall CPS_PROC2(C_u_2_integer_minus, c, self, k, x, y)
     651{
     652  CPS_BODY2(c, self, k, x, y);
    653653  if ((x & y) & C_FIXNUM_BIT) {
    654654    C_word ab[C_SIZEOF_FIX_BIGNUM], *a = ab;
     
    17751775}
    17761776
    1777 void C_ccall
    1778 C_2_basic_times(C_word c, C_word self, C_word k, C_word x, C_word y)
    1779 {
     1777void C_ccall CPS_PROC2(C_2_basic_times, c, self, k, x, y)
     1778{
     1779  CPS_BODY2(c, self, k, x, y);
    17801780  if (x & C_FIXNUM_BIT) {
    17811781    if (y & C_FIXNUM_BIT) {
     
    17881788      C_kontinue(k, C_flonum(&a, (double)C_unfix(x) * C_flonum_magnitude(y)));
    17891789    } else if (C_IS_BIGNUM_TYPE(y)) {
    1790       C_u_2_integer_times(4, (C_word)NULL, k, x, y);
     1790      CPS_CALL(C_u_2_integer_times, 4, (C_word)NULL, k, x, y);
    17911791    } else {
    17921792      try_extended_number("numbers#@extended-2-times", 3, k, x, y);
     
    18091809  } else if (C_IS_BIGNUM_TYPE(x)) {
    18101810    if (y & C_FIXNUM_BIT) {
    1811       C_u_2_integer_times(4, (C_word)NULL, k, x, y);
     1811      CPS_CALL(C_u_2_integer_times, 4, (C_word)NULL, k, x, y);
    18121812    } else if (C_immediatep(y)) {
    18131813      barf(C_BAD_ARGUMENT_TYPE_NO_NUMBER_ERROR, "*", x);
     
    18161816      C_kontinue(k, C_flonum(&a, C_bignum_to_double(x)*C_flonum_magnitude(y)));
    18171817    } else if (C_IS_BIGNUM_TYPE(y)) {
    1818       C_u_2_integer_times(4, (C_word)NULL, k, x, y);
     1818      CPS_CALL(C_u_2_integer_times, 4, (C_word)NULL, k, x, y);
    18191819    } else {
    18201820      try_extended_number("numbers#@extended-2-times", 3, k, x, y);
     
    18611861}
    18621862
    1863 void C_ccall
    1864 C_u_2_integer_times(C_word c, C_word self, C_word k, C_word x, C_word y)
    1865 {
     1863void C_ccall CPS_PROC2(C_u_2_integer_times, c, self, k, x, y)
     1864{
     1865  CPS_BODY2(c, self, k, x, y);
    18661866  if (x & C_FIXNUM_BIT) {
    18671867    if (y & C_FIXNUM_BIT) {
     
    25302530}
    25312531
    2532 void C_ccall /* x is any exact integer but y is _always_ a fixnum */
    2533 C_u_integer_shift(C_word c, C_word self, C_word k, C_word x, C_word y)
    2534 {
     2532/* x is any exact integer but y is _always_ a fixnum */
     2533void C_ccall CPS_PROC2(C_u_integer_shift, c, self, k, x, y)
     2534{
     2535  CPS_BODY2(c, self, k, x, y);
    25352536  C_word ab[C_SIZEOF_FIX_BIGNUM], *a = ab;
    25362537
     
    26512652 */
    26522653void C_ccall
    2653 C_u_bignum_extract_digits(C_word c, C_word self, C_word k, C_word x, C_word start, C_word end)
    2654 {
     2654CPS_PROC3(C_u_bignum_extract_digits, c, self, k, x, start, end)
     2655{
     2656  CPS_BODY3(c, self, k, x, start, end);
    26552657  if (x & C_FIXNUM_BIT) { /* Needed? */
    26562658    if (C_unfix(start) == 0 && (end == C_SCHEME_FALSE || C_unfix(end) > 0))
     
    27982800}
    27992801
    2800 void C_ccall
    2801 C_u_2_integer_bitwise_and(C_word c, C_word self, C_word k, C_word x, C_word y)
    2802 {
     2802void C_ccall CPS_PROC2(C_u_2_integer_bitwise_and, c, self, k, x, y)
     2803{
     2804  CPS_BODY2(c, self, k, x, y);
    28032805  if ((x & y) & C_FIXNUM_BIT) {
    28042806    C_kontinue(k, C_u_fixnum_and(x, y));
     
    28532855}
    28542856
    2855 void C_ccall
    2856 C_u_2_integer_bitwise_ior(C_word c, C_word self, C_word k, C_word x, C_word y)
    2857 {
     2857void C_ccall CPS_PROC2(C_u_2_integer_bitwise_ior, c, self, k, x, y)
     2858{
     2859  CPS_BODY2(c, self, k, x, y);
    28582860  if ((x & y) & C_FIXNUM_BIT) {
    28592861    C_kontinue(k, C_u_fixnum_or(x, y));
     
    29052907}
    29062908
    2907 void C_ccall
    2908 C_u_2_integer_bitwise_xor(C_word c, C_word self, C_word k, C_word x, C_word y)
    2909 {
     2909void C_ccall CPS_PROC2(C_u_2_integer_bitwise_xor, c, self, k, x, y)
     2910{
     2911  CPS_BODY2(c, self, k, x, y);
    29102912  if ((x & y) & C_FIXNUM_BIT) {
    29112913    C_kontinue(k, C_fixnum_xor(x, y));
     
    32253227
    32263228/* External interface for the above internal divrem functions */
    3227 void C_ccall
    3228 C_basic_divrem(C_word c, C_word self, C_word k, C_word x, C_word y)
    3229 {
     3229void C_ccall CPS_PROC2(C_basic_divrem, c, self, k, x, y)
     3230{
     3231  CPS_BODY2(c, self, k, x, y);
    32303232  if (c != 4) C_bad_argc_2(c, 4, self);
    32313233  basic_divrem(k, x, y, C_SCHEME_TRUE, C_SCHEME_TRUE);
    32323234}
    32333235
    3234 void C_ccall
    3235 C_u_integer_divrem(C_word c, C_word self, C_word k, C_word x, C_word y)
    3236 {
     3236void C_ccall CPS_PROC2(C_u_integer_divrem, c, self, k, x, y)
     3237{
     3238  CPS_BODY2(c, self, k, x, y);
    32373239  integer_divrem(k, x, y, C_SCHEME_TRUE, C_SCHEME_TRUE);
    32383240}
    32393241
    3240 void C_ccall
    3241 C_basic_remainder(C_word c, C_word self, C_word k, C_word x, C_word y)
    3242 {
     3242void C_ccall CPS_PROC2(C_basic_remainder, c, self, k, x, y)
     3243{
     3244  CPS_BODY2(c, self, k, x, y);
    32433245  if (c != 4) C_bad_argc_2(c, 4, self);
    32443246  basic_divrem(k, x, y, C_SCHEME_FALSE, C_SCHEME_TRUE);
    32453247}
    32463248
    3247 void C_ccall
    3248 C_u_integer_remainder(C_word c, C_word self, C_word k, C_word x, C_word y)
    3249 {
     3249void C_ccall CPS_PROC2(C_u_integer_remainder, c, self, k, x, y)
     3250{
     3251  CPS_BODY2(c, self, k, x, y);
    32503252  integer_divrem(k, x, y, C_SCHEME_FALSE, C_SCHEME_TRUE);
    32513253}
    32523254
    3253 void C_ccall
    3254 C_basic_quotient(C_word c, C_word self, C_word k, C_word x, C_word y)
    3255 {
     3255void C_ccall CPS_PROC2(C_basic_quotient, c, self, k, x, y)
     3256{
     3257  CPS_BODY2(c, self, k, x, y);
    32563258  if (c != 4) C_bad_argc_2(c, 4, self);
    32573259  basic_divrem(k, x, y, C_SCHEME_TRUE, C_SCHEME_FALSE);
    32583260}
    32593261
    3260 void C_ccall
    3261 C_u_integer_quotient(C_word c, C_word self, C_word k, C_word x, C_word y)
    3262 {
     3262void C_ccall CPS_PROC2(C_u_integer_quotient, c, self, k, x, y)
     3263{
     3264  CPS_BODY2(c, self, k, x, y);
    32633265  integer_divrem(k, x, y, C_SCHEME_TRUE, C_SCHEME_FALSE);
    32643266}
  • release/4/numbers/trunk/numbers-c.h

    r32722 r32725  
    153153void C_ccall C_bignum_destructive_trim(C_word big);
    154154C_word C_ccall C_bignum_simplify(C_word big);
    155 void C_ccall C_u_bignum_extract_digits(C_word c, C_word self, C_word k, C_word x, C_word start, C_word end) C_noret;
     155void C_ccall CPS_PROC3(C_u_bignum_extract_digits, c, self, k, x, start, end) C_noret;
    156156
    157157C_regparm double C_bignum_to_double(C_word bignum);
     
    166166C_word C_ccall C_u_i_2_fixnum_gcd(C_word x, C_word y);
    167167C_word C_ccall C_a_u_i_2_flonum_gcd(C_word **p, C_word n, C_word x, C_word y);
    168 void C_ccall C_u_2_integer_gcd(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    169 
    170 void C_ccall C_2_basic_plus(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    171 C_regparm C_word C_fcall C_a_u_i_2_fixnum_plus(C_word **ptr, C_word n, C_word x, C_word y);
    172 void C_ccall C_u_2_integer_plus(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    173168
    174169void C_ccall CPS_PROC1(C_basic_abs, c, self, k, x) C_noret;
     
    182177C_regparm C_word C_fcall C_a_u_i_fixnum_negate(C_word **ptr, C_word n, C_word x);
    183178
    184 void C_ccall C_2_basic_minus(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
     179void C_ccall CPS_PROC2(C_2_basic_plus, c, self, k, x, y) C_noret;
     180C_regparm C_word C_fcall C_a_u_i_2_fixnum_plus(C_word **ptr, C_word n, C_word x, C_word y);
     181void C_ccall CPS_PROC2(C_u_2_integer_plus, c, self, k, x, y) C_noret;
     182
     183void C_ccall CPS_PROC2(C_2_basic_minus, c, self, k, x, y) C_noret;
    185184C_regparm C_word C_fcall C_a_u_i_2_fixnum_minus(C_word **ptr, C_word n, C_word x, C_word y);
    186 void C_ccall C_u_2_integer_minus(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    187 
    188 void C_ccall C_2_basic_times(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
     185void C_ccall CPS_PROC2(C_u_2_integer_minus, c, self, k, x, y) C_noret;
     186
     187void C_ccall CPS_PROC2(C_2_basic_times, c, self, k, x, y) C_noret;
    189188C_regparm C_word C_fcall C_a_u_i_2_fixnum_times(C_word **ptr, C_word n, C_word x, C_word y);
    190 void C_ccall C_u_2_integer_times(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    191 
    192 void C_ccall C_basic_quotient(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    193 void C_ccall C_u_integer_quotient(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    194 
    195 void C_ccall C_basic_remainder(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    196 void C_ccall C_u_integer_remainder(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    197 
    198 void C_ccall C_basic_divrem(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    199 void C_ccall C_u_integer_divrem(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
     189void C_ccall CPS_PROC2(C_u_2_integer_times, c, self, k, x, y) C_noret;
     190
     191void C_ccall CPS_PROC2(C_basic_quotient, c, self, k, x, y) C_noret;
     192void C_ccall CPS_PROC2(C_u_integer_quotient, c, self, k, x, y) C_noret;
     193
     194void C_ccall CPS_PROC2(C_basic_remainder, c, self, k, x, y) C_noret;
     195void C_ccall CPS_PROC2(C_u_integer_remainder, c, self, k, x, y) C_noret;
     196
     197void C_ccall CPS_PROC2(C_basic_divrem, c, self, k, x, y) C_noret;
     198void C_ccall CPS_PROC2(C_u_integer_divrem, c, self, k, x, y) C_noret;
    200199
    201200void C_ccall C_numbers_nequalp(C_word c, C_word self, C_word k, ...) C_noret;
     
    239238C_word C_ccall C_u_i_integer_length(C_word x);
    240239
    241 void C_ccall C_u_integer_shift(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    242 void C_ccall C_u_2_integer_bitwise_and(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    243 void C_ccall C_u_2_integer_bitwise_ior(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
    244 void C_ccall C_u_2_integer_bitwise_xor(C_word c, C_word self, C_word k, C_word x, C_word y) C_noret;
     240void C_ccall CPS_PROC2(C_u_integer_shift, c, self, k, x, y) C_noret;
     241void C_ccall CPS_PROC2(C_u_2_integer_bitwise_and, c, self, k, x, y) C_noret;
     242void C_ccall CPS_PROC2(C_u_2_integer_bitwise_ior, c, self, k, x, y) C_noret;
     243void C_ccall CPS_PROC2(C_u_2_integer_bitwise_xor, c, self, k, x, y) C_noret;
    245244
    246245/* Silly but in some cases needed */
Note: See TracChangeset for help on using the changeset viewer.