[PATCH 1/7] bb_ioctl implementation - improved
Robin Farine
robin.farine at terminus.org
Tue Jul 17 08:18:59 UTC 2007
On Mon July 16 2007 23:34, Denis Vlasenko wrote:
> On Monday 16 July 2007 08:59, Robin Farine wrote:
> > Especially when on ARM for instance, the == -1 variant is 8
> > bytes bigger than the < 0 for a given compiler and flags. The
> > outcome of
>
> We have lots of if (f() == -1) comparisons too:
> You just said that clever (== per-arch) choice of
> FAILED_NEGATIVE(x) and FAILED_NONZERO(x) will save ~1k of code on
> ARM.
> Target arch can be dealt with #ifdefs
>
> > go for the safe variant rather than the one that spares 1 byte
> > on architecture foo.
>
> 1 byte maybe, but 8 bytes?
To be fair, I cheated. I used a simple test where the compiler could
optimize the code in the two branches of the < 0 test benefiting
from the fact that bit 31 is cleared in one branch and set in the
other. In general the code size tends to be the same for both
variants of the test.
My point was more that the outcome of such an optimization depends
on the target architecture and probably also on the version of gcc
and the flags used. But if macros can help saving size on an arch
without penalizing the others while keeping the code correct and
readable, then why not.
Robin
More information about the busybox
mailing list