1 2 #define COUNT(s) (__arraycount(s)) 3 4 struct call_handler { 5 const char *name; 6 const char *(*namefunc)(const message *m_out); 7 int (*outfunc)(struct trace_proc *proc, const message *m_out); 8 void (*infunc)(struct trace_proc *proc, const message *m_out, 9 const message *m_in, int failed); 10 }; 11 #define HANDLER(n,o,i) { .name = n, .outfunc = o, .infunc = i } 12 #define HANDLER_NAME(n,o,i) { .namefunc = n, .outfunc = o, .infunc = i } 13 14 struct calls { 15 endpoint_t endpt; 16 unsigned int base; 17 const struct call_handler *map; 18 unsigned int count; 19 }; 20 21 struct flags { 22 unsigned int mask; 23 unsigned int value; 24 const char *name; 25 }; 26 #define FLAG(f) { f, f, #f } 27 #define FLAG_MASK(m,f) { m, f, #f } 28 #define FLAG_ZERO(f) { ~0, f, #f } 29 30 /* not great, but it prevents a massive potential for typos.. */ 31 #define NAME(r) case r: return #r 32 #define TEXT(v) case v: text = #v; break 33