Messages in this thread | | | Date | Mon, 22 Nov 2004 06:33:28 -0500 | From | Jakub Jelinek <> | Subject | Re: var args in kernel? |
| |
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).
Jakub - 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/
| |