lkml.org 
[lkml]   [2004]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: var args in kernel?
Jakub Jelinek wrote:
> On Mon, Nov 22, 2004 at 12:03:56PM +0100, Jan Engelhardt wrote:
>
>>>> What you can't do is e.g.
>>>> va_list ap;
>>>> va_start (ap, x);
>>>> bar (x, ap);
>>>> bar (x, ap);
>>>> va_end (ap);
>>
>>In theory, you can't. But the way how GCC (and probably other compilers)
>>implement it, you can. Because "ap" is just a pointer (which fits into a
>>register, if I may add). As such, you can copy it, pass it multiple times, use
>>it multiple times, and whatever you like.
>
>
> That's exactly the wrong assumption.
> On some Linux architectures you can, on others you can't.
> Architectures where va_list is a char or void pointer include e.g.:
> i386, sparc*, ppc64, ia64
> Architectures where va_list is something different, usually struct { ... } va_list[1];
> or something similar:
> x86_64, ppc32, alpha, s390, s390x
>
> In the latter case, you obviously can't do va_list dest = src and
> if you do bar (x, ap); the content of the struct pointed by ap is changed
> after the call, therefore you can't use it for other routines
> (as it depends on where exactly the called function stopped with va_arg).

Why can't you do dest=src? Assignment of struct to struct has been a
part of C since earliest times. I used it in ~1990 in code which ran on
Z80, Multics, M68k, VAX and Cray2, and it worked without any ifdefs (for
that, there were "just a few" for other issues like 8 vs. 9 bit char, etc).

--
-bill davidsen (davidsen@tmr.com)
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.053 / U:0.704 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site