[iolib-ticket] #1: Poll syscall has wrong prototype on FreeBSD

IOLib iolib-devel at common-lisp.net
Sun Sep 23 18:32:31 UTC 2007


#1: Poll syscall has wrong prototype on FreeBSD
-----------------------------+----------------------------------------------
Reporter:  john at fremlin.org  |       Owner:  sionescu   
    Type:  enhancement       |      Status:  new        
Priority:  minor             |   Component:  iolib-posix
 Version:  0.5.4             |    Keywords:             
-----------------------------+----------------------------------------------
 The proper definition should take the timeout as a pointer to a timespec

 #+freebsd
 (defsyscall "poll" :int
   "Scan for I/O activity on multiple file descriptors."
   (fds     :pointer)
   (nfds    nfds)
   (timeout :pointer))

 Here is an example of using it

 #+freebsd
 (defun syscall-poll (fds nfds timeout)
   (cffi:with-foreign-object (ts 'iolib-posix:timespec)
     (cffi:with-foreign-slots ((iolib-posix:sec iolib-posix:nsec) ts iolib-
 posix:timespec)
       (multiple-value-bind (s frac)
           (floor (or timeout 0))
         (setf iolib-posix:sec s)
         (setf iolib-posix:nsec (floor (* frac 1000000)))))
     (iolib-posix:poll fds nfds
                       (if timeout ts
                           (cffi:null-pointer)))))

 where the equivalent code on Linux is

 #+linux
 (defun syscall-poll (fds nfds timeout)
   (iolib-posix:poll fds nfds
                     (if timeout
                         (floor (* timeout 1000))
                         -1)))

-- 
Ticket URL: <http://trac.common-lisp.net/iolib/ticket/1>
IOLib <http://common-lisp.net/project/iolib>
a CommonLisp I/O library


More information about the Iolib-ticket mailing list