[Top] [All Lists]

Re: __initfunc(), kernel coding logic?

Subject: Re: __initfunc(), kernel coding logic?
Date: Thu, 2 Jul 1998 19:09:42 +0200
In-reply-to: <Pine.LNX.3.95.980702172623.159A-100000@schnecke.dutch.mountain>; from Richard van den Berg on Thu, Jul 02, 1998 at 05:28:15PM +0200
References: <Pine.LNX.3.95.980702172623.159A-100000@schnecke.dutch.mountain>
On Thu, Jul 02, 1998 at 05:28:15PM +0200, Richard van den Berg wrote:

> I am stuck with __initfunc(), trying to make the ethernet driver more
> talkative while booting I didn't succeed. So I replaced it with these
> lines of code:
> ---------------
> #include <linux/kernel.h>
> __initfunc(void my_test(void))
> {
>       printk("see if this shows up\n");
>       return 0;
> }
> ---------------
> It compiles with "declance.c:4: warning: return-type defaults to `int'"
> and gets nicely archived and linked but doesn't show up when booting. My
> question is what likes __initfunc() to see to behave decently?

__initfunc() is just a memory usage optimization.  After the kernel has
initialized itself it will dump all the code and data which has been
declared as only being used during the initialization.  In other words
you don't need to use it.  That memory is being freed in sys_setup(),
therefore you are not allowed to use initfunc/data after that point.
I assume you've been including <linux/init.h> to get the right definitions,
didn't you.

There is no obvious bug in your code except that ``return 0'' is bogus
for a void function.  Maybe you're getting caught by the effect that text
printed via printk() during the very early startup will not be printed
before console_init has been completed?


<Prev in Thread] Current Thread [Next in Thread>