From owner-svn-src-all@FreeBSD.ORG Fri Jun 11 17:05:05 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 8AC791065693; Fri, 11 Jun 2010 17:05:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 5D7438FC23; Fri, 11 Jun 2010 17:05:05 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 0EE8C46C7A; Fri, 11 Jun 2010 13:05:05 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 522288A050; Fri, 11 Jun 2010 13:05:04 -0400 (EDT) From: John Baldwin To: src-committers@freebsd.org Date: Fri, 11 Jun 2010 13:04:49 -0400 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) References: <201006111556.o5BFuIEi020826@svn.freebsd.org> In-Reply-To: <201006111556.o5BFuIEi020826@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201006111304.49966.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Fri, 11 Jun 2010 13:05:04 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r209050 - 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: Fri, 11 Jun 2010 17:05:05 -0000 On Friday 11 June 2010 11:56:18 am John Baldwin wrote: > Author: jhb > Date: Fri Jun 11 15:56:18 2010 > New Revision: 209050 > URL: http://svn.freebsd.org/changeset/base/209050 > > Log: > Add helper macros to iterate over available CPUs in the system. > CPU_FOREACH(i) iterates over the CPU IDs of all available CPUs. The > CPU_FIRST() and CPU_NEXT(i) macros can also be used to iterate over > available CPU IDs. CPU_NEXT(i) wraps around to CPU_FIRST() rather than > returning some sort of terminator. The intended use case for CPU_FIRST() and CPU_NEXT() is to use it to do things like this: u_int hash[64]; int i, j; j = CPU_FIRST(); for (i = 0; i < 64; i++) { hash[i] = j; j = CPU_NEXT(j); } If the auto-wrapping semantics of CPU_NEXT() is too odd, we could make it return NOCPU when it hits the end of the list instead perhaps and use some other macro to provide the current CPU_NEXT()-like behavior. -- John Baldwin