On Sat, Mar 03, 2012 at 11:46:01PM +1100, Graeme Russ wrote:
> > Perhaps the macro could be expanded to include a prototype for the function,
> 
> How so - Can you provide a code example?

Sure, since all the functions are int(*)(void), just something like this:

+#define INIT_FUNC(fn, init_name, deps) \
+    static int ##fn (void); \
+    static const char __init_func_ ## fn[] __used \
+    __attribute__((__section__(".initfuncs"))) = \
+    "(" #fn ":" #init_name ";" #deps ")\n";

(I'm guessing static is OK for this use case?).

The patch overall looks like it will make it a lot simpler to understand and
change the sequence initialisation functions are called, which is a very good
thing. I'm just mindful of getting easy-to-diagnose error messages back when
things go wrong.

An example:

        static int f1(int x)
        {
                return x + 1;
        }

        #define INIT_FUNC(fn) \
                static void fn(int)

        INIT_FUNC(f1);

gcc immediately throws the following error:

        t2.c:9: error: conflicting types for ‘f1’
        t2.c:1: note: previous definition of ‘f1’ was here

which is pretty clear.

Bye for now,
-- 
Laurence Withers, <lwith...@guralp.com>                http://www.guralp.com/
Direct tel:+447753988197 or tel:+443333408643               Software Engineer
General support queries: <supp...@guralp.com>         CMG-DCM CMG-EAM CMG-NAM
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to