root / lab4 / .minix-src / include / ddekit / initcall.h @ 14
History | View | Annotate | Download (805 Bytes)
1 |
#ifndef _DDEKIT_INITCALL_H
|
---|---|
2 |
#define _DDEKIT_INITCALL_H
|
3 |
#include <ddekit/ddekit.h> |
4 |
#include <ddekit/attribs.h> |
5 |
|
6 |
typedef void (*ddekit_initcall_t)(void); |
7 |
|
8 |
struct __ddekit_initcall_s {
|
9 |
ddekit_initcall_t func; |
10 |
int prio;
|
11 |
struct __ddekit_initcall_s *next;
|
12 |
}; |
13 |
|
14 |
void __ddekit_add_initcall(struct __ddekit_initcall_s *dis); |
15 |
|
16 |
/* Define a function to be a DDEKit initcall.
|
17 |
* This is the right place to place Linux' module_init functions & Co.
|
18 |
*/
|
19 |
#define DDEKIT_INITCALL(fn) DDEKIT_CTOR(fn, 1) |
20 |
|
21 |
#define DDEKIT_CTOR(fn, prio) \
|
22 |
static void __attribute__((used)) __attribute__((constructor))\ |
23 |
__ddekit_initcall_##fn() { \ |
24 |
static struct __ddekit_initcall_s dis = {(ddekit_initcall_t)fn, prio, 0}; \ |
25 |
__ddekit_add_initcall(&dis); } |
26 |
|
27 |
/* Runs all registered initcalls. */
|
28 |
void ddekit_do_initcalls(void); |
29 |
|
30 |
#endif
|