X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=kern%2Fmsg.h;h=b87881b4b7fb982f0c2bc771f3bd50cbf3c47124;hb=4fcd224037bf57ae177034834492de5521662afd;hp=0fcfffad45df50bb8039163b2c0e340e6e621da3;hpb=52cd7843bd8f38047401c768abee7309157344a2;p=bertos.git diff --git a/kern/msg.h b/kern/msg.h index 0fcfffad..b87881b4 100755 --- a/kern/msg.h +++ b/kern/msg.h @@ -18,6 +18,9 @@ /* * $Log$ + * Revision 1.2 2004/08/14 19:37:57 rasky + * Merge da SC: macros.h, pool.h, BIT_CHANGE, nome dei processi, etc. + * * Revision 1.1 2004/06/06 15:11:08 bernie * Import into DevLib. * @@ -26,6 +29,7 @@ #define KERN_MSG_H #include "event.h" +#include typedef struct MsgPort @@ -43,17 +47,30 @@ typedef struct Msg } Msg; -/*! Initialize a messge port */ -#define INITPORT(p) INITLIST(&(p)->queue) +/*! Initialize a message port */ +INLINE void msg_initPort(MsgPort* port, Event event) +{ + INITLIST(&port->queue); + port->evn = event; +} -/*! Queue a message to a message port */ -#define PUTMSG(p,m) (ADDTAIL(&(p)->queue,(Node *)(m)), DOEVENT(&(p)->evn)) -#define PUTMSG_INTR(p,m) (ADDTAIL(&(p)->queue,(Node *)(m)), DOEVENT_INTR(&(p)->evn)) +/*! Queue \a msg into \a port, triggering the associated event */ +INLINE void msg_put(MsgPort* port, Msg* msg) +{ + ADDTAIL(&port->queue, &msg->link); + event_do(&port->evn); +} -/*! Get first message from port's queue (returns NULL when the port is empty) */ -#define GETMSG(p) ((Msg *)REMHEAD(&(p)->queue)) +/* Get the first message from the queue of \a port, or NULL if the port is empty */ +INLINE Msg* msg_get(MsgPort* port) +{ + return (Msg*)REMHEAD(&port->queue); +} -/*! Reply a message to its sender */ -#define REPLYMSG(m) (PUTMSG((m)->replyPort,(m))) +/*! Send back (reply) \a msg to its sender */ +INLINE void msg_reply(Msg* msg) +{ + msg_put(msg->replyPort, msg); +} #endif /* KERN_MSG_H */