From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MLzOA-0005yQ-HF for mharc-grub-devel@gnu.org; Wed, 01 Jul 2009 08:58:14 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MLzO8-0005y9-WB for grub-devel@gnu.org; Wed, 01 Jul 2009 08:58:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MLzO4-0005xT-3X for grub-devel@gnu.org; Wed, 01 Jul 2009 08:58:12 -0400 Received: from [199.232.76.173] (port=45608 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLzO4-0005xQ-0q for grub-devel@gnu.org; Wed, 01 Jul 2009 08:58:08 -0400 Received: from aybabtu.com ([69.60.117.155]:51149) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MLzO3-0004nh-Hf for grub-devel@gnu.org; Wed, 01 Jul 2009 08:58:07 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtp (Exim 4.69) (envelope-from ) id 1MLyKE-0007Lt-Mr for grub-devel@gnu.org; Wed, 01 Jul 2009 13:50:07 +0200 Received: from rmh by thorin with local (Exim 4.69) (envelope-from ) id 1MLzO0-0004cv-RZ for grub-devel@gnu.org; Wed, 01 Jul 2009 14:58:04 +0200 Date: Wed, 1 Jul 2009 14:58:04 +0200 From: Robert Millan To: The development of GRUB 2 Message-ID: <20090701125804.GA17770@thorin> References: <20090627121216.GA29067@thorin> <1246248556.22661.24.camel@mj> <20090629134900.GC20463@thorin> <1246316362.15956.63.camel@mj> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1246316362.15956.63.camel@mj> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) Subject: Re: [PATCH] export -boot parameter as qemu_boot{0,1,2} X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jul 2009 12:58:13 -0000 On Mon, Jun 29, 2009 at 06:59:22PM -0400, Pavel Roskin wrote: > On Mon, 2009-06-29 at 15:49 +0200, Robert Millan wrote: > > > > Use of a nested function seems totally unwarranted. > > > > I did it to make the code more readable. Declaring functions that will > > be used locally inside their scope improves code clarity and prevents > > mistakes (like attempting to run them from somewhere else). > > However, they are not widely used. In GRUB, nested functions are used > to allow passing them as callbacks that can access local variables of > the containing function. > > There is a problem associates with nested functions. Some versions of > gcc miscompile them with -mregparm=3. Arguments other than the first > one are not passed correctly. There was a test in configure.ac, but it > turned out to be wrong, so we are always specifying > __attribute__((__regparm__(1))) for nested functions taking more than > one argument on i386 (kernel code only). > > Just look for NESTED_FUNC_ATTR to see what I mean. We had several bugs > because NESTED_FUNC_ATTR wasn't used consistently. > > I don't know if NESTED_FUNC_ATTR is needed in your case, or it's only > needed when the function is passed as an argument. In any case, I think > it's an overkill for the problem you are solving. Isn't this something that should be handled at GCC level? When you declare a local variable as "static", GCC knows it should be allocated statically. Is there nothing similar for local functions? I'd rather rewrite the function differently than spreading it in different parts of the file. There's no need to make the code harder to figure out for the sake of this implementation problem. -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."