avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Broken strtoul() and ldiv()


From: Peter Jansen
Subject: Re: [avr-gcc-list] Broken strtoul() and ldiv()
Date: Mon, 18 Mar 2002 14:47:23 +1100

Hi Geoffrey,

> All recent (and probably old versions, too) of avr-libc have broken
> strtoul.  I always get 0xffffffff out.  The problem appears to be that
> ldiv() is broken.  If I change the conditionals in strtoul() around so
> that it uses '/' and '%' instead of ldiv(), it works.  This leads me to
> believe that ldiv() is broken.
> 
> Checking the ldiv() source file, it just jumps to __divmodsi4 in libgcc.
> Perhaps either this isn't the right thing to do, or __divmodsi4 is broken.

I think the problem is in strtoul with the ldiv. ldiv is defined as
__divmodsi4 where for strtoul it should call __udivmodsi4.

I checked a case with ldiv and it seems ok. The register passing etc
looks ok and calling ldiv from another program returns the correct
answer.
 
You could try putting something like 

extern ldiv_t uldiv(long, long) __asm__("__udivmodsi4") __ATTR_CONST__;

in strtoul.c

and change the call to ldiv to uldiv

Regards,

-- 
Peter Jansen
Smart Container
Level 1, NIC Building
Eveleigh
NSW       1430
AUSTRALIA
avr-gcc-list at http://avr1.org



reply via email to

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