From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LvYMr-0004UE-JT for mharc-grub-devel@gnu.org; Sun, 19 Apr 2009 10:51:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LvYMq-0004U9-Ga for grub-devel@gnu.org; Sun, 19 Apr 2009 10:51:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LvYMl-0004Ts-1o for grub-devel@gnu.org; Sun, 19 Apr 2009 10:51:35 -0400 Received: from [199.232.76.173] (port=55902 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LvYMk-0004Tp-T6 for grub-devel@gnu.org; Sun, 19 Apr 2009 10:51:30 -0400 Received: from mail-ew0-f160.google.com ([209.85.219.160]:34066) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LvYMk-0001Bm-6c for grub-devel@gnu.org; Sun, 19 Apr 2009 10:51:30 -0400 Received: by ewy4 with SMTP id 4so1496905ewy.42 for ; Sun, 19 Apr 2009 07:51:29 -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=SB7JYJMIVH3BtindlfGNnoQyNgGvHfPenz9SnZriElA=; b=i0FI1gyAtTZSgu+aJq+kc3snDmJOGIO/F3n19S7LzRbXsHt0MlvSZ/+DwCvXXWEnjF V3VFZUVIZmmmUV/UVYJ48CieDLMHz0r8f335wXFe3uAevBYaX+YAFb1q4aN3QUqlBBxz LCcN37DAROkWiTqGgW1FXxPgy2tOBlUl2jCtY= 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=GHCEmoFs+qr/uaIB6JNRdAzRY7W4Ep60TcR4yRMHmtQN8xTt/rEqvzYgBj07VfuIgS ICr3py0UbS26oU1zuyNK+tdirZ3bc1GFerx/NKr/+S4sEhGbBXx050chc/qJfM1LQb6d wN5wkeqB+KSCGZHAnop9G4uuG/m4WdVXRCLco= MIME-Version: 1.0 Received: by 10.210.37.16 with SMTP id k16mr4798334ebk.54.1240152689137; Sun, 19 Apr 2009 07:51:29 -0700 (PDT) In-Reply-To: <20090419102958.tfy97u7lc8400c4c-cebfxv@webmail.spamcop.net> References: <1239983697.4383.15.camel@mj> <1240004288.9057.5.camel@mj> <20090419102958.tfy97u7lc8400c4c-cebfxv@webmail.spamcop.net> Date: Sun, 19 Apr 2009 16:51:29 +0200 Message-ID: From: Vladimir Serbinenko To: The development of GRUB 2 Content-Type: multipart/alternative; boundary=0015174c142280d75f0467e98cc7 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: Sun, 19 Apr 2009 14:51:36 -0000 --0015174c142280d75f0467e98cc7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit In my opinion a far better way would be to add an additional void * argument which is passed unchanged to the hook. Like: struct local { ... }; main_func () { struct local locvars; grub_*_iterate (arg1,arg2,arg3, &locvars); } hook (arg1, arg2, arg3, voidparg) { struct local *locvars = (struct local *) voidparg; } On Sun, Apr 19, 2009 at 4:29 PM, Pavel Roskin wrote: > Quoting Bean : > > Yeah, I agree with you. The conversion will take some effort, but it >> could payoff in the long run. Perhaps we can achieve this in two >> steps: >> >> 1, Change nested function definition to accept only one parameter. For >> function with multiple parameters, place them in a structure and pass >> the pointer. This would eliminate NESTED_FUNC_ATTR, as the regparm >> issue won't occur in function with only one parameter. >> >> 2. Eliminate nested function. This would be easier after step 1. As we >> now pass parameters in a structure, we can append extra variables at >> the end, and cast it to the required type. Inside the callback >> function, we cast it back to use the extra fields. >> > > That's an excellent plan! Thank you! > > Considering the amount of changes, it may be a good idea to use the git > mirror with stgit, so that several patches can be made and everything is > well tested together before applying. > > -- > Regards, > Pavel Roskin > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > --0015174c142280d75f0467e98cc7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable In my opinion a far better way would be to add an additional void * argumen= t which is passed unchanged to the hook. Like:

struct local
{
= =A0=A0 ...
};

main_func ()
{
struct local locvars;

g= rub_*_iterate (arg1,arg2,arg3, &locvars);
}

hook (arg1, arg2, arg3, voidparg)
{
struct local *locvars = =3D (struct local *) voidparg;
=A0=A0
}

On Sun, Apr 19, 2009 at 4:29= PM, Pavel Roskin <p= roski@gnu.org> wrote:
Quoting Bean <bean123ch@gmail.com>:

Yeah, I agree with you. The conversion will take some effort, but it
could payoff in the long run. Perhaps we can achieve this in two
steps:

1, Change nested function definition to accept only one parameter. For
function with multiple parameters, place them in a structure and pass
the pointer. This would eliminate NESTED_FUNC_ATTR, as the regparm
issue won't occur in function with only one parameter.

2. Eliminate nested function. This would be easier after step 1. As we
now pass parameters in a structure, we can append extra variables at
the end, and cast it to the required type. Inside the callback
function, we cast it back to use the extra fields.

That's an excellent plan! =A0Thank you!

Considering the amount of changes, it may be a good idea to use the git mir= ror with stgit, so that several patches can be made and everything is well = tested together before applying.

--
Regards,
Pavel Roskin


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

--0015174c142280d75f0467e98cc7--