preempt: add module initialization safety checks
[bertos.git] / bertos / kern / preempt.c
index f285d43f5a53c3e3932f3d1d5edca9be072a26d2..825505019aebeae98ed03f7efe77bc383ecd385a 100644 (file)
  * \author Bernie Innocenti <bernie@codewiz.org>
  */
 
+#include <cfg/cfg_kern.h>
+
+#if CONFIG_KERN_PREEMPT
+
 #include "proc_p.h"
 #include "proc.h"
 
 #include <cpu/irq.h>   // IRQ_DISABLE()...
 #include <drv/timer.h>
 #include <cfg/module.h>
+#include <cfg/depend.h>    // CONFIG_DEPEND()
+
+// Check config dependencies
+CONFIG_DEPEND(CONFIG_KERN_PREEMPT,    CONFIG_KERN_SCHED && CONFIG_TIMER_EVENTS && CONFIG_KERN_IRQ);
+CONFIG_DEPEND(CONFIG_KERN_PRI,        CONFIG_KERN_PREEMPT);
 
+MOD_DEFINE(preempt)
 
 int preempt_forbid_cnt;
 
@@ -140,4 +150,8 @@ void preempt_init(void)
        timer_add(&preempt_timer);
 
        idle_init();
+
+       MOD_INIT(preempt);
 }
+
+#endif // CONFIG_KERN_PREEMPT