The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/msgport2.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * SYS/MSGPORT2.H
    3  *
    4  *      Implements Inlines for LWKT messages and ports.
    5  * 
    6  * $DragonFly: src/sys/sys/msgport2.h,v 1.17 2008/11/09 09:20:09 sephe Exp $
    7  */
    8 
    9 #ifndef _SYS_MSGPORT2_H_
   10 #define _SYS_MSGPORT2_H_
   11 
   12 #ifndef _KERNEL
   13 
   14 #error "This file should not be included by userland programs."
   15 
   16 #else
   17 
   18 #ifndef _SYS_THREAD2_H_
   19 #include <sys/thread2.h>
   20 #endif
   21 
   22 /*
   23  * Initialize a LWKT message structure.  Note that if the message supports
   24  * an abort MSGF_ABORTABLE must be passed in flags.
   25  *
   26  * Note that other areas of the LWKT msg may already be initialized, so we
   27  * do not zero the message here.
   28  *
   29  * Messages are marked as DONE until sent.
   30  */
   31 static __inline
   32 void
   33 lwkt_initmsg(lwkt_msg_t msg, lwkt_port_t rport, int flags)
   34 {
   35     msg->ms_flags = MSGF_DONE | flags;
   36     msg->ms_reply_port = rport;
   37 }
   38 
   39 static __inline
   40 void
   41 lwkt_initmsg_abortable(lwkt_msg_t msg, lwkt_port_t rport, int flags,
   42                        void (*abortfn)(lwkt_msg_t))
   43 {
   44     lwkt_initmsg(msg, rport, flags | MSGF_ABORTABLE);
   45     msg->ms_abortfn = abortfn;
   46 }
   47 
   48 static __inline
   49 void
   50 lwkt_replymsg(lwkt_msg_t msg, int error)
   51 {   
   52     lwkt_port_t port;
   53 
   54     msg->ms_error = error;
   55     port = msg->ms_reply_port;
   56     port->mp_replyport(port, msg);
   57 }
   58 
   59 /*
   60  * Retrieve the next message from the port's message queue, return NULL
   61  * if no messages are pending.  The retrieved message will either be a
   62  * request or a reply based on the MSGF_REPLY bit.
   63  * 
   64  * If the backend port is a thread port, the the calling thread MUST
   65  * own the port.
   66  */
   67 static __inline
   68 void *
   69 lwkt_getport(lwkt_port_t port)
   70 {
   71     return(port->mp_getport(port));
   72 }
   73 
   74 static __inline
   75 void *
   76 lwkt_waitport(lwkt_port_t port, int flags)
   77 {
   78     return(port->mp_waitport(port, flags));
   79 }
   80 
   81 static __inline
   82 int
   83 lwkt_waitmsg(lwkt_msg_t msg, int flags)
   84 {
   85     return(msg->ms_reply_port->mp_waitmsg(msg, flags));
   86 }
   87 
   88 
   89 static __inline
   90 int
   91 lwkt_checkmsg(lwkt_msg_t msg)
   92 {
   93     return(msg->ms_flags & MSGF_DONE);
   94 }
   95 
   96 static __inline
   97 int
   98 lwkt_dropmsg(lwkt_msg_t msg)
   99 {
  100     lwkt_port_t port;
  101     int error = ENOENT;
  102 
  103     KKASSERT(msg->ms_flags & MSGF_DROPABLE);
  104     port = msg->ms_target_port;
  105     if (port)
  106             error = port->mp_dropmsg(port, msg);
  107     return (error);
  108 }
  109 
  110 #endif  /* _KERNEL */
  111 #endif  /* _SYS_MSGPORT2_H_ */

Cache object: 6e4b60c266a3d056669beafea65cfba4


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.