aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/pcpu.h
diff options
context:
space:
mode:
authorLawrence Stewart <lstewart@FreeBSD.org>2010-06-19 02:30:10 +0000
committerLawrence Stewart <lstewart@FreeBSD.org>2010-06-19 02:30:10 +0000
commitcb0bd51d988e016eda6f2d78db289c29dc29392c (patch)
tree43c1683e0340f6c50bc1796d6153e98b92e44a0c /sys/sys/pcpu.h
parent69a990a144d27bb864f56ac6f7f80835cd28720b (diff)
downloadsrc-cb0bd51d988e016eda6f2d78db289c29dc29392c.tar.gz
src-cb0bd51d988e016eda6f2d78db289c29dc29392c.zip
- 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)
Notes
Notes: svn path=/head/; revision=209325
Diffstat (limited to 'sys/sys/pcpu.h')
-rw-r--r--sys/sys/pcpu.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
index 472a658bfd40..ea4befb3369f 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