linux-mips
[Top] [All Lists]

va_list implementation on mips64 , with 32bit cross compiled

To: Linux MIPS Mailing List <linux-mips@linux-mips.org>
Subject: va_list implementation on mips64 , with 32bit cross compiled
From: "wilbur.chan" <wilbur512@gmail.com>
Date: Thu, 14 Oct 2010 08:06:42 +0800
Cc: chelly wilbur <wilbur512@gmail.com>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:cc:content-type; bh=6Zz+f5ynx73C//ZSEV23PaGvj4+pUntdq3w/SEsn7uA=; b=ma8VAJhzkxwcUGsm7a+AgYFi6NWi+v5GEu+S6IUHHic5rCApSXLiEY0qS6zUEg5gdX YO0/Hc7DXoTrQGjrUMDQoVOerVfr+UcHYVbERA5F045ukUUNnMrudbng1CV0dKCaPBqn VZubZR5ZhoMTlzWzpPzxXtiRDxNqN+RvzuZBM=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=ixKXlAfReswIJI9qvKGLEgAhsDxMymcPomaS5F+KmMcwngkrorObPvf7HHLyZvOmGf G+vT4sMd/+hj/nHymuyVHP21KDDcv+Vpyb5YmoK4mAuMSwatqduUcpmJAeDZ4HXxjaBv tZQeBNllIi6a5ekeaOXE8+Plu/C5WSQm+k3Ak=
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
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

<Prev in Thread] Current Thread [Next in Thread>