From owner-svn-src-head@FreeBSD.ORG Sun Jun 13 10:10:48 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 641E4106567C; Sun, 13 Jun 2010 10:10:48 +0000 (UTC) (envelope-from pjd@garage.freebsd.pl) Received: from mail.garage.freebsd.pl (chello089077043238.chello.pl [89.77.43.238]) by mx1.freebsd.org (Postfix) with ESMTP id 9139A8FC0C; Sun, 13 Jun 2010 10:10:47 +0000 (UTC) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 0657F45CA0; Sun, 13 Jun 2010 12:10:46 +0200 (CEST) Received: from localhost (gate.wheel.pl [10.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 3F0B545C9C; Sun, 13 Jun 2010 12:10:38 +0200 (CEST) Date: Sun, 13 Jun 2010 12:10:25 +0200 From: Pawel Jakub Dawidek To: Lawrence Stewart Message-ID: <20100613101025.GD1320@garage.freebsd.pl> References: <201006130239.o5D2du3m086332@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="maH1Gajj2nflutpK" Content-Disposition: inline In-Reply-To: <201006130239.o5D2du3m086332@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 9.0-CURRENT amd64 X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-5.9 required=4.5 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.0.4 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r209119 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jun 2010 10:10:48 -0000 --maH1Gajj2nflutpK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jun 13, 2010 at 02:39:55AM +0000, Lawrence Stewart wrote: > Author: lstewart > Date: Sun Jun 13 02:39:55 2010 > New Revision: 209119 > URL: http://svn.freebsd.org/changeset/base/209119 >=20 > Log: > Add a utility macro to simplify calculating an aggregate sum from a DPC= PU > counter variable. > =20 > Sponsored by: FreeBSD Foundation > Reviewed by: jhb, rpaulo, rwatson (previous version of patch) > MFC after: 1 week >=20 > Modified: > head/sys/sys/pcpu.h >=20 > Modified: head/sys/sys/pcpu.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/sys/pcpu.h Sun Jun 13 01:27:29 2010 (r209118) > +++ head/sys/sys/pcpu.h Sun Jun 13 02:39:55 2010 (r209119) > @@ -106,6 +106,17 @@ extern uintptr_t dpcpu_off[]; > #define DPCPU_ID_GET(i, n) (*DPCPU_ID_PTR(i, n)) > #define DPCPU_ID_SET(i, n, v) (*DPCPU_ID_PTR(i, n) =3D v) > =20 > +/* > + * Utility macros. > + */ > +#define DPCPU_SUM(n, var, sum) \ > +do { \ > + (sum) =3D 0; \ > + u_int i; \ > + CPU_FOREACH(i) \ > + (sum) +=3D (DPCPU_ID_PTR(i, n))->var; \ > +} while (0) I'd suggest first swapping variable declaration and '(sum) =3D 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? --=20 Pawel Jakub Dawidek http://www.wheelsystems.com pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --maH1Gajj2nflutpK Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkwUrpEACgkQForvXbEpPzQNbACgtDcalgrjF5GBlPfRSqb/+tLS B54AoIK1ff4fyjN56XUlJuYIAxtzRbEK =CVoE -----END PGP SIGNATURE----- --maH1Gajj2nflutpK--