This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: CYGBLD_ATTRIB_CONSTRUCTOR with CYGBLD_ATTRIB_INIT_PRI in C application
- From: Sergei Gavrikov <w3sg at SoftHome dot net>
- To: Edgar Grimberg <edgar dot grimberg at zylin dot com>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Thu, 18 Oct 2007 23:04:26 +0300
- Subject: Re: [ECOS] CYGBLD_ATTRIB_CONSTRUCTOR with CYGBLD_ATTRIB_INIT_PRI in C application
- References: <471751A8.8090005@zylin.com>
On Thu, Oct 18, 2007 at 02:29:28PM +0200, Edgar Grimberg wrote:
> Hi,
>
> Is it possible to have CYGBLD_ATTRIB_CONSTRUCTOR with
> CYGBLD_ATTRIB_INIT_PRI in a C application and have the priority taken
> into account?
I don't think that is allowed in pure C. But, in C you can call all
initializing functions according it's priorities from some place if you
describe the entries using CYG_HAL_TABLE_QUALIFIED_ENTRY macro. Look at
redboot.h, please. There is same constructions for that. It seems that
RedBoot_init(_f_, _p_) macro is that what you wanted.
Such a macro will let you easy to register the initializers from any C
file or module
MyApp_init(_foo_init, MyApp_INIT_FIRST);
..
MyApp_init(_bar_init, MyApp_INIT_BEFORE_THAT);
..
And your cyg_start() or other place must have the iterator(s) for the
init table(s) which makes a smart job of it
for (init_entry = __MyApp_INIT_TAB__;
init_entry != &__MyApp_INIT_TAB_END__; init_entry++) {
(*init_entry->fun) ();
}
--
Sergei
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss