X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Funix.lisp;h=4ad861f281e1ddd3d79c08a01b83e3c411de6c74;hb=b8f63d9b4e978bec3bfc1f4fc471e5ed946781fd;hp=ce25a36fc7adebd198126ba44ae03c5048ce2143;hpb=8fc5fda05f92d69c95b47e4ad7561d91dab18c3e;p=sbcl.git diff --git a/src/code/unix.lisp b/src/code/unix.lisp index ce25a36..4ad861f 100644 --- a/src/code/unix.lisp +++ b/src/code/unix.lisp @@ -24,9 +24,6 @@ (in-package "SB!UNIX") -(file-comment - "$Header$") - (/show0 "unix.lisp 21") ;;;; common machine-independent structures @@ -39,10 +36,9 @@ (sb!xc:defmacro def-unix-error (name number description) `(progn + (defconstant ,name ,number ,description) (eval-when (:compile-toplevel :execute) - (push (cons ,number ,description) *compiler-unix-errors*)) - (eval-when (:compile-toplevel :load-toplevel :execute) - (defconstant ,name ,number ,description)))) + (push (cons ,number ,description) *compiler-unix-errors*)))) (sb!xc:defmacro emit-unix-errors () (let* ((max (apply #'max (mapcar #'car *compiler-unix-errors*))) @@ -196,9 +192,8 @@ #!+linux long #!+bsd quad-t) -(eval-when (:compile-toplevel :load-toplevel :execute) - (/show0 "unix.lisp 215") - (defconstant fd-setsize 1024)) +(/show0 "unix.lisp 195") +(defconstant fd-setsize 1024) (/show0 "unix.lisp 217") (def-alien-type nil @@ -331,7 +326,6 @@ (void-syscall ("close" int) fd)) ;;; fcntlbits.h -(eval-when (:compile-toplevel :load-toplevel :execute) (/show0 "unix.lisp 337") (defconstant o_rdonly 0) ; read-only flag @@ -355,7 +349,6 @@ #!+linux #o2000 #!+bsd #x0008) (/show0 "unix.lisp 361") -) ; EVAL-WHEN ;;;; timebits.h @@ -543,6 +536,19 @@ (addr (deref ptr offset))) len)) +(defun unix-pipe () + #!+sb-doc + "Unix-pipe sets up a unix-piping mechanism consisting of + an input pipe and an output pipe. Unix-Pipe returns two + values: if no error occurred the first value is the pipe + to be read from and the second is can be written to. If + an error occurred the first value is NIL and the second + the unix error code." + (with-alien ((fds (array int 2))) + (syscall ("pipe" (* int)) + (values (deref fds 0) (deref fds 1)) + (cast fds (* int))))) + ;;; UNIX-CHDIR accepts a directory name and makes that the ;;; current working directory. (defun unix-chdir (path) @@ -566,6 +572,14 @@ (cast buf (* char))))) (cast buf c-string)))) +(defun unix-dup (fd) + #!+sb-doc + "Unix-dup duplicates an existing file descriptor (given as the + argument) and returns it. If FD is not a valid file descriptor, NIL + and an error number are returned." + (declare (type unix-fd fd)) + (int-syscall ("dup" int) fd)) + ;;; UNIX-EXIT terminates a program. (defun unix-exit (&optional (code 0)) #!+sb-doc @@ -639,9 +653,6 @@ (cast buf c-string) (cast buf (* char)) 256))) -;;; Unix-fsync writes the core-image of the file described by "fd" to -;;; permanent storage (i.e. disk). - (defun unix-fsync (fd) #!+sb-doc "Unix-fsync writes the core image of the file described by @@ -649,6 +660,17 @@ (declare (type unix-fd fd)) (void-syscall ("fsync" int) fd)) +;;;; sys/ioctl.h + +(defun unix-ioctl (fd cmd arg) + #!+sb-doc + "Unix-ioctl performs a variety of operations on open i/o + descriptors. See the UNIX Programmer's Manual for more + information." + (declare (type unix-fd fd) + (type (unsigned-byte 32) cmd)) + (void-syscall ("ioctl" int unsigned-int (* char)) fd cmd arg)) + ;;;; sys/resource.h ;;; FIXME: All we seem to need is the RUSAGE_SELF version of this. @@ -727,9 +749,8 @@ ,num-descriptors ,read-fds ,write-fds ,exception-fds (if timeout-secs (alien-sap (addr tv)) (int-sap 0)))))) -;;; Unix-select accepts sets of file descriptors and waits for an event +;;; UNIX-SELECT accepts sets of file descriptors and waits for an event ;;; to happen on one of them or to time out. - (defmacro num-to-fd-set (fdset num) `(if (fixnump ,num) (progn @@ -950,8 +971,8 @@ (def-unix-error ESRCH 3 "No such process") |# (def-unix-error EINTR 4 "Interrupted system call") -#| (def-unix-error EIO 5 "I/O error") +#| (def-unix-error ENXIO 6 "No such device or address") (def-unix-error E2BIG 7 "Arg list too long") (def-unix-error ENOEXEC 8 "Exec format error")