Constructors

Harald Welte laforge at gnumonks.org
Fri Jun 25 01:28:09 UTC 2010


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)




More information about the baseband-devel mailing list