diff options
author | lstewart <lstewart@FreeBSD.org> | 2010-06-19 02:30:10 +0000 |
---|---|---|
committer | lstewart <lstewart@FreeBSD.org> | 2010-06-19 02:30:10 +0000 |
commit | 3ab8676f7b4604c253c925ae463fd26f495a84b8 (patch) | |
tree | 43c1683e0340f6c50bc1796d6153e98b92e44a0c /sys/sys/pcpu.h | |
parent | 21a2cb393519d41616424cd3fbbe6abed20445a0 (diff) | |
download | FreeBSD-src-3ab8676f7b4604c253c925ae463fd26f495a84b8.zip FreeBSD-src-3ab8676f7b4604c253c925ae463fd26f495a84b8.tar.gz |
- Rename the internal for loop iterator to "_i" to avoid potential shadowing of
external variables named "i". The "_" prefix is reserved for infrastructure
type code and is therefore not expected to be used by normal code likely to
call DPCPU_SUM(). [1]
- Change DPCPU_SUM to return the sum rather than calculate and assign it
internally. Usage is now: "sum = DPCPU_SUM(dpcpu_var, member_to_sum);" [2]
- Fix some style nits. [3]
Sponsored by: FreeBSD Foundation
Suggested by: bde [3], mdf [1], kib [1,2], pjd [1,3]
Reviewed by: kib
MFC after: 1 week (instead of r209119)
Diffstat (limited to 'sys/sys/pcpu.h')
-rw-r--r-- | sys/sys/pcpu.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index 472a658..ea4befb 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -109,13 +109,17 @@ extern uintptr_t dpcpu_off[]; /* * 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) +#define DPCPU_SUM(n, var) __extension__ \ +({ \ + u_int _i; \ + __typeof((DPCPU_PTR(n))->var) sum; \ + \ + sum = 0; \ + CPU_FOREACH(_i) { \ + sum += (DPCPU_ID_PTR(_i, n))->var; \ + } \ + sum; \ +}) /* * XXXUPS remove as soon as we have per cpu variable |