svn commit: r209119 - head/sys/sys
Lawrence Stewart
lstewart at freebsd.org
Sun Jun 13 13:24:18 UTC 2010
On 06/13/10 20:20, Gabor Kovesdan wrote:
>
>>>
>>> +/*
>>> + * Utility macros.
>>> + */
>>> +#define DPCPU_SUM(n, var, sum) \
>>> +do { \
>>> + (sum) = 0; \
>>> + u_int i; \
>>> + CPU_FOREACH(i) \
>>> + (sum) += (DPCPU_ID_PTR(i, n))->var; \
>>> +} while (0)
>> I'd suggest first swapping variable declaration and '(sum) = 0;'.
>> Also using 'i' as a counter in macro can easly lead to name collision.
>> If you need to do it, I'd suggest '_i' or something.
>> Maybe it would be better to make it an inline function rather than macro?
> And why using old BSD-stlye u_int? style(9) also suggest using ISO C types.
From <sys/smp.h>
extern u_int mp_maxid;
...
#define CPU_FOREACH(i) \
for ((i) = 0; (i) <= mp_maxid; (i)++) \
if (!CPU_ABSENT((i)))
Made sense to keep the types for i and mp_maxid the same. Happy to
change if you have a better suggestion.
Cheers,
Lawrence
More information about the svn-src-all
mailing list