From 07de7d5fb59935e366f12c29d5901045c0c964c8 Mon Sep 17 00:00:00 2001 From: Lawrence Stewart Date: Tue, 13 Jul 2010 06:49:34 +0000 Subject: [PATCH] - Rename DPCPU_SUM to DPCPU_VARSUM to better reflect the fact it operates on member variables of a DPCPU struct. - Add DPCPU_SUM which sums a DPCPU variable. Sponsored by: FreeBSD Foundation MFC after: 3 days --- sys/sys/pcpu.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index ea4befb3369..c157807ed5d 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -109,7 +109,19 @@ extern uintptr_t dpcpu_off[]; /* * Utility macros. */ -#define DPCPU_SUM(n, var) __extension__ \ +#define DPCPU_SUM(n) __extension__ \ +({ \ + u_int _i; \ + __typeof(DPCPU_PTR(n)) sum; \ + \ + sum = 0; \ + CPU_FOREACH(_i) { \ + sum += DPCPU_ID_PTR(_i, n); \ + } \ + sum; \ +}) + +#define DPCPU_VARSUM(n, var) __extension__ \ ({ \ u_int _i; \ __typeof((DPCPU_PTR(n))->var) sum; \