Author: psmith Date: Sun Feb 4 23:51:27 2007 New Revision: 69
Modified: branches/home/psmith/restructure/src/io/fd-helper.lisp Log: Corrections to fcntl and O_NONBLOCK definitions for linux
Modified: branches/home/psmith/restructure/src/io/fd-helper.lisp ============================================================================== --- branches/home/psmith/restructure/src/io/fd-helper.lisp (original) +++ branches/home/psmith/restructure/src/io/fd-helper.lisp Sun Feb 4 23:51:27 2007 @@ -32,7 +32,12 @@
(defconstant +cmd-get-flags+ 3) (defconstant +cmd-set-flags+ 4) -(defconstant +arg-nonblock+ #x0004) + +#+(or darwin macosx freebsd) +(defconstant +arg-nonblock+ #x4) + +#+linux +(defconstant +arg-nonblock+ #x800)
(defcfun ("close" %close) :int (fd :int)) @@ -40,7 +45,10 @@ (defcfun ("fcntl" %fcntl) :int (fd :int) (cmd :int) +#+(or darwin macosx freebsd) (arg :int)) +#+linux + (arg :long))
(defcfun ("read" %read) :long (fd :int) @@ -60,10 +68,15 @@ (defun memzero (ptr size) (%memset ptr 0 size))
+(defun get-fd-flags(unix-fd) + (%fcntl unix-fd +cmd-get-flags+ 0))
(defun set-fd-nonblocking (unix-fd) "Set UNIX-FD to non-blocking mode (O_NONBLOCK)." - (%fcntl unix-fd +cmd-set-flags+ +arg-nonblock+)) + (let* ((flags (get-fd-flags unix-fd)) + (new-flags (logior flags +arg-nonblock+))) + (format t "set-fd-nonblocking :fd ~A :old-flags 0x~X 0x~X~%" unix-fd flags new-flags) + (%fcntl unix-fd +cmd-set-flags+ new-flags)))
(defun close-fd (unix-fd)