lkml.org 
[lkml]   [2004]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: var args in kernel?
From
Date
Jan Engelhardt <jengelh@linux01.gwdg.de> writes:

>>> 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
>
> Yeah I originally had that in mind but did not write it out ;)
> What would the struct look like? Because if the following was true, then you
> could also use a pointer:

You left out an important detail:

> int my_printf(const char *fmt, struct { some ints, some char's, whatever } arg)

int my_printf(const char *fmt, struct { some ints, some char's, whatever } arg[1])

which the same as

int my_printf(const char *fmt, struct { some ints, some char's, whatever } *arg)

Andreas.

--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
-
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.171 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site