PERFORCE change 126950 for review

Hans Petter Selasky hselasky at c2i.net
Sat Sep 29 04:22:09 PDT 2007


On Saturday 29 September 2007, Kip Macy wrote:
> http://perforce.freebsd.org/chv.cgi?CH=126950
>
> Change 126950 by kmacy at kmacy_home:ethng on 2007/09/29 05:20:19
>
> 	fix ring count to correctly account for prod < cons
>
> Affected files ...
>
> .. //depot/projects/ethng/src/sys/dev/cxgb/cxgb_osdep.h#11 edit
>
> Differences ...
>

Just a nit.

> ==== //depot/projects/ethng/src/sys/dev/cxgb/cxgb_osdep.h#11 (text+ko) ====
>
> @@ -72,7 +72,10 @@
>  static __inline int
>  mbuf_ring_count(struct mbuf_ring *mr)
>  {
> -	return abs(mr->mr_cons - mr->mr_prod);
> +	int size = mr->mr_size;
> +	int mask = size - 1;
> +
> +	return ((size + mr->mr_prod - mr->mr_cons) & mask);
                 ^^^^ I don't think you need this, hence "(size & mask) == 0"

I assume that size is a power of two. Maybe if you were using modulo and you 
are playing with signed numbers you would need it.

--HPS


More information about the p4-projects mailing list