Hi,<br><br>If I understand correctly, this is the same type of idea of the linux kernel's __init magic, except that no code cleanup is done?<br><br>Regards<br>Sebastien<br><br><div class="gmail_quote">On Fri, Jun 25, 2010 at 3:28 AM, Harald Welte <span dir="ltr"><<a href="mailto:laforge@gnumonks.org">laforge@gnumonks.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi!<br>
<br>
As indicated in other mails, we now have support for gcc-style constructors<br>
in OsmocomBB.  The way to use them is relatively easy:  Simply put<br>
"__attribute__((constructor))" at the function that you want to be<br>
called during initialization.<br>
<br>
The way how this works is like this:<br>
* gcc and the linker create a table of function pointers to all the<br>
  functions with that attribute<br>
* the code in compal_ramload_start.S takes care of calling<br>
  lib/ctors.s:do_global_ctors() which iterates over the list<br>
  and calls each constructor<br>
<br>
This concept is now used for things like prim_fbsb_init() in layer1,<br>
but I have also started to use it for board_init().  This means that<br>
board_init() no longer needs to be called from the main() function<br>
of each app.<br>
<br>
We can probably put more stuff into constructors, but we should also<br>
be careful as with gcc-4.0.2 we cannot yet indicate priorities and thus<br>
there is no explicit way to control the ordering in case of dependencies.<br>
<br>
Regards,<br>
        Harald<br>
<font color="#888888">--<br>
- Harald Welte <<a href="mailto:laforge@gnumonks.org">laforge@gnumonks.org</a>>           <a href="http://laforge.gnumonks.org/" target="_blank">http://laforge.gnumonks.org/</a><br>
============================================================================<br>
"Privacy in residential applications is a desirable marketing option."<br>
                                                  (ETSI EN 300 175-7 Ch. A6)<br>
<br>
</font></blockquote></div><br>