develooper Front page | perl.perl5.porters | Postings from March 2003

Re: [PATCH] glibc _moddi3

Thread Previous | Thread Next
From:
Enache Adrian
Date:
March 2, 2003 20:20
Subject:
Re: [PATCH] glibc _moddi3
Message ID:
20030303041928.GA31687@ratsnest.hole
On Sun, Mar 02, 2003 at 06:01:40PM +0100, Tels wrote:
> Here are two test c files, both "compiled" with gcc -s -O3 and I show only
> the assembly output for the main functions here:

Maybe my message was bad formulated. I didn't say to keep the
if (..) ..; code - silly compilers doesn't seem to grok it.
Maybe the thing everybody wants is:

in .h
#define ABS(a)	((a) < 0 ? -(a) : (a))
	/* beware: it evaluates 'a' twice */

in .c
left % ABS(right)

But, please please don't use the wicked abs() function.
It's not an operator.

It will always punch its argument into an int, should it
be long long, long, unsigned, etc. GCC will sometimes
inline it and sometimes not.

You'll be better off if you _never_ use it :-)

> Oh, one more thought: In the code in question, what are "right" and "left"?
> ints? longs? or IVs?

They are IVs. This means they could be 64-bit on a 32-bit platform.
(If you configured with -Duse64bitint).

Adi

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About