This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: Accessing non-existing varargs argument


On 12/12/14 04:30, Andrew Haley wrote:
On 12/12/2014 10:20 AM, Florian Weimer wrote:
open is declared as:

    int open(const char *pathname, int flags, ...);

The intent is to have two overloaded variants:

    int open(const char *pathname, int flags);
    int open(const char *pathname, int flags, mode_t mode);

The presence of the mode argument depends on the flags specified.  The
set of such flags is known by the kernel.  I wish to avoid to maintain
this implementation detail in libc as well, so I want to always read the
mode argument, possibly passing a garbage value to the kernel.

Is there GCC-portable way to achieve this?

You're assuming that for all targets the varargs calling convention is
the same as the non-varargs calling convention, at least for integer
registers.  I don't think this is true for all targets, although it
might be true for the targets GCC supports today.
It's not true for all targets GCC supports today once you include non-integer types.

It'd probably work for the specific cases Florian wants to tackle, but I'd consider it highly non-portable.

What problem are you trying to tackle here Florian?

Jeff


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