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/i386/ibcs2/ibcs2_msg.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 1995 Steven Wallace
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. The name of the author may not be used to endorse or promote products
   11  *    derived from this software without specific prior written permission
   12  *
   13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   23  *
   24  * $FreeBSD: releng/5.0/sys/i386/ibcs2/ibcs2_msg.c 83366 2001-09-12 08:38:13Z julian $
   25  */
   26 
   27 /*
   28  * IBCS2 message compatibility module.
   29  *
   30  */
   31 
   32 #include <sys/param.h>
   33 #include <sys/systm.h>
   34 #include <sys/sysproto.h>
   35 
   36 #include <i386/ibcs2/ibcs2_types.h>
   37 #include <i386/ibcs2/ibcs2_signal.h>
   38 #include <i386/ibcs2/ibcs2_util.h>
   39 #include <i386/ibcs2/ibcs2_poll.h>
   40 #include <i386/ibcs2/ibcs2_proto.h>
   41 
   42 
   43 int
   44 ibcs2_getmsg(td, uap)
   45         struct thread *td;
   46         struct ibcs2_getmsg_args *uap;
   47 {
   48         return 0; /* fake */
   49 }
   50 
   51 int
   52 ibcs2_putmsg(td, uap)
   53         struct thread *td;
   54         struct ibcs2_putmsg_args *uap;
   55 {
   56         return 0; /* fake */
   57 }
   58 
   59 
   60 int
   61 ibcs2_poll(td, uap)
   62         struct thread *td;
   63         struct ibcs2_poll_args *uap;
   64 {
   65         int error, i;
   66         fd_set *readfds, *writefds, *exceptfds;
   67         struct timeval *timeout;
   68         struct ibcs2_poll conv;
   69         struct select_args tmp_select;
   70         caddr_t sg = stackgap_init();
   71 
   72         if (uap->nfds > FD_SETSIZE)
   73                 return EINVAL;
   74         readfds   = stackgap_alloc(&sg, sizeof(fd_set *));
   75         writefds  = stackgap_alloc(&sg, sizeof(fd_set *));
   76         exceptfds = stackgap_alloc(&sg, sizeof(fd_set *));
   77         timeout   = stackgap_alloc(&sg, sizeof(struct timeval *));
   78 
   79         FD_ZERO(readfds);
   80         FD_ZERO(writefds);
   81         FD_ZERO(exceptfds);
   82         if (uap->timeout == -1)
   83                 timeout = NULL;
   84         else {
   85                 timeout->tv_usec = (uap->timeout % 1000)*1000;
   86                 timeout->tv_sec  = uap->timeout / 1000;
   87         }
   88 
   89         tmp_select.nd = 0;
   90         tmp_select.in = readfds;
   91         tmp_select.ou = writefds;
   92         tmp_select.ex = exceptfds;
   93         tmp_select.tv = timeout;
   94 
   95         for (i = 0; i < uap->nfds; i++) {
   96                 if ((error = copyin(uap->fds + i*sizeof(struct ibcs2_poll),
   97                                    &conv, sizeof(conv))) != 0)
   98                         return error;
   99                 conv.revents = 0;
  100                 if (conv.fd < 0 || conv.fd > FD_SETSIZE)
  101                         continue;
  102                 if (conv.fd >= tmp_select.nd)
  103                         tmp_select.nd = conv.fd + 1;
  104                 if (conv.events & IBCS2_READPOLL)
  105                         FD_SET(conv.fd, readfds);
  106                 if (conv.events & IBCS2_WRITEPOLL)
  107                         FD_SET(conv.fd, writefds);
  108                 FD_SET(conv.fd, exceptfds);
  109         }
  110         if ((error = select(td, &tmp_select)) != 0)
  111                 return error;
  112         if (td->td_retval[0] == 0)
  113                 return 0;
  114         td->td_retval[0] = 0;
  115         for (td->td_retval[0] = 0, i = 0; i < uap->nfds; i++) {
  116                 copyin(uap->fds + i*sizeof(struct ibcs2_poll),
  117                        &conv, sizeof(conv));
  118                 conv.revents = 0;
  119                 if (conv.fd < 0 || conv.fd > FD_SETSIZE)
  120                         /* should check for open as well */
  121                         conv.revents |= IBCS2_POLLNVAL;
  122                 else {
  123                         if (FD_ISSET(conv.fd, readfds))
  124                                 conv.revents |= IBCS2_POLLIN;
  125                         if (FD_ISSET(conv.fd, writefds))
  126                                 conv.revents |= IBCS2_POLLOUT;
  127                         if (FD_ISSET(conv.fd, exceptfds))
  128                                 conv.revents |= IBCS2_POLLERR;
  129                         if (conv.revents)
  130                                 ++td->td_retval[0];
  131                 }
  132                 if ((error = copyout(&conv,
  133                                     uap->fds + i*sizeof(struct ibcs2_poll),
  134                                     sizeof(conv))) != 0)
  135                         return error;
  136         }
  137         return 0;
  138 }

Cache object: bd59013f3db3f74fd0979a2d4e4bc9c5


[ 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.