This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

makecontext and its arguments


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]