[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] strtoul() bug?
From: |
eric |
Subject: |
Re: [avr-libc-dev] strtoul() bug? |
Date: |
Fri, 13 Jun 2003 22:35:23 GMT |
> As address@hidden wrote:
>
> > > I'm compiling for an ATMEGA128, and it seems I never
> > succeed with
> > > strtoul() working: always getting back 0xFFFFFFFFul
>
> Aka. ULONG_MAX, which is an indication of an overflow
error.
>
> I finally found the time to debug this.
>
> > Would you be willing
> > to fill out a bug tracker on the avr-libc project page
for
> > this?
>
> Not needed anymore. :)
>
> The bug was Marek's attempt to copy over the same
optimization that he
> did in strtol() which saves one integer division by using
ldiv() to do
> the division and remainder within a single operation.
Unfortunately,
> our libgcc.a misses the required uldiv() function that
would be needed
> for strtoul(), and the trickery to use ldiv() instead
completely fell
> over when comparing the unsigned long temp variables
against a signed
> long value.
>
> I've removed the optimization from the source, and
basically reverted
> the file to the original BSD version. Should anybody
want to include
> an uldiv() function into libgcc.a (the underlying gcc
auxiliary
> functions are certainly already around there, i think),
we can pull
> out the old code from CVS, and reactivate it.
>
> Note that this also fixes the warnings in this file. ;-)
(as mentioned
> in doc/TODO)
Very nice! :) Thanks
Eric