Constructors

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Sébastien Lorquet squalyl at gmail.com
Mon Jun 28 14:19:01 UTC 2010


Hi,

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?

Regards
Sebastien

On Fri, Jun 25, 2010 at 3:28 AM, Harald Welte <laforge at gnumonks.org> wrote:

> Hi!
>
> As indicated in other mails, we now have support for gcc-style constructors
> in OsmocomBB.  The way to use them is relatively easy:  Simply put
> "__attribute__((constructor))" at the function that you want to be
> called during initialization.
>
> The way how this works is like this:
> * gcc and the linker create a table of function pointers to all the
>  functions with that attribute
> * the code in compal_ramload_start.S takes care of calling
>  lib/ctors.s:do_global_ctors() which iterates over the list
>  and calls each constructor
>
> This concept is now used for things like prim_fbsb_init() in layer1,
> but I have also started to use it for board_init().  This means that
> board_init() no longer needs to be called from the main() function
> of each app.
>
> We can probably put more stuff into constructors, but we should also
> be careful as with gcc-4.0.2 we cannot yet indicate priorities and thus
> there is no explicit way to control the ordering in case of dependencies.
>
> Regards,
>        Harald
> --
> - Harald Welte <laforge at gnumonks.org>
> http://laforge.gnumonks.org/
>
> ============================================================================
> "Privacy in residential applications is a desirable marketing option."
>                                                  (ETSI EN 300 175-7 Ch. A6)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/baseband-devel/attachments/20100628/65dca256/attachment.htm>


More information about the baseband-devel mailing list