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_proc.h"
00047 #include "cfg/cfg_signal.h"
00048
00049 #if CONFIG_KERN
00050 #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS
00051 #include <kern/signal.h>
00052 #endif
00053
00054
00055 struct Process;
00056 #endif
00057
00058
00060 typedef void (*Hook)(void *);
00061
00062 typedef struct Event
00063 {
00064 void (*action)(struct Event *);
00065 union
00066 {
00067 #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS
00068 struct
00069 {
00070 struct Process *sig_proc;
00071 sigbit_t sig_bit;
00072 } Sig;
00073 #endif
00074 struct
00075 {
00076 Hook func;
00077 void *user_data;
00078 } Int;
00079 } Ev;
00080 } Event;
00081
00082 void event_hook_ignore(Event *event);
00083 void event_hook_signal(Event *event);
00084 void event_hook_softint(Event *event);
00085
00087 #define event_initNone(e) \
00088 ((e)->action = event_hook_ignore)
00089
00091 INLINE Event event_createNone(void);
00092 INLINE Event event_createNone(void)
00093 {
00094 Event e;
00095 e.action = event_hook_ignore;
00096 return e;
00097 }
00098
00100 #define event_initSoftint(e,f,u) \
00101 ((e)->action = event_hook_softint,(e)->Ev.Int.func = (f), (e)->Ev.Int.user_data = (u))
00102
00104 INLINE Event event_createSoftint(Hook func, void *user_data)
00105 {
00106 Event e;
00107 e.action = event_hook_softint;
00108 e.Ev.Int.func = func;
00109 e.Ev.Int.user_data = user_data;
00110 return e;
00111 }
00112
00113 #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS
00114
00116 #define event_initSignal(e,p,s) \
00117 ((e)->action = event_hook_signal,(e)->Ev.Sig.sig_proc = (p), (e)->Ev.Sig.sig_bit = (s))
00118
00120 INLINE Event event_createSignal(struct Process *proc, sigbit_t bit)
00121 {
00122 Event e;
00123 e.action = event_hook_signal;
00124 e.Ev.Sig.sig_proc = proc;
00125 e.Ev.Sig.sig_bit = bit;
00126 return e;
00127 }
00128
00129 #endif
00130
00132 INLINE void event_do(struct Event *e)
00133 {
00134 e->action(e);
00135 }
00136
00137 #endif