[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Eliminating nested functions

From: Vladimir Serbinenko
Subject: Re: Eliminating nested functions
Date: Sun, 19 Apr 2009 16:51:29 +0200

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 <address@hidden> wrote:
Quoting Bean <address@hidden>:

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

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.

Pavel Roskin

Grub-devel mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]