makecontext and its arguments
Andreas Jaeger
aj@suse.de
Mon Aug 5 03:17:00 GMT 2002
Implementing makecontext on x86-64 I noticed a problem with passing
its arguments.
The function is defined as:
void makecontext(ucontext_t *ucp, void (*func)(void),
int argc, ...);
There's no way to determine the type of the arguments.
The Austin Draft (and also our manual) mentions:
The application shall ensure that the value of argc matches the
number of integer arguments passed to func; otherwise, the
behavior is undefined.
The glibc C implementations use va_arg(ap, long) to access the
parameter. But this won't work for x86-64 with int arguments since
int arguments are not properly sign extented to 64-bit for variable
arguments.
My question nails down to whether I can safely use va_arg(ap,int) in
the makecontext implementation or not.
Btw. Our testprogram stdlib/tst-setcontext.c uses:
static void
f1 (long a0, long a1, long a2, long a3)
Shouldn't those be ints?
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
More information about the Libc-hacker
mailing list