On Wed, Nov 03, 2004 at 10:14:03AM +0900, YOSHIFUJI Hideaki / ?$B5HF#1QL@ wrote:
> In article <20041102210259.GA12642@xxxxxxxxxxxxxxxxxxx> (at Wed, 3 Nov 2004
> 08:02:59 +1100), Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> says:
>
> > - if (tbl->entries > tbl->gc_thresh3 ||
> > - (tbl->entries > tbl->gc_thresh2 &&
> > + entries = atomic_inc_return(&tbl->entries) - 1;
> > + if (entries >= tbl->gc_thresh3 ||
> > + (entries >= tbl->gc_thresh2 &&
>
> Why don't you do something like this?
>
> entries = atomic_inc_return(&tbl->entries);
> if (entries > tbl->gc_thresh3 ||
> (entries > tbl->gc_thresh2 &&
We could do that. The first form generates slightly better code on
i386. However, the situation is probably reversed for other
architectures.
A more serious issue is that some architectures arm/arm26/um/x86_64
don't have atomic_inc_return.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
|