event.h
Go to the documentation of this file.00001
00042 #ifndef KERN_EVENT_H
00043 #define KERN_EVENT_H
00044
00045 #include <cfg/compiler.h>
00046 #include "cfg/cfg_kern.h"
00047
00048 #if CONFIG_KERN
00049 #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS
00050 #include <kern/signal.h>
00051 #endif
00052
00053
00054 struct Process;
00055 #endif
00056
00057
00059 typedef void (*Hook)(void *);
00060
00061 typedef struct Event
00062 {
00063 void (*action)(struct Event *);
00064 union
00065 {
00066 #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS
00067 struct
00068 {
00069 struct Process *sig_proc;
00070 sigbit_t sig_bit;
00071 } Sig;
00072 #endif
00073 struct
00074 {
00075 Hook func;
00076 void *user_data;
00077 } Int;
00078 } Ev;
00079 } Event;
00080
00081 void event_hook_ignore(Event *event);
00082 void event_hook_signal(Event *event);
00083 void event_hook_softint(Event *event);
00084
00086 #define event_initNone(e) \
00087 ((e)->action = event_hook_ignore)
00088
00090 INLINE Event event_createNone(void);
00091 INLINE Event event_createNone(void)
00092 {
00093 Event e;
00094 e.action = event_hook_ignore;
00095 return e;
00096 }
00097
00099 #define event_initSoftint(e,f,u) \
00100 ((e)->action = event_hook_softint,(e)->Ev.Int.func = (f), (e)->Ev.Int.user_data = (u))
00101
00103 INLINE Event event_createSoftint(Hook func, void *user_data)
00104 {
00105 Event e;
00106 e.action = event_hook_softint;
00107 e.Ev.Int.func = func;
00108 e.Ev.Int.user_data = user_data;
00109 return e;
00110 }
00111
00112 #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS
00113
00115 #define event_initSignal(e,p,s) \
00116 ((e)->action = event_hook_signal,(e)->Ev.Sig.sig_proc = (p), (e)->Ev.Sig.sig_bit = (s))
00117
00119 INLINE Event event_createSignal(struct Process *proc, sigbit_t bit)
00120 {
00121 Event e;
00122 e.action = event_hook_signal;
00123 e.Ev.Sig.sig_proc = proc;
00124 e.Ev.Sig.sig_bit = bit;
00125 return e;
00126 }
00127
00128 #endif
00129
00131 INLINE void event_do(struct Event *e)
00132 {
00133 e->action(e);
00134 }
00135
00136 #endif