avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: [avr-libc-dev] Problem with unsigned long long printf()


From: Joerg Wunsch
Subject: Re: Fwd: [avr-libc-dev] Problem with unsigned long long printf()
Date: Sat, 18 Sep 2004 23:21:26 +0200
User-agent: Mutt/1.5.6i

As Theodore A. Roth wrote:

> > did you read this on the list? Is it a bug or not?

(Which list btw.?)

> First, avr-libc currently does not handle the '%llu', '%lld', etc.
> specifiers. This was probably by design so as not to bloat the vfprintf
> function any more than is already is.

You're right on that assumption, Ted.  I thought for a moment about
it, but gave up on it for the bloat that would have been caused by
implementing 64-bit handling.

Consequently, I never noticed the problem you've detected now.

If at all, I'd at best like to implement it as an optional library
(i.e. a fourth option to build/link vfprintf()).  However, I'm not
really happy with the current way optional libraries have to be
requested.  If anyone's got a cool idea for that, I'll be glad to hear
about it.

> To me, this looks suspiciously like gcc is not handling the
> 
>   a.ull = va_arg (ap, unsigned long long);
> 
> call correctly when the type is 64 bits. when passing a 64 bit variable
> by value, gcc pushes the 8 bytes onto the stack instead of passing via 8
> registers. If my analysis is correct, then there's a bug in gcc.

Hmm, there are at most 8 registers available for argument passing.
Thus, a 64-bit type could only be passed in registers if it is the
sole (or very first) argument in a function call.  Anything else has
go onto the stack.

Also, variadic arguments can IMHO never be passed in registers, since
the callee would never know which register to start.  AFAICT, they
always go to the stack.

Probably noone ever tested varargs handling for 64-bit types though.
Since <stdarg.h> and all related stuff is in GCC's domain (as opposed
to avr-libc's), well, yes, somehow there must be a bug in GCC here,
but I'd rather suspect that __builtin_va* stuff than anything else.

-- 
J"org Wunsch                                           Unix support engineer
Wir stellen aus! Auf der SYSTEMS 2004  vom 18.-22. Oktober in München
Halle B 3, Stand 320-206 (Partner-Stand von Sun Microsystems)
Halle B 2, Stand 605 "Die Musterfirma"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]