From owner-freebsd-current@FreeBSD.ORG Wed Feb 7 15:33:42 2007 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5226516A402; Wed, 7 Feb 2007 15:33:42 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from out5.smtp.messagingengine.com (out5.smtp.messagingengine.com [66.111.4.29]) by mx1.freebsd.org (Postfix) with ESMTP id DFED913C471; Wed, 7 Feb 2007 15:33:41 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from out1.internal (unknown [10.202.2.149]) by out1.messagingengine.com (Postfix) with ESMTP id 2EAE11A90F0; Wed, 7 Feb 2007 10:04:18 -0500 (EST) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by out1.internal (MEProxy); Wed, 07 Feb 2007 10:04:18 -0500 X-Sasl-enc: 5FH2utRT9qk7VcnujhggSgRnQf1cT6jw1en1acSw8up3 1170860657 Received: from [192.168.123.18] (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTP id F25A11356D; Wed, 7 Feb 2007 10:04:16 -0500 (EST) Message-ID: <45C9EA6F.1080503@FreeBSD.org> Date: Wed, 07 Feb 2007 15:04:15 +0000 From: "Bruce M. Simpson" User-Agent: Thunderbird 1.5.0.9 (X11/20070125) MIME-Version: 1.0 To: Luigi Rizzo References: <20070207004131.A62183@xorpc.icir.org> <15241.SV0BLFJbGwk=.1170843949.squirrel@koef.zs64.net> <20070207024918.D63529@xorpc.icir.org> <3bbf2fe10702070255q58ab6c9fn2b393cfbc75a3fb@mail.gmail.com> <20070207025916.A63989@xorpc.icir.org> In-Reply-To: <20070207025916.A63989@xorpc.icir.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Attilio Rao , Stefan Bethke , current@freebsd.org Subject: Re: C macro to find the next power of 2 ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2007 15:33:42 -0000 Luigi Rizzo wrote: >> You cannot use this unless you don't rewrite as a preprocessing stub. >> > > that's why i am using my version and wrote it functionally. > All this talk of recursively evaluated CPP macros is making my head spin. We just want to compute LOG2(sizeof(struct foobar))+1 after all. Ooh, but many tried and died: http://swtch.com/gosling89ace.pdf http://groups.google.co.uk/group/comp.lang.c/browse_thread/thread/f34a65d3fe73a6d4/0d3322283427a51a?lnk=st&q=For+loop+equivalent+with+the+preprocessor&rnum=2&hl=en#0d3322283427a51a Go to the end of this thread, and it turns out C++ can *probably* do it through templatization. http://groups.google.co.uk/group/comp.lang.c/browse_thread/thread/95bfa768423adb4f/17eb99dbdf11d161?lnk=st&q=log2+preprocessor&rnum=1&hl=en#17eb99dbdf11d161 Good luck with that... Regards, BMS