William,
Thanks for the reply.
Basically, I understand it's useful for the constructor.
I'm confused about why we should call it explicitly in the code,
because in the other codes, we needn't do this, maybe the gcc will
handle it.

On Sep 28, 10:21 am, "William W.-Y. Liang" <[email protected]>
wrote:
> Hi, Ivan,
>
> __ctor_list and __ctor_end are defined by the linker script, for a special
> section for 'constructors' defined in the kernel.
>
> William Lianghttp://www.ntut.edu.tw/~wyliang
>
> 2011/9/27 ivan <[email protected]>
>
>
>
>
>
>
>
> > Hi, guys
>
> > When I read the code of lk/kernel/main.c, I feel confused about using
> > "call_constructors()" during the
> > initialization, as below.  Could anyone interpret it to me? Your kind
> > help will be appreciated very much.
>
> > ******************************
> > void kmain(void)
> > {
> >        // get us into some sort of thread context
> >        thread_init_early();
>
> >        .....
>
> >        call_constructors();
> >        ......
> > }
>
> > static void call_constructors(void)
> > {
> >        void **ctor;
> >        ctor = &__ctor_list;
> >        while(ctor != &__ctor_end) {
> >                void (*func)(void);
>
> >                func = (void (*)())*ctor;
>
> >                func();
> >                ctor++;
> >        }
> > }
>
> > ******************************
>
> > --
> > unsubscribe: [email protected]
> > website:http://groups.google.com/group/android-kernel

-- 
unsubscribe: [email protected]
website: http://groups.google.com/group/android-kernel

Reply via email to