X-Git-Url: http://git.droids-corp.org/?p=protos%2Flibecoli.git;a=blobdiff_plain;f=include%2Fecoli_init.h;h=80a0c01c8732c993154e06731b10a4d211f66361;hp=4e8bc1e5e11219a9039f17b01ab1363efa703154;hb=24da58b43f922ab7aa378d864a83b10746076ac8;hpb=ec731385f1ed38a35e4e0df83e5ae4e8b8151df6 diff --git a/include/ecoli_init.h b/include/ecoli_init.h index 4e8bc1e..80a0c01 100644 --- a/include/ecoli_init.h +++ b/include/ecoli_init.h @@ -14,6 +14,11 @@ #include #include +/** + * Register initialization and exit callbacks. These callbacks are + * ordered by priority: for initialization, the lowest priority is called + * first. For exit, the callbacks are invoked in reverse order. + */ #define EC_INIT_REGISTER(t) \ static void ec_init_init_##t(void); \ static void __attribute__((constructor, used)) \ @@ -27,6 +32,11 @@ */ typedef int (ec_init_t)(void); +/** + * Type of exit function. + */ +typedef void (ec_exit_t)(void); + TAILQ_HEAD(ec_init_list, ec_init); /** @@ -35,6 +45,7 @@ TAILQ_HEAD(ec_init_list, ec_init); struct ec_init { TAILQ_ENTRY(ec_init) next; /**< Next in list. */ ec_init_t *init; /**< Init function. */ + ec_exit_t *exit; /**< Exit function. */ unsigned int priority; /**< Priority (0=first, 99=last) */ }; @@ -47,7 +58,7 @@ struct ec_init { void ec_init_register(struct ec_init *test); /** - * Initialize ecoli library + * Initialize ecoli library. * * Must be called before any other function from libecoli, except * ec_malloc_register(). @@ -57,4 +68,9 @@ void ec_init_register(struct ec_init *test); */ int ec_init(void); +/** + * Uninitialize ecoli library. + */ +void ec_exit(void); + #endif