[kaffe] sysdepCallMethod test - i386 port

Sivaramakrishnan KC kaycee.srk at gmail.com
Mon Feb 25 03:55:29 PST 2008


Hi,

I have ported the sysdepCallMethod test from
http://www.kaffe.org/pipermail/kaffe/2003-May/129976.html to i386. But
i still have this doubt. What does callMethodinfo->nrargs represent?
Does it represent the number of valid arguements in
callMethodInfo->args? Because i found in i386/sysdepCallMethod.h ==>

-----------------------------------------------------------------------------------------------
unsigned args = call->nrargs;

  /* Push all arguments into the stack, in last-to-first order.  This
     assumes that the second 32bit-word of longs and doubles is
     available as an additional int argument, as callMethod[AV]() do.  */
  while (args > 0)
    asm volatile ("pushl %0" : : "m" (call->args[--args].i) : "sp");
-----------------------------------------------------------------------------------------------

Even if there is only one jdouble arguement, call->nrargs should be
2(=call->argsize) in order to push 2 32-bit values into the stack. I
have used the same value for call->nrargs and call->argsize in the
following testcase. Only then the does it work fine. Correct me if i
am wrong.

This is tested under i386/cygwin. Should work for other platforms as well.
---------------sysdepCallMethod_test_i386.c---------------------------------
#if 0
exec ${CC:-gcc} $CFLAGS -I.. -I../include -I../config
-I../kaffe/kaffevm  -I../kaffe $0 -o ${0%%.c}
#endif

#include <stdio.h>
#include <stdint.h>

/* Basic types definitions */
#include "kaffevm/gtypes.h"

#define NEED_sysdepCallMethod 1
#include "kaffevm/support.h"
#include "md.h"

static const char char_v = 'V';
static const char char_c = 'C';
static const char char_s = 'S';
static const char char_i = 'I';
static const char char_j = 'J';
static const char char_f = 'F';
static const char char_d = 'D';
#define JTYPECHAR(T) (char_##T)

static int argsize(char type) {
  int s = 0;
  switch (type) {
  case 'V':
    s = 0;
    break;
  case 'C':
  case 'S':
  case 'I':
  case 'F':
    s = 1;
    break;
  case 'J':
  case 'D':
    s = 2;
    break;
  default:
    abort();
  }
  return s;
}

static void print_jvalue(const char *msg, jvalue *value, char type) {
  if (msg)
    printf("%s", msg);
  switch (type) {
  case 'V':
    printf("void");
    break;
  case 'C':
    printf("%c", value->c);
    break;
  case 'S':
    printf("%d", value->s);
    break;
  case 'I':
    printf("%d", value->i);
    break;
  case 'J':
    printf("%lld", value->j);
    break;
  case 'F':
    printf("%f", value->f);
    break;
  case 'D':
    printf("%lf", value->d);
    break;
  default:
    abort();
  }
}

#define MYDBG

#define GET_SIZE_0(...) 0
#define GET_SIZE_1(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_0(__VA_ARGS__)
#define GET_SIZE_2(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_1(__VA_ARGS__)
#define GET_SIZE_3(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_2(__VA_ARGS__)
#define GET_SIZE_4(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_3(__VA_ARGS__)
#define GET_SIZE_5(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_4(__VA_ARGS__)
#define GET_SIZE_6(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_5(__VA_ARGS__)
#define GET_SIZE_7(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_6(__VA_ARGS__)
#define GET_SIZE_8(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_7(__VA_ARGS__)
#define GET_SIZE_9(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_8(__VA_ARGS__)
#define GET_SIZE_10(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_9(__VA_ARGS__)
#define GET_SIZE_11(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_10(__VA_ARGS__)
#define GET_SIZE_12(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_11(__VA_ARGS__)
#define GET_SIZE_13(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_12(__VA_ARGS__)
#define GET_SIZE_14(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_13(__VA_ARGS__)
#define GET_SIZE_15(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_14(__VA_ARGS__)
#define GET_SIZE_16(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_15(__VA_ARGS__)
#define GET_SIZE_17(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_16(__VA_ARGS__)
#define GET_SIZE_18(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_17(__VA_ARGS__)
#define GET_SIZE_19(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_18(__VA_ARGS__)
#define GET_SIZE_20(TYPE, VAL, ...)
argsize(JTYPECHAR(TYPE))+GET_SIZE_19(__VA_ARGS__)
#define GET_SIZE(NARGS, ...) GET_SIZE_##NARGS(__VA_ARGS__)

