This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: Problem with new stdarg implementation (gcc >= 2.9x)



> What I ask for is an interface that allows pass a size instead of a tag
> and parse it this way:
>
>     size = va_arg(ap, size);
>     memcpy(datum, va_arg(ap, typeof(structofsize(size)), size);

It is impossible. Take for example mips in 64-bit mode. doubles inside
a structure are passed in floating point registers, not in integer registers.
If you only pass the size and alignment of the structure, the va_arg
macro will not be able to distinguish
  struct { double x; }
and
  struct { long x; }
and you will therefore get wrong results.

If you restrict yourself to structures which only contain `long' or `void*'
items, you can solve the problem by treating each CPU and ABI, one by one.
This approach has been realized in [1]. But beware: it is far from portable.

                   Bruno

[1] ftp://ftp.santafe.edu/pub/gnu/ffcall-1.6.tar.gz


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