From owner-svn-src-all@FreeBSD.ORG Mon Jun 14 08:52:11 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA317106566B; Mon, 14 Jun 2010 08:52:10 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 62F0B8FC15; Mon, 14 Jun 2010 08:52:09 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o5E8q500010732 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 14 Jun 2010 11:52:05 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o5E8q5x8089057; Mon, 14 Jun 2010 11:52:05 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o5E8q5Lu089056; Mon, 14 Jun 2010 11:52:05 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 14 Jun 2010 11:52:05 +0300 From: Kostik Belousov To: Lawrence Stewart Message-ID: <20100614085205.GD13238@deviant.kiev.zoral.com.ua> References: <201006130239.o5D2du3m086332@svn.freebsd.org> <20100613101025.GD1320@garage.freebsd.pl> <4C158B71.205@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="G/vVCphCGw+yuveY" Content-Disposition: inline In-Reply-To: <4C158B71.205@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Pawel Jakub Dawidek Subject: Re: svn commit: r209119 - head/sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jun 2010 08:52:11 -0000 --G/vVCphCGw+yuveY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 14, 2010 at 11:52:49AM +1000, Lawrence Stewart wrote: > On 06/13/10 20:10, Pawel Jakub Dawidek wrote: > >On Sun, Jun 13, 2010 at 02:39:55AM +0000, Lawrence Stewart wrote: > [snip] > >> > >>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) > >> > >>+/* > >>+ * 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. >=20 > Given that the DPCPU variable name space is flat and variable names have= =20 > to be unique, perhaps something like the following would address the=20 > concerns raised? >=20 > #define DPCPU_SUM(n, var, sum) \ > do { \ > u_int _##n##_i; \ > (sum) =3D 0; \ > CPU_FOREACH(_##n##_i) \ > (sum) +=3D (DPCPU_ID_PTR(_##n##_i, n))->var; \ > } while (0) You do not have to jump through this. Mostly by convention, in our kernel sources, names with "_" prefix are reserved for the infrastructure (cannot say implementation). I think it is quite safe to use _i for the iteration variable. As an example of this, look at sys/sys/mount.h, implementation of VFS_NEEDGIANT, VFS_LOCK_GIANT etc macros. They do use gcc ({}) extension to provide function-like macros, but this is irrelevant. Or, look at the VFS_ASSERT_GIANT that is exactly like what you need. --G/vVCphCGw+yuveY Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkwV7bQACgkQC3+MBN1Mb4iMjACfeF3vcuEkv2MoW7zhQULyZrBi SjgAoPCy/3A3aegSBYjw4ht0YBFqX0o4 =NpwE -----END PGP SIGNATURE----- --G/vVCphCGw+yuveY--