blob: 70a0538296cc8b4ac5efd615dab7ed3b8fdd2b46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include "common.h"
#include <ddekit/initcall.h>
#ifdef DDEKIT_DEBUG_INITCALL
#undef DDEBUG
#define DDEBUG DDEKIT_DEBUG_INITCALL
#endif
#include "debug.h"
static struct __ddekit_initcall_s head = {0,0,0};
/****************************************************************************/
/* __ddekit_add_initcall */
/****************************************************************************/
void __attribute__((used))
__ddekit_add_initcall(struct __ddekit_initcall_s * ic) {
/* This function is required for the DDEKIT_INITCALL makro */
struct __ddekit_initcall_s *i = 0;
DDEBUG_MSG_VERBOSE("adding initcall (%p) to %p with prio %d head at %p",
ic, ic->func, ic->prio, &head);
for (i = &head; i; i=i->next)
{
if (!i->next) {
i->next = ic;
return;
}
if (i->next->prio > ic->prio) {
ic->next = i->next;
i->next = ic;
return;
}
}
}
/****************************************************************************/
/* ddekit_do_initcalls */
/****************************************************************************/
void ddekit_do_initcalls()
{
struct __ddekit_initcall_s *i = 0;
DDEBUG_MSG_VERBOSE("exectuing initcalls (head at %p, head->next = %p)",
&head, head.next);
for (i = head.next; i; i=i->next) {
DDEBUG_MSG_VERBOSE("executing initcall: %p with prio %d",
i->func, i->prio);
i->func();
}
}
|