#define CALL_INVOKE_DO_PREPARE_N(IDX, TYPE, VAL)	do{\
  if(argsize(JTYPECHAR(TYPE))==2) \
  { \
    args[IDX+1].TYPE = VAL;				\
    call.callsize[IDX+1] = argsize(JTYPECHAR(TYPE));	\
    call.calltype[IDX+1] = JTYPECHAR(TYPE); \
    /*printf("\nIDX+1: %d TYPE: %c VALUE: %lf",IDX+1,JTYPECHAR(TYPE),VAL);*/\
    args[IDX].i = (args[IDX+1].j)>>32;\
    call.callsize[IDX] = 0;\
    /*printf("\nIDX: %d TYPE: %c VALUE: %d\n",IDX,'I',args[IDX].i);*/\
  } \
  else\
  {\
  args[IDX].TYPE = VAL;				\
  call.callsize[IDX] = argsize(JTYPECHAR(TYPE));	\
  call.calltype[IDX] = JTYPECHAR(TYPE); \
  /*printf("\nIDX: %d TYPE: %c VALUE: %d\n",IDX,(JTYPECHAR(TYPE)),VAL);*/\
    }\
  }while(0)

#define CALL_INVOKE_PREPARE_0(...)		/* nothing */
#define CALL_INVOKE_PREPARE_1(TYPE, VAL,
...)	CALL_INVOKE_DO_PREPARE_N(0, TYPE, VAL)
#define CALL_INVOKE_PREPARE_2(TYPE, VAL,
...)	CALL_INVOKE_PREPARE_1(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_1(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_3(TYPE, VAL,
...)	CALL_INVOKE_PREPARE_2(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_2(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_4(TYPE, VAL,
...)	CALL_INVOKE_PREPARE_3(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_3(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_5(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_4(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_4(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_6(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_5(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_5(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_7(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_6(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_6(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_8(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_7(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_7(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_9(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_8(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_8(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_10(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_9(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_9(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_11(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_10(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_10(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_12(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_11(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_11(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_13(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_12(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_12(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_14(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_13(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_13(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_15(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_14(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_14(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_16(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_15(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_15(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_17(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_16(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_16(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_18(TYPE, VAL, ...)	
CALL_INVOKE_PREPARE_17(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_17(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_19(TYPE, VAL,
...)	CALL_INVOKE_PREPARE_18(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_18(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE_20(TYPE, VAL,
...)	CALL_INVOKE_PREPARE_19(__VA_ARGS__);
CALL_INVOKE_DO_PREPARE_N(GET_SIZE_19(__VA_ARGS__), TYPE, VAL);
#define CALL_INVOKE_PREPARE(NARGS,
...)		CALL_INVOKE_PREPARE_##NARGS(__VA_ARGS__)


#define SWAP(X, Y) do {				\
  typeof(X) T = X;				\
  X = Y;					\
  Y = T;					\
} while (0)

#define CALL_INVOKE(FUNC, RETTYPE, NARGS, ...) do {	\
  jvalue args[NARGS];					\
  jvalue ret;						\
  callMethodInfo call;					\
  static int i,s = 0;						\
  call.function = &FUNC;				\
  call.ret = &ret;					\
  call.retsize = argsize(JTYPECHAR(RETTYPE));		\
  call.rettype = JTYPECHAR(RETTYPE);			\
  call.args = args;\
  s=GET_SIZE(NARGS, ##__VA_ARGS__);				\
  call.nrargs=s;\
  char callsize[s]; \
  char calltype[s]; \
  call.callsize = callsize; \
  call.calltype = calltype; \
  call.argsize = s;					\
  CALL_INVOKE_PREPARE(NARGS, ##__VA_ARGS__, 1);		\
  /* reverse arguments */				\
  for (i = 0; i < s/2; i++) {			\
    int x = i, y = s- i - 1;			\
    SWAP(args[x], args[y]);				\
    SWAP(call.callsize[x], call.callsize[y]);		\
    SWAP(call.calltype[x], call.calltype[y]);		\
  }						\
  sysdepCallMethod(&call);				\
  print_jvalue("returns: ", &ret, call.rettype);	\
  printf("\n");						\
} while (0)

#define CALL_DIRECT_EXPAND_0(...)		/* nothing */
#define CALL_DIRECT_EXPAND_1(TYPE, VAL)		VAL
#define CALL_DIRECT_EXPAND_2(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_1(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_3(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_2(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_4(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_3(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_5(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_4(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_6(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_5(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_7(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_6(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_8(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_7(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_9(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_8(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_10(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_9(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_11(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_10(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_12(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_11(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_13(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_12(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_14(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_13(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_15(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_14(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_16(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_15(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_17(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_16(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_18(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_17(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_19(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_18(__VA_ARGS__)
#define CALL_DIRECT_EXPAND_20(TYPE, VAL, ...)	VAL,
CALL_DIRECT_EXPAND_19(__VA_ARGS__)
#define CALL_DIRECT_ARGS(NARGS, ...)		CALL_DIRECT_EXPAND_##NARGS(__VA_ARGS__)

#define CALL_DIRECT_RET_v(RETVAL, TYPE, FUNC)	FUNC
#define CALL_DIRECT_RET_x(RETVAL, TYPE, FUNC)	RETVAL.TYPE = FUNC
#define CALL_DIRECT_RET_c			CALL_DIRECT_RET_x
#define CALL_DIRECT_RET_s			CALL_DIRECT_RET_x
#define CALL_DIRECT_RET_i			CALL_DIRECT_RET_x
#define CALL_DIRECT_RET_j			CALL_DIRECT_RET_x
#define CALL_DIRECT_RET_f			CALL_DIRECT_RET_x
#define CALL_DIRECT_RET_d			CALL_DIRECT_RET_x

#define DO_CALL_DIRECT(FUNC, RETVAL, RETTYPE, NARGS, ...) \
  CALL_DIRECT_RET_##RETTYPE(RETVAL, RETTYPE,
FUNC)(CALL_DIRECT_ARGS(NARGS, __VA_ARGS__))

#define CALL_DIRECT(FUNC, RETTYPE, NARGS, ...) do {			\
  jvalue retval;							\
  char rettype = JTYPECHAR(RETTYPE);					\
  DO_CALL_DIRECT(FUNC, retval, RETTYPE, NARGS, __VA_ARGS__);		\
  print_jvalue("returns: ", &retval, rettype);				\
  printf("\n");								\
} while (0)

#define CALL(FUNC, RETTYPE, NARGS, ...)		      			\
  printf("# %s: %s => %s\n", #FUNC, #__VA_ARGS__, #RETTYPE);		\
  CALL_DIRECT(FUNC, RETTYPE, NARGS, __VA_ARGS__);			\
  CALL_INVOKE(FUNC, RETTYPE, NARGS, __VA_ARGS__);			\
  printf("\n");


static void f_v_v(void)
{
}

static void f_v_i(jint i)
{
  printf("%d\n", i);
}

static void f_v_d(jdouble d)
{
  printf("%lf\n",d);
}
static void f_v_ij(jint i, jlong j)
{
  printf("%d, %lld\n", i, j);
}

static void f_v_cij(jchar c, jint i, jlong j)
{
  printf("%c, %d, %lld\n", c, i, j);
}

static void f_v_csijfd(jchar c, jshort s, jint i, jlong j, jfloat f, jdouble d)
{
  printf("%c, %d, %d, %lld, %f, %lf\n", c, s, i, j, f, d);
}

static void f_v_fidjffijddjjiidfd(jfloat p1, jint p2, jdouble p3,
jlong p4, jfloat p5,
				  jfloat p6, jint p7, jlong p8, jdouble p9, jdouble p10,
				  jlong p11, jlong p12, jint p13, jint p14, jdouble p15,
				  jfloat p16, jdouble p17)
{
  printf("%f, %d, %lf, %lld, %f, %f, %d, %lld, %lf, %lf, %lld, %lld,
%d, %d, %lf, %f, %lf\n",
	 p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17);
}

static jchar f_c_c(jchar c)
{
  printf("%c\n", c);
  return c + 'A' - 'a';
}

static jshort f_s_ii(jint x, jint y)
{
  printf("%d, %d\n", x, y);
  return x + y;
}

static jint add_2i(jint p1, jint p2)
{
  printf("%d, %d\n", p1, p2);
  return p1 + p2;
}

static jlong add_2j(jlong p1, jlong p2)
{
  printf("%lld, %lld\n", p1, p2);
  return p1 + p2;
}

static jint add_12i(jint p1, jint p2, jint p3, jint p4,
		   jint p5, jint p6, jint p7, jint p8,
		   jint p9, jint p10, jint p11, jint p12)
{
  return p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10 + p11 + p12;
}

static jfloat add_2f(jfloat p1, jfloat p2)
{
  return p1 + p2;
}

static jfloat add_10f(jfloat p1, jfloat p2, jfloat p3, jfloat p4, jfloat p5,
		     jfloat p6, jfloat p7, jfloat p8, jfloat p9, jfloat p10) {
  return p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10;
}

static jdouble add_10d(jdouble p1, jdouble p2, jdouble p3, jdouble p4,
jdouble p5,
		      jdouble p6, jdouble p7, jdouble p8, jdouble p9, jdouble p10) {
  return p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10;
}

static jfloat add_20f(jfloat p1, jfloat p2, jfloat p3, jfloat p4, jfloat p5,
		     jfloat p6, jfloat p7, jfloat p8, jfloat p9, jfloat p10,
		     jfloat p11, jfloat p12, jfloat p13, jfloat p14, jfloat p15,
		     jfloat p16, jfloat p17, jfloat p18, jfloat p19, jfloat p20)
{
  return p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10 + p11 + p12 + p13 +
    p14 + p15 + p16 + p17 + p18 + p19 + p20;
}

static jlong add_jijiijiiji(jlong p1, jint p2, jlong p3, jint p4, jint p5,
			    jlong p6, jint p7, jint p8, jlong p9, jint p10)
{
  return p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10;
}

static jlong add_ijijjijjij(jint p1, jlong p2, jint p3, jlong p4, jlong p5,
			    jint p6, jlong p7, jlong p8, jint p9, jlong p10)
{
  return p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10;
}

static jdouble add_ffddffddfdf(jfloat p1, jfloat p2, jdouble p3, jdouble p4,
			       jfloat p5, jfloat p6, jdouble p7, jdouble p8,
			       jfloat p9, jdouble p10, jfloat p11)
{
  return p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10 + p11;
}

static jint add_fidjffijddjjiidfd(jfloat p1, jint p2, jdouble p3,
jlong p4, jfloat p5,
				  jfloat p6, jint p7, jlong p8, jdouble p9, jdouble p10,
				  jlong p11, jlong p12, jint p13, jint p14, jdouble p15,
				  jfloat p16, jdouble p17)
{
  return p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9
    + p10 + p11 + p12 + p13 + p14 + p15 + p16 + p17;
}


static void printSP()
{
int i;
   asm volatile ("movl %%esp,%0"
        : "=r" (i));
   printf("SP: %d\n",i);
}

int main(void) {

  CALL(f_v_v, v, 0);
  CALL(f_v_d,v,1,d,3.14);
  CALL(f_v_i, v, 1, i, 1);
  CALL(f_v_ij, v, 2, i, 1, j, 284587398);
  CALL(f_v_cij, v, 3, c, 'c', i, 1, j, 2);
  CALL(f_v_csijfd, v, 6, c, 'c', s, 16384, i, 107374, j, 461168, f,
1.0, d, 3.14);
  CALL(f_c_c, c, 1, c, 'z');
  CALL(f_s_ii, s, 2, i, 1, i, 2);

  // view mixed floats, doubles, ints and longs
  CALL(f_v_fidjffijddjjiidfd,
       v,
       17,
       f, 1, i, 2, d, 3, j, 4, f, 5, f, 6, i, 7, j, 8, d, 9,
       d, 10, j, 11, j, 12, i, 13, i, 14, d, 15, f, 16, d, 17);

  // add two ints
  CALL(add_2i, i, 2, i, 1, i, 2);

  // add two longs
  CALL(add_2j, j, 2, j, 1, j, 2);

  // add many ints
  CALL(add_12i, i, 12, i, 1, i, 2, i, 3, i, 4, i, 5, i, 6, i, 7, i, 8,
i, 9, i, 10, i, 11, i, 12);

  // add two floats
  CALL(add_2f, f, 2, f, 1.0, f, 2.0);

  // add many floats
  CALL(add_10f,
       f,
       10,
       f, 1, f, 2, f, 3, f, 4, f, 5, f, 6, f, 7, f, 8, f, 9, f, 10);

  // add many doubles
  CALL(add_10d,
       d,
       10,
       d, 1, d, 2, d, 3, d, 4, d, 5, d, 6, d, 7, d, 8, d, 9, d, 10);

  // add many many floats
  CALL(add_20f,
       f,
       20,
       f, 1, f, 2, f, 3, f, 4, f, 5, f, 6, f, 7, f, 8, f, 9, f, 10,
       f, 11, f, 12, f, 13, f, 14, f, 15, f, 16, f, 17, f, 18, f, 19, f, 20);

  // add mixed ints
  CALL(add_jijiijiiji,
       j,
       10,
       j, 1, i, 2, j, 3, i, 4, i, 5, j, 6, i, 7, i, 8, j, 9, i, 10);

  // add mixed ints 2
  CALL(add_ijijjijjij,
       j,
       10,
       i, 1, j, 2, i, 3, j, 4, j, 5, i, 6, j, 7, j, 8, i, 9, j, 10);

  // add mixed floats
  CALL(add_ffddffddfdf,
       d,
       11,
       f, 1, f, 2, d, 3, d, 4, f, 5, f, 6, d, 7, d, 8, f, 9, d, 10, f, 11);

  // add mixed floats, doubles, ints and longs
  CALL(add_fidjffijddjjiidfd,
       i,
       17,
       f, 1, i, 2, d, 3, j, 4, f, 5, f, 6, i, 7, j, 8, d, 9,
       d, 10, j, 11, j, 12, i, 13, i, 14, d, 15, f, 16, d, 17);
}
-----------------------------------------------------------------------------------------------------------------------------
Instructions:
1. copy this file to kaffe/developers
2. sh <filename>.c




More information about the kaffe mailing list