From owner-svn-src-head@FreeBSD.ORG Sun Jun 13 13:24:18 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 BD072106566C; Sun, 13 Jun 2010 13:24:18 +0000 (UTC) (envelope-from lstewart@freebsd.org) Received: from lauren.room52.net (lauren.room52.net [210.50.193.198]) by mx1.freebsd.org (Postfix) with ESMTP id 516598FC17; Sun, 13 Jun 2010 13:24:18 +0000 (UTC) Received: from lawrence1.loshell.room52.net (unknown [59.167.184.191]) by lauren.room52.net (Postfix) with ESMTPSA id B428D7E871; Sun, 13 Jun 2010 23:24:16 +1000 (EST) Message-ID: <4C14DBFF.5050305@freebsd.org> Date: Sun, 13 Jun 2010 23:24:15 +1000 From: Lawrence Stewart User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-AU; rv:1.9.1.9) Gecko/20100405 Thunderbird/3.0.4 MIME-Version: 1.0 To: Gabor Kovesdan References: <201006130239.o5D2du3m086332@svn.freebsd.org> <20100613101025.GD1320@garage.freebsd.pl> <4C14B0EA.8090500@FreeBSD.org> In-Reply-To: <4C14B0EA.8090500@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 13:24:18 -0000 On 06/13/10 20:20, Gabor Kovesdan wrote: > >>> >>> +/* >>> + * 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) >> I'd suggest first swapping variable declaration and '(sum) = 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? > And why using old BSD-stlye u_int? style(9) also suggest using ISO C types. From extern u_int mp_maxid; ... #define CPU_FOREACH(i) \ for ((i) = 0; (i) <= mp_maxid; (i)++) \ if (!CPU_ABSENT((i))) Made sense to keep the types for i and mp_maxid the same. Happy to change if you have a better suggestion. Cheers, Lawrence