4 * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5 * Copyright 1999,2001 Bernardo Innocenti <bernie@develer.com>
6 * This file is part of DevLib - See devlib/README for information.
9 * \brief Simple inter-process messaging system
11 * This module implements a common system for executing
12 * a user defined action calling a hook function.
16 * \author Bernardo Innocenti <bernie@develer.com>
21 * Revision 1.1 2004/06/06 15:11:08 bernie
31 typedef struct MsgPort
33 List queue; /*!< Messages queued at this port */
34 Event evn; /*!< Event to trigger when a message arrives */
40 Node link; /*!< Link into message port queue */
41 MsgPort *replyPort; /*!< Port to which the msg is to be replied */
42 /* User data may follow */
46 /*! Initialize a messge port */
47 #define INITPORT(p) INITLIST(&(p)->queue)
49 /*! Queue a message to a message port */
50 #define PUTMSG(p,m) (ADDTAIL(&(p)->queue,(Node *)(m)), DOEVENT(&(p)->evn))
51 #define PUTMSG_INTR(p,m) (ADDTAIL(&(p)->queue,(Node *)(m)), DOEVENT_INTR(&(p)->evn))
53 /*! Get first message from port's queue (returns NULL when the port is empty) */
54 #define GETMSG(p) ((Msg *)REMHEAD(&(p)->queue))
56 /*! Reply a message to its sender */
57 #define REPLYMSG(m) (PUTMSG((m)->replyPort,(m)))
59 #endif /* KERN_MSG_H */