On Thu, 17 Jun 2010, Kostik Belousov wrote:

On Thu, Jun 17, 2010 at 12:38:08PM +1000, Lawrence Stewart wrote:
I've tested the above and it works. I also prefer the idea of having
DPCPU_SUM return the sum so that you can do "var = DPCPU_SUM(...)". My
only concern with this method is that the caller no longer has the
choice to make the sum variable a larger type to avoid overflow. It
would be nice to be able to have the DPCPU vars be uint32_t but be able
to sum them into a uint64_t accumulator for example. Perhaps this isn't
really an issue though... I'm not sure.
You are worried about overflow in the sum of 32 or 64 variables, but if
this is the case, then each member of the sum can overflow as well, IMO.
Either ignore the issue, or use a uintmax_t.

Or use int variables so that the overflow trap can work, and fix the
overflow trap to work (gcc -ftapv, but this is unusable in the kernel),
and get a nice panic on all overflows, not just here :-).

Bruce
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to