Changeset 32727 in project


Ignore:
Timestamp:
08/21/15 20:39:49 (4 years ago)
Author:
sjamaan
Message:

numbers: Convert variadic procedures to work with argvector as well

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

Legend:

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

    r32725 r32727  
    9494static C_regparm void integer_divrem(C_word k, C_word x, C_word y, C_word return_q, C_word return_r) C_noret;
    9595static C_regparm void bignum_divrem(C_word k, C_word x, C_word y, C_word return_q, C_word return_r) C_noret;
    96 static void divrem_intflo_2(C_word c, C_word self, ...) C_noret;
     96static void CONT_PROCN(divrem_intflo_2, c, self) C_noret;
    9797static void CONT_PROC(bignum_divrem_fixnum_2, c, self, negated_big) C_noret;
    9898static C_word bignum_remainder_unsigned_halfdigit(C_word num, C_word den);
     
    10411041
    10421042/* TODO: Rename to C_nequalp */
    1043 void C_ccall C_numbers_nequalp(C_word c, C_word self, C_word k, ...)
    1044 {
     1043void C_ccall CPS_PROCN(C_numbers_nequalp, c, self, k)
     1044{
     1045  CPS_BODYN(c, self, k);
    10451046  C_word x, y, result;
     1047#ifdef ARGVECTOR_CHICKEN
     1048  int i = 2;
     1049#else
    10461050  va_list v;
     1051#endif
    10471052
    10481053  if (c < 4) C_bad_argc_2(c, 4, self);
    10491054
    10501055  c -= 2;
     1056#ifdef ARGVECTOR_CHICKEN
     1057  x = __av[i++];
     1058#else
    10511059  va_start(v, k);
    1052 
    10531060  x = va_arg(v, C_word);
     1061#endif
     1062
    10541063  while(--c) {
     1064#ifdef ARGVECTOR_CHICKEN
     1065    y = __av[i++];
     1066#else
    10551067    y = va_arg(v, C_word);
     1068#endif
    10561069    result = C_i_2_basic_equalp(x, y);
    10571070    if (result == C_SCHEME_FALSE) break;
    10581071  }
    10591072
     1073#ifndef ARGVECTOR_CHICKEN
    10601074  va_end(v);
     1075#endif
    10611076  C_kontinue(k, result);
    10621077}
     
    12681283
    12691284/* TODO: Rename to C_lessp */
    1270 void C_ccall C_numbers_lessp(C_word c, C_word self, C_word k, ...)
    1271 {
     1285void C_ccall CPS_PROCN(C_numbers_lessp, c, self, k)
     1286{
     1287  CPS_BODYN(c, self, k);
    12721288  C_word x, y, result;
     1289#ifdef ARGVECTOR_CHICKEN
     1290  int i = 2;
     1291#else
    12731292  va_list v;
    1274 
     1293#endif
     1294 
    12751295  if (c < 4) C_bad_argc_2(c, 4, self);
    12761296
    12771297  c -= 2;
     1298#ifdef ARGVECTOR_CHICKEN
     1299  x = __av[i++];
     1300#else
    12781301  va_start(v, k);
    1279 
    12801302  x = va_arg(v, C_word);
     1303#endif
     1304
    12811305  while(--c) {
     1306#ifdef ARGVECTOR_CHICKEN
     1307    y = __av[i++];
     1308#else
    12821309    y = va_arg(v, C_word);
     1310#endif
    12831311    result = C_i_2_basic_lessp(x, y);
    12841312    if (result == C_SCHEME_FALSE) break;
     
    12861314  }
    12871315
     1316#ifndef ARGVECTOR_CHICKEN
    12881317  va_end(v);
     1318#endif
    12891319  C_kontinue(k, result);
    12901320}
    12911321
    12921322/* TODO: Rename to C_less_or_equal_p */
    1293 void C_ccall C_numbers_less_or_equal_p(C_word c, C_word self, C_word k, ...)
    1294 {
     1323void C_ccall CPS_PROCN(C_numbers_less_or_equal_p, c, self, k)
     1324{
     1325  CPS_BODYN(c, self, k);
    12951326  C_word x, y, result;
     1327#ifdef ARGVECTOR_CHICKEN
     1328  int i = 2;
     1329#else
    12961330  va_list v;
     1331#endif
    12971332
    12981333  if (c < 4) C_bad_argc_2(c, 4, self);
    12991334
    13001335  c -= 2;
     1336#ifdef ARGVECTOR_CHICKEN
     1337  x = __av[i++];
     1338#else
    13011339  va_start(v, k);
    1302 
    13031340  x = va_arg(v, C_word);
     1341#endif
     1342
    13041343  while(--c) {
     1344#ifdef ARGVECTOR_CHICKEN
     1345    y = __av[i++];
     1346#else
    13051347    y = va_arg(v, C_word);
     1348#endif
    13061349    result = C_i_2_basic_less_or_equalp(x, y);
    13071350    if (result == C_SCHEME_FALSE) break;
     
    13091352  }
    13101353
     1354#ifndef ARGVECTOR_CHICKEN
    13111355  va_end(v);
     1356#endif
    13121357  C_kontinue(k, result);
    13131358}
     
    13581403
    13591404/* TODO: Rename to C_greater_p */
    1360 void C_ccall C_numbers_greaterp(C_word c, C_word self, C_word k, ...)
    1361 {
     1405void C_ccall CPS_PROCN(C_numbers_greaterp, c, self, k)
     1406{
     1407  CPS_BODYN(c, self, k);
    13621408  C_word x, y, result;
     1409#ifdef ARGVECTOR_CHICKEN
     1410  int i = 2;
     1411#else
    13631412  va_list v;
     1413#endif
    13641414
    13651415  if (c < 4) C_bad_argc_2(c, 4, self);
    13661416
    13671417  c -= 2;
     1418#ifdef ARGVECTOR_CHICKEN
     1419  x = __av[i++];
     1420#else
    13681421  va_start(v, k);
    1369 
    13701422  x = va_arg(v, C_word);
     1423#endif
     1424
    13711425  while(--c) {
     1426#ifdef ARGVECTOR_CHICKEN
     1427    y = __av[i++];
     1428#else
    13721429    y = va_arg(v, C_word);
     1430#endif
    13731431    result = C_i_2_basic_greaterp(x, y);
    13741432    if (result == C_SCHEME_FALSE) break;
     
    13761434  }
    13771435
     1436#ifndef ARGVECTOR_CHICKEN
    13781437  va_end(v);
     1438#endif
    13791439  C_kontinue(k, result);
    13801440}
    13811441
    13821442/* TODO: Rename to C_greater_or_equal_p */
    1383 void C_ccall C_numbers_greater_or_equal_p(C_word c, C_word self, C_word k, ...)
    1384 {
     1443void C_ccall CPS_PROCN(C_numbers_greater_or_equal_p, c, self, k)
     1444{
     1445  CPS_BODYN(c, self, k);
    13851446  C_word x, y, result;
     1447#ifdef ARGVECTOR_CHICKEN
     1448  int i = 2;
     1449#else
    13861450  va_list v;
     1451#endif
    13871452
    13881453  if (c < 4) C_bad_argc_2(c, 4, self);
    13891454
    13901455  c -= 2;
     1456#ifdef ARGVECTOR_CHICKEN
     1457  x = __av[i++];
     1458#else
    13911459  va_start(v, k);
    1392 
    13931460  x = va_arg(v, C_word);
     1461#endif
     1462
    13941463  while(--c) {
     1464#ifdef ARGVECTOR_CHICKEN
     1465    y = __av[i++];
     1466#else
    13951467    y = va_arg(v, C_word);
     1468#endif
    13961469    result = C_i_2_basic_greater_or_equalp(x, y);
    13971470    if (result == C_SCHEME_FALSE) break;
     
    13991472  }
    14001473
     1474#ifndef ARGVECTOR_CHICKEN
    14011475  va_end(v);
     1476#endif
    14021477  C_kontinue(k, result);
    14031478}
     
    30693144}
    30703145
    3071 static void divrem_intflo_2(C_word c, C_word self, ...)
    3072 {
     3146static void CONT_PROCN(divrem_intflo_2, c, self)
     3147{
     3148  CONT_BODYN(c, self);
    30733149  C_word k = C_block_item(self, 1), x, y;
     3150#ifndef ARGVECTOR_CHICKEN
    30743151  va_list v;
     3152#endif
    30753153
    30763154  free_tmp_bignum(C_block_item(self, 2));
    30773155 
     3156#ifndef ARGVECTOR_CHICKEN
    30783157  va_start(v, self);
     3158#endif
    30793159  if (c == 2) {
    30803160    C_word ab[C_SIZEOF_FLONUM], *a = ab;
     3161#ifdef ARGVECTOR_CHICKEN
     3162    x = __av[1];
     3163#else
    30813164    x = va_arg(v, C_word);
    30823165    va_end(v);
     3166#endif
    30833167    if (x & C_FIXNUM_BIT) x = C_a_i_fix_to_flo(&a, 1, x);
    30843168    else x = C_a_u_i_big_to_flo(&a, 1, x);
     
    30863170  } else { /* c == 3 */
    30873171    C_word ab[C_SIZEOF_FLONUM*2], *a = ab;
     3172#ifdef ARGVECTOR_CHICKEN
     3173    x = __av[1];
     3174    y = __av[2];
     3175#else
    30883176    x = va_arg(v, C_word);
    30893177    y = va_arg(v, C_word);
    30903178    va_end(v);
    3091 
     3179#endif
     3180   
    30923181    if (x & C_FIXNUM_BIT) x = C_a_i_fix_to_flo(&a, 1, x);
    30933182    else x = C_a_u_i_big_to_flo(&a, 1, x);
  • release/4/numbers/trunk/numbers-c.h

    r32725 r32727  
    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# define CONT_BODYN(c, s) C_word s = __av[0];
     27# define CONT_PROCN(name, c, s)   name(C_word c, C_word *__av)
    2628/* cpsproc() can't easily be used in prototype and definition */
    2729# define CPS_PROC1(name, c, s, k, a1) name(C_word c, C_word *__av)
     
    3032# define CPS_PROC4(name, c, s, k, a1, a2, a3, a4) name(C_word c, C_word *__av)
    3133# define CPS_PROC5(name, c, s, k, a1, a2, a3, a4, a5) name(C_word c, C_word *__av)
     34# define CPS_PROCN(name, c, s, k) name(C_word c, C_word *__av)
    3235# define CPS_PROCNPLUS1(name, c, s, k, a1) name(C_word c, C_word *__av)
    3336/* Excuse the mess */
     
    3841# define CPS_BODY5(c, s, k, a1, a2, a3, a4, a5) 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; C_word a3 = c >= 3 ? __av[4] : 0; C_word a4 = c >= 4 ? __av[5] : 0; C_word a5 = c >= 5 ? __av[6] : 0;
    3942# define CPS_BODYNPLUS1(c, s, k, a1) C_word s = __av[0]; C_word k = __av[1]; C_word a1 = c >= 1 ? __av[2] : 0;
     43# define CPS_BODYN(c, s, k) C_word s = __av[0]; C_word k = __av[1];
    4044# define CPS_CALL(fn, c, s, k, ...) do { C_word avk[] = {s,k,__VA_ARGS__}; fn(c, avk); } while(0)
    4145
     
    4549# define CONT_BODY(s, a1) /* Nothing */
    4650# define CONT_PROC(name, c, s, a1)   name(C_word c, C_word s, C_word a1)
     51# define CONT_BODYN(c, s) /* Nothing */
     52# define CONT_PROCN(name, c, s)   name(C_word c, C_word s, ...)
    4753# define CPS_PROC1(name, c, s, k, a1) name(C_word c, C_word s, C_word k, C_word a1)
    4854# 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)
     
    5056# define CPS_PROC4(name, c, s, k, a1, a2, a3, a4) name(C_word c, C_word s, C_word k, C_word a1, C_word a2, C_word a3, C_word a4, C_word a5)
    5157# define CPS_PROC5(name, c, s, k, a1, a2, a3, a4, a5) name(C_word c, C_word s, C_word k, C_word a1, C_word a2, C_word a3, C_word a4, C_word a5)
     58# define CPS_PROCN(name, c, s, k) name(C_word c, C_word s, C_word k, ...)
    5259# define CPS_PROCNPLUS1(name, c, s, k, a1) name(C_word c, C_word s, C_word k, C_word a1, ...)
    5360# define CPS_BODY1(c, s, k, a1) /* Nothing */
     
    5663# define CPS_BODY4(c, s, k, a1, a2, a3, a4) /* Nothing */
    5764# define CPS_BODY5(c, s, k, a1, a2, a3, a4, a5) /* Nothing */
     65# define CPS_BODYN(c, s, k) /* Nothing */
    5866# define CPS_BODYNPLUS1(c, s, k, a1) /* Nothing */
    5967# define CPS_CALL(fn, c, s, k, ...)  fn(c, s, k, __VA_ARGS__);
     
    198206void C_ccall CPS_PROC2(C_u_integer_divrem, c, self, k, x, y) C_noret;
    199207
    200 void C_ccall C_numbers_nequalp(C_word c, C_word self, C_word k, ...) C_noret;
     208void C_ccall CPS_PROCN(C_numbers_nequalp, c, self, k) C_noret;
    201209C_regparm C_word C_fcall C_i_2_basic_equalp(C_word x, C_word y);
    202210C_word C_ccall C_u_i_2_integer_equalp(C_word x, C_word y);
    203 void C_ccall C_numbers_lessp(C_word c, C_word self, C_word k, ...) C_noret;
     211void C_ccall CPS_PROCN(C_numbers_lessp, c, self, k) C_noret;
    204212C_regparm C_word C_fcall C_i_2_basic_lessp(C_word x, C_word y);
    205213C_word C_ccall C_u_i_2_integer_lessp(C_word x, C_word y);
    206 void C_ccall C_numbers_less_or_equalp(C_word c, C_word self, C_word k, ...) C_noret;
     214void C_ccall CPS_PROCN(C_numbers_less_or_equalp, c, self, k) C_noret;
    207215C_regparm C_word C_fcall C_i_2_basic_less_or_equalp(C_word x, C_word y);
    208216C_word C_ccall C_u_i_2_integer_or_equal_p(C_word x, C_word y);
    209 void C_ccall C_numbers_greaterp(C_word c, C_word self, C_word k, ...) C_noret;
     217void C_ccall CPS_PROCN(C_numbers_greaterp, c, self, k) C_noret;
    210218C_regparm C_word C_fcall C_i_2_basic_greaterp(C_word x, C_word y);
    211219C_word C_ccall C_u_i_2_integer_greaterp(C_word x, C_word y);
    212 void C_ccall C_numbers_greater_or_equal_p(C_word c, C_word self, C_word k, ...) C_noret;
     220void C_ccall CPS_PROCN(C_numbers_greater_or_equal_p, c, self, k) C_noret;
    213221C_regparm C_word C_fcall C_i_2_basic_greater_or_equalp(C_word x, C_word y);
    214222C_word C_ccall C_u_i_2_integer_or_equalp(C_word x, C_word y);
Note: See TracChangeset for help on using the changeset viewer.