Remove building with NOCRYPTO option
[minix.git] / minix / lib / libddekit / src / initcall.c
blob70a0538296cc8b4ac5efd615dab7ed3b8fdd2b46
1 #include "common.h"
3 #include <ddekit/initcall.h>
6 #ifdef DDEKIT_DEBUG_INITCALL
7 #undef DDEBUG
8 #define DDEBUG DDEKIT_DEBUG_INITCALL
9 #endif
11 #include "debug.h"
13 static struct __ddekit_initcall_s head = {0,0,0};
15 /****************************************************************************/
16 /* __ddekit_add_initcall */
17 /****************************************************************************/
18 void __attribute__((used))
19 __ddekit_add_initcall(struct __ddekit_initcall_s * ic) {
21 /* This function is required for the DDEKIT_INITCALL makro */
23 struct __ddekit_initcall_s *i = 0;
25 DDEBUG_MSG_VERBOSE("adding initcall (%p) to %p with prio %d head at %p",
26 ic, ic->func, ic->prio, &head);
28 for (i = &head; i; i=i->next)
30 if (!i->next) {
31 i->next = ic;
32 return;
34 if (i->next->prio > ic->prio) {
35 ic->next = i->next;
36 i->next = ic;
37 return;
42 /****************************************************************************/
43 /* ddekit_do_initcalls */
44 /****************************************************************************/
45 void ddekit_do_initcalls()
47 struct __ddekit_initcall_s *i = 0;
49 DDEBUG_MSG_VERBOSE("exectuing initcalls (head at %p, head->next = %p)",
50 &head, head.next);
52 for (i = head.next; i; i=i->next) {
53 DDEBUG_MSG_VERBOSE("executing initcall: %p with prio %d",
54 i->func, i->prio);
55 i->func();