#include <stdio.h>
#include <stdarg.h>

#if defined VA_TYPE_PPC
#  define PARROT_VA_TO_VAPTR(x) (x)
#endif
#if defined VA_TYPE_X86
#  define PARROT_VA_TO_VAPTR(x) (&(x))
#endif

typedef struct a_t {
    void *args;
} arg;

static void
test2(arg *a) {

    va_list *ap = (va_list*)a->args;
    int i;
    double d;
    char *s;

    i = va_arg(*ap, int);
    d = va_arg(*ap, double);
    s = va_arg(*ap, char *);
    if (i == 42 && d == 2.0)
	printf("%s\n",s);
    else
	printf("nok\n");
}

static void
test1(va_list ap)
{
    arg a;
    a.args = PARROT_VA_TO_VAPTR(ap);
    test2(&a);
}

static void
test0(int n, ...)
{
    va_list ap;
    va_start(ap, n);
    test1(ap);
    va_end(ap);
}

int main(int argc, char *argv[])
{
    test0(3, 42, 2.0, "ok");
    return 0;
}


