Add INLINE declamations for foreign wrappers.
[iolib/alendvai.git] / io.multiplex / foreign-unix.lisp
blob49bd781e99000c1ddeadae267634f366f4bb0283
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; --- Linux-specific definitions.
4 ;;;
5 ;;; Copyright (C) 2005-2006, Matthew Backes <lucca@accela.net>
6 ;;; Copyright (C) 2005-2006, Dan Knapp <dankna@accela.net>
7 ;;;
8 ;;; Permission is hereby granted, free of charge, to any person
9 ;;; obtaining a copy of this software and associated documentation
10 ;;; files (the "Software"), to deal in the Software without
11 ;;; restriction, including without limitation the rights to use, copy,
12 ;;; modify, merge, publish, distribute, sublicense, and/or sell copies
13 ;;; of the Software, and to permit persons to whom the Software is
14 ;;; furnished to do so, subject to the following conditions:
15 ;;;
16 ;;; The above copyright notice and this permission notice shall be
17 ;;; included in all copies or substantial portions of the Software.
18 ;;;
19 ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 ;;; DEALINGS IN THE SOFTWARE.
28 (in-package :io.multiplex)
30 ;;;; sys/select.h
32 ;;; FIXME: too low level?
33 (defsyscall "select" :int
34 "Scan for I/O activity on multiple file descriptors."
35 (nfds :int)
36 (readfds :pointer)
37 (writefds :pointer)
38 (exceptfds :pointer)
39 (timeout :pointer))
41 ;;; FIXME: document these.
42 (declaim (inline fd-zero fd-clr fd-set fd-isset))
44 (defun fd-zero (fd-set)
45 (bzero fd-set size-of-fd-set)
46 (values fd-set))
48 (defun copy-fd-set (from to)
49 (nix:memcpy to from size-of-fd-set)
50 (values to))
52 (deftype select-file-descriptor ()
53 `(mod #.fd-setsize))
55 (defun fd-isset (fd fd-set)
56 (multiple-value-bind (byte-off bit-off) (floor fd 8)
57 (let ((oldval (mem-aref fd-set :uint8 byte-off)))
58 (logbitp bit-off oldval))))
60 (defun fd-clr (fd fd-set)
61 (multiple-value-bind (byte-off bit-off) (floor fd 8)
62 (let ((oldval (mem-aref fd-set :uint8 byte-off)))
63 (setf (mem-aref fd-set :uint8 byte-off)
64 (logandc2 oldval (ash 1 bit-off)))))
65 (values fd-set))
67 (defun fd-set (fd fd-set)
68 (multiple-value-bind (byte-off bit-off) (floor fd 8)
69 (let ((oldval (mem-aref fd-set :uint8 byte-off)))
70 (setf (mem-aref fd-set :uint8 byte-off)
71 (logior oldval (ash 1 bit-off)))))
72 (values fd-set))
74 ;;;; sys/poll.h
76 (defsyscall "poll" :int
77 "Scan for I/O activity on multiple file descriptors."
78 (fds :pointer)
79 (nfds nfds)
80 (timeout :int))