1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016, Olivier MATZ <zer0@droids-corp.org>
6 * @defgroup nodes Nodes
9 * @brief Register initialization routines.
15 #include <sys/queue.h>
17 #include <ecoli_log.h>
18 #include <ecoli_node.h>
21 * Register initialization and exit callbacks. These callbacks are
22 * ordered by priority: for initialization, the lowest priority is called
23 * first. For exit, the callbacks are invoked in reverse order.
25 #define EC_INIT_REGISTER(t) \
26 static void ec_init_init_##t(void); \
27 static void __attribute__((constructor, used)) \
28 ec_init_init_##t(void) \
30 ec_init_register(&t); \
34 * Type of init function. Return 0 on success, -1 on error.
36 typedef int (ec_init_t)(void);
39 * Type of exit function.
41 typedef void (ec_exit_t)(void);
43 TAILQ_HEAD(ec_init_list, ec_init);
46 * A structure describing a test case.
49 TAILQ_ENTRY(ec_init) next; /**< Next in list. */
50 ec_init_t *init; /**< Init function. */
51 ec_exit_t *exit; /**< Exit function. */
52 unsigned int priority; /**< Priority (0=first, 99=last) */
56 * Register an initialization function.
59 * A pointer to a ec_init structure to be registered.
61 void ec_init_register(struct ec_init *test);
64 * Initialize ecoli library.
66 * Must be called before any other function from libecoli, except
67 * ec_malloc_register().
70 * 0 on success, -1 on error (errno is set).
75 * Uninitialize ecoli library.