Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Luu6n-0007PB-Mf for mharc-grub-devel@gnu.org; Fri, 17 Apr 2009 15:52:21 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Luu6l-0007OH-OV for grub-devel@gnu.org; Fri, 17 Apr 2009 15:52:19 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Luu6h-0007Lo-9K for grub-devel@gnu.org; Fri, 17 Apr 2009 15:52:19 -0400 Received: from [199.232.76.173] (port=56807 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Luu6g-0007Li-Kb for grub-devel@gnu.org; Fri, 17 Apr 2009 15:52:14 -0400 Received: from mail-ew0-f160.google.com ([209.85.219.160]:41695) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Luu6f-0001t1-La for grub-devel@gnu.org; Fri, 17 Apr 2009 15:52:14 -0400 Received: by ewy4 with SMTP id 4so1044194ewy.42 for ; Fri, 17 Apr 2009 12:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=X6l8rI5HZ2v/EJg7QzSzDZYad1aNYaobFAtC5jV833M=; b=RljcOtD47lYYEZeXIiq4WOucH6/i5a2UhOoCQmiDyWgYhzIaVu+iMR8SYSLvWG1RyU T8DkBT4kIKc5LIMdRt2Vii19WuyMwPV0uevZ6yl/rYxYhgZhhad4aVK2olHwKdqzVnhf lllFVHAdaNUKBjGN3yf0MAB//qGEXBvvaiHIg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=aI8FUVHVtw8M0tJ/UyoWl6yEAuJgfGJ1rwil4qKPwACI7exDi3OY1un8Ei72x13qcT B5WKqvFWCdMx2kWG/ps/KfvK83Zd8QGqeQcrduBVzubiza3jOkEsYxOR+cPKeawUW9xB 7uxxZaFnyISS+3aQK9DmT+JAwYLRD2r2yf8Eg= MIME-Version: 1.0 Received: by 10.210.139.15 with SMTP id m15mr2117894ebd.38.1239997931768; Fri, 17 Apr 2009 12:52:11 -0700 (PDT) In-Reply-To: References: <1239983697.4383.15.camel@mj> Date: Fri, 17 Apr 2009 21:52:11 +0200 Message-ID: From: Vladimir Serbinenko To: The development of GRUB 2 Content-Type: multipart/alternative; boundary=0015174c17783ece060467c584e6 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: Eliminating nested functions 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: Fri, 17 Apr 2009 19:52:20 -0000 --0015174c17783ece060467c584e6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Fri, Apr 17, 2009 at 9:33 PM, Bean wrote: > Hi, > > One of the advantage of nested function is to use local variables. > Without it, we would need to pass them as global variable, or add > custom data pointer in many of the iterate function, which would make > the code a lot uglier IMO. > Do you have information in which direction it will influence the size of kernel? (trampoline vs global vs custom pointer) > > On Fri, Apr 17, 2009 at 11:54 PM, Pavel Roskin wrote: > > Hello! > > > > While I have just applied a patch adding NESTED_FUNC_ATTR to several > > functions as an emergency fix for a major breakage in ata, ohci, uhci > > and lspci modules, I would prefer a more radical solution. > > > > I suggest that we eliminate all nested functions. The reasons are: > > > > 1) They make the code less readable, as they make the parent functions > > longer. > > > > 2) They have problems with some popular compilers, as recent as gcc-4.0 > > when regparm(3) is used. > > > > 3) We failed to implement a reliable test for such problems. We are > > using regparm(1) for all compilers. > > > > 4) The existing test is one of the obstacles making it impossible to > > compile without having libc for the target (x86_64->i386 would be really > > nice), as we need to run the compiled test executable. > > > > 5) Non-i386 architectures define NESTED_FUNC_ATTR as an empty symbol, so > > developers on such architectures don't see if they use it correctly. > > > > 6) NESTED_FUNC_ATTR tends to proliferate to the file scope functions, as > > it happened with grub_pci_iterate(). It only takes one caller using a > > nested function to force NESTED_FUNC_ATTR on all functions used as an > > argument to the same function. > > > > We can give all formerly nested functions better, more descriptive names > > starting like other functions in the file and ending with "_iter". > > > > -- > > Regards, > > Pavel Roskin > > > > > > _______________________________________________ > > Grub-devel mailing list > > Grub-devel@gnu.org > > http://lists.gnu.org/mailman/listinfo/grub-devel > > > > > > -- > Bean > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > --0015174c17783ece060467c584e6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Fri, Apr 17, 2009 at 9:33 PM, Bean <bean123ch@gmail.= com> wrote:
Hi,

One of the advantage of nested function is to use local variables.
Without it, we would need to pass them as global variable, or add
custom data pointer in many of the iterate function, which would make
the code a lot uglier IMO.
Do you have= information in which direction it will influence the size of kernel? (tram= poline vs global vs custom pointer)
=A0

On Fri, Apr 17, 2009 at 11:54 PM, Pavel Roskin <proski@gnu.org> wrote:
> Hello!
>
> While I have just applied a patch adding NESTED_FUNC_ATTR to several > functions as an emergency fix for a major breakage in ata, ohci, uhci<= br> > and lspci modules, I would prefer a more radical solution.
>
> I suggest that we eliminate all nested functions. =A0The reasons are:<= br> >
> 1) They make the code less readable, as they make the parent functions=
> longer.
>
> 2) They have problems with some popular compilers, as recent as gcc-4.= 0
> when regparm(3) is used.
>
> 3) We failed to implement a reliable test for such problems. =A0We are=
> using regparm(1) for all compilers.
>
> 4) The existing test is one of the obstacles making it impossible to > compile without having libc for the target (x86_64->i386 would be r= eally
> nice), as we need to run the compiled test executable.
>
> 5) Non-i386 architectures define NESTED_FUNC_ATTR as an empty symbol, = so
> developers on such architectures don't see if they use it correctl= y.
>
> 6) NESTED_FUNC_ATTR tends to proliferate to the file scope functions, = as
> it happened with grub_pci_iterate(). =A0It only takes one caller using= a
> nested function to force NESTED_FUNC_ATTR on all functions used as an<= br> > argument to the same function.
>
> We can give all formerly nested functions better, more descriptive nam= es
> starting like other functions in the file and ending with "_iter&= quot;.
>
> --
> Regards,
> Pavel Roskin
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



--
Bean


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

--0015174c17783ece060467c584e6--