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

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

Re: [avr-libc-dev] strtoul() bug?


From: Marek Michalkiewicz
Subject: Re: [avr-libc-dev] strtoul() bug?
Date: Sat, 14 Jun 2003 00:49:38 +0200
User-agent: Mutt/1.4i

On Fri, Jun 13, 2003 at 11:25:15PM +0200, Joerg Wunsch wrote:
> 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,

Oops.  Thanks.  Probably not enough coffee at the time I did this -
I don't even remember when it was, must have been long long ago.

> 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.

Current libgcc.a contains uldiv(), only under a different name:

div   -> __divmodhi4
ldiv  -> __divmodsi4
udiv  -> __udivmodhi4
uldiv -> __udivmodsi4

udiv/uldiv are not standard ANSI/ISO C names, and as such are not
defined in stdlib.h (only the signed div/ldiv functions are there),
but the functionality is already available.  It probably wasn't at
the time I introduced that strtoul bug...

GCC should be smart enough to use the udivmodsi4 insn just once
to get both the quotient and the remainder, but (as I just checked)
this is not the case (two separate calls) in the compiled code of
strtoul().  No idea why, and there are other bugs to fix first
(correct inefficient code is better than incorrect efficient code :).

Marek





reply via email to

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