[gccsdk] libscl valist functions and __GNUC__

John Tytgat John.Tytgat at aaug.net
Sun May 27 07:01:41 PDT 2007


In message <ab4886070705240114x504a48c5n6246182299847ab5 at mail.gmail.com>
          "Nick Burrett" <nick at sqrt.co.uk> wrote:

> The macros were defined in stdio.h.  I wrote them because Norcroft did
> an extra level of indirection when passing the vararg pointer to the
> function.  We needed to emulate this within GCC in order to get
> vsscanf() and friends working.  Certainly this used to work, as I
> tested it when I originally wrote the macros.
>
> The va_list formats are the same, as this is defined by the APCS.

Is it ? Because the way float arguments are passed is different between
GCC and Norcroft.  GCC will stick to 4 bytes while Norcroft will convert
the floats to doubles and reserve 8 bytes for this.

See r1801.

I never found an authoritive source on the APCS-R or APCS-32 definition
saying which convention is the right one.

> It
> is just the passing of the va_list to the function that is different
> here.

I don't see in our libscl code a different treatment of va_list passing
between GCC and Norcroft.

> You'd need to undefine the macros and actually compare the assembler
> output between Norcroft and GCC here to see what I'm talking about.

Apart from the float difference, I don't see any other difference.

> Note that the use of macros here would suggest that linking with GCC
> compiled code against any Norcroft library that uses the va_list arg,
> would result in problems.

r2 (admin): Added __gcc_vprintf, __gcc_vfprintf and __gcc_vsprintf as
  aliases for vprintf, vfprintf and vsprintf.
r878 (nick): Added the __gcc_* macros in stdio.h
r1639 (alex): Added __gcc_vsnprintf as alias for vsnprintf.
r2637 (joty): Added __gcc_vfscanf, __gcc_vscanf and __gcc_vsscanf as
  aliases for vfscanf, vscanf and vsscanf.

I'm not sure if my change r2637 made today is the best one. I would be
tempted to remove the __gcc_*() macros and the resulting changes made in
r2, r1639 and r2637.

John.
-- 
John Tytgat, in his comfy chair at home                                 BASS
John.Tytgat at aaug.net                             ARM powered, RISC OS driven




More information about the gcc mailing list