va_list implementation on mips64 , with 32bit cross compiled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am planning  to use va_list on a single module, however the
following code did not work properly.

typedef char *	va_list;
#define _INTSIZEOF(n)	( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
#define va_start(ap,v)	( ap = (va_list)&v + _INTSIZEOF(v) )
#define va_arg(ap,t)	( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#define va_end(ap)	( ap = (va_list)0 )

void test_val_list()
{
unsigned long test=0x1234;
test_printk("test:0x%x OK\n",aaa);
}

void test_printk(const char *format, ...)
{
va_list args;
va_start(args, format);
unsigned int v1 = va_arg(args,unsigned long);
printk("v1 is 0x%x\n",v1);
unsigned int v2 = va_arg(args,unsigned long);
printk("v2 is 0x%x\n",v2);
}


The result is :

v1 is 0x00000013

v2 is 0x00000019

Why this happened ? shouldn't v1 be 0x1234 here?

Thank you



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux