From: Robert Millan <rmh@aybabtu.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] export -boot parameter as qemu_boot{0,1,2}
Date: Wed, 1 Jul 2009 14:58:04 +0200 [thread overview]
Message-ID: <20090701125804.GA17770@thorin> (raw)
In-Reply-To: <1246316362.15956.63.camel@mj>
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."
prev parent reply other threads:[~2009-07-01 12:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-27 12:12 [PATCH] export -boot parameter as qemu_boot{0,1,2} Robert Millan
2009-06-29 4:09 ` Pavel Roskin
2009-06-29 13:49 ` Robert Millan
2009-06-29 20:18 ` Vladimir 'phcoder' Serbinenko
2009-06-29 22:31 ` Pavel Roskin
2009-06-29 22:59 ` Pavel Roskin
2009-07-01 12:58 ` Robert Millan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090701125804.GA17770@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.