Date: Wed, 21 Apr 2004 22:58:01 -0700 From: Peter Wemm <peter@wemm.org> To: freebsd-amd64@freebsd.org Cc: amd64@freebsd.org Subject: Re: va_list q Message-ID: <200404212258.01563.peter@wemm.org> In-Reply-To: <20040422050128.GQ34647@lucky.net> References: <20040422050128.GQ34647@lucky.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 21 April 2004 10:01 pm, Valentin Nechayev wrote: > Hi, > I was notified that maintained port (net/pppd23) can't be built on > amd64. Failure message is: > > cc -O -pipe -g -I../include -DHAVE_PATHS_H -D_BITYPES -c utils.c > utils.c: In function `vslprintf': > utils.c:253: error: invalid use of non-lvalue array > *** Error code 1 > > The code in question is: > > int > vslprintf(buf, buflen, fmt, args) > [...] > #ifndef __powerpc__ > > > n = vslprintf(buf, buflen + 1, f, va_arg(args, > > va_list)); > > #else > /* On the powerpc, a va_list is an array of 1 structure > */ n = vslprintf(buf, buflen + 1, f, va_arg(args, void *)); #endif > > (I selected failed line with '>') > > va_arg() uses translation to pointer to specified type; this > translation fails with message shown above. (Translation is used > AFAIS on all platforms, but only amd64 causes error.) I have no > freebsd/amd64 box now. Can anybody say how can it be fixed, and > whether shown powerpc hack is applicable to amd64 if it's last-resort > solution? amd64 needs to use the same code that is in the #ifdef __powerpc__. Its what we use in src/usr.sbin/pppd FWIW. On powerpc and amd64, the argument passing ABI is so complicated that the sequence counters can't be fit in the spare bits in a pointer like on the other platforms. So on those two (and some other) platforms, gcc implements va_list as a pointer to an external structure. As an aside, this breaks code that assums it can copy va_lists by assignment. On powerpc and amd64, you *must* use va_copy(), or you simply copy the pointer, not the actual argument passing state. -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200404212258.01563.peter>