Subject: Re: foo_init()s in main() [was: CVS commit: src/sys]
To: Simon Burge <email@example.com>
From: Jason Thorpe <firstname.lastname@example.org>
Date: 11/22/2005 09:57:52
On Nov 22, 2005, at 1:50 AM, Simon Burge wrote:
> Martin Husemann wrote:
>> On Tue, Nov 22, 2005 at 11:29:35AM +1100, Simon Burge wrote:
>>> It really seems like we should do something to automate this, say
>>> on the FreeBSD sysinit stuff or linksets or something.
>> Yes, we should.
>> Could anyone give a summary of "FreeBSD sysinit" stuff?
> In a very brief nut-shell there's a macro SYSINIT:
> #define SYSINIT(uniquifier, subsystem, order, func, ident) \
> which builds a link set of initialisation functions.
> "uniquifier" is used to build the link set variable name.
> "subsystem" is
> a numeric constant that defines the order of the function in the
> sequence . "order" sorts orders within a subsystem . "func"
> is the
> function, and "ident" appears to be an arg to "func".
I'd just like to state for the record that I don't like the FreeBSD
SYSINIT stuff. It still requires a centralized list of "subsystems",
and still explicitly encodes the order. So, now instead of looking
in one place for the order of initialization, you have to look in a
bunch of random places.
I would much prefer we go with a lazy initialization scheme.
> To pick an example at random, net/route.c then says:
> SYSINIT(route, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, route_init, 0);