From 14a1a090731b8fa3632a6e4b51deee8cbc8f59c9 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Wed, 4 Aug 2004 10:54:17 +0000 Subject: [PATCH] 0.8.13.22: SB-POSIX enhancements ... fork, wait and waitpid from Thomas Burdick (sbcl-devel 2004-05-10) ... C wrappers for waitpid macros ... chroot from Istvan Marko (sbcl-devel 2004-06-07) --- NEWS | 2 ++ contrib/sb-posix/TODO | 6 +++--- contrib/sb-posix/constants.lisp | 11 ++++++++--- contrib/sb-posix/interface.lisp | 39 +++++++++++++++++++++++++++++++++++++++ contrib/sb-posix/sb-posix.asd | 3 ++- version.lisp-expr | 2 +- 6 files changed, 55 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 6b7811e..9b5326a 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ changes in sbcl-0.8.14 relative to sbcl-0.8.13: * bug fix: division operators (MOD, TRUNCATE and the like) with constant zero divisors and integer dividends no longer generate left shifts. + * bug fix: provide default methods for INPUT-STREAM-P and + OUTPUT-STREAM-P specialized on SB-GRAY:FUNDAMENTAL-STREAM. changes in sbcl-0.8.13 relative to sbcl-0.8.12: * new feature: SB-PACKAGE-LOCKS. See the "Package Locks" section of diff --git a/contrib/sb-posix/TODO b/contrib/sb-posix/TODO index a00894e..27de86b 100644 --- a/contrib/sb-posix/TODO +++ b/contrib/sb-posix/TODO @@ -9,7 +9,7 @@ adding. FD_CLR FD_ISSET FD_SET FD_ZERO accept acct adjtime adjtimex bdflush bind break brk cacheflush capget capset chroot clone connect -create_module delete_module execve exit flock fork +create_module delete_module execve exit flock fstatfs ftime getcontext getdents getdomainname getdtablesize getgroups gethostid gethostname getitimer getpeername getpriority getrlimit getrusage getsockname getsockopt @@ -29,8 +29,8 @@ sigaction sigaltstack sigblock siggetmask sigmask signal sigpause sigpending sigprocmask sigreturn sigsetmask sigsuspend sigvec socket socketcall socketpair ssetmask statfs stime stty swapoff swapon syscalls sysctl sysfs sysinfo syslog time times -ulimit umount uname ustat utime utimes vfork vhangup wait wait3 -wait4 waitpid write writev +ulimit umount uname ustat utime utimes vfork vhangup wait3 +wait4 write writev 4) In the spec but not implemented: diff --git a/contrib/sb-posix/constants.lisp b/contrib/sb-posix/constants.lisp index a566050..560be59 100644 --- a/contrib/sb-posix/constants.lisp +++ b/contrib/sb-posix/constants.lisp @@ -5,13 +5,14 @@ ;;; first, the headers necessary to find definitions of everything (#||# "sys/types.h" - "unistd.h" "sys/stat.h" "sys/socket.h" "sys/un.h" "netinet/in.h" "netinet/in_systm.h" - "netinet/ip.h" "net/if.h" "netdb.h" "errno.h" "netinet/tcp.h" - "fcntl.h" "sys/mman.h" + "netinet/ip.h" "net/if.h" "netinet/tcp.h" "sys/mman.h" "sys/wait.h" + "fcntl.h" + "netdb.h" "errno.h" "dirent.h" "signal.h" + "unistd.h" "termios.h") @@ -195,6 +196,10 @@ (:integer enomedium "ENOMEDIUM" nil t) (:integer emediumtype "EMEDIUMTYPE" nil t) + ;; wait + (:integer wnohang "WNOHANG") + (:integer wuntraced "WUNTRACED") + ;; mode_t (:type mode-t "mode_t") (:integer s-isuid "S_ISUID" nil t) diff --git a/contrib/sb-posix/interface.lisp b/contrib/sb-posix/interface.lisp index 1f03272..bf9498e 100644 --- a/contrib/sb-posix/interface.lisp +++ b/contrib/sb-posix/interface.lisp @@ -76,6 +76,7 @@ (define-call "chmod" int minusp (pathname filename) (mode sb-posix::mode-t)) (define-call "chown" int minusp (pathname filename) (owner sb-posix::uid-t) (group sb-posix::gid-t)) +(define-call "chroot" int minusp (pathname filename)) (define-call "close" int minusp (fd file-descriptor)) (define-call "creat" int minusp (pathname filename) (mode sb-posix::mode-t)) (define-call "dup" int minusp (oldfd file-descriptor)) @@ -166,6 +167,7 @@ ;;; processes, signals (define-call "alarm" int never-fails (seconds unsigned)) +(define-call "fork" sb-posix::pid-t minusp) (define-call "getpgid" sb-posix::pid-t minusp (pid sb-posix::pid-t)) (define-call "getpid" sb-posix::pid-t never-fails) (define-call "getppid" sb-posix::pid-t never-fails) @@ -178,6 +180,43 @@ (pid sb-posix::pid-t) (pgid sb-posix::pid-t)) (define-call "setpgrp" int minusp) +(export 'sb-posix::wait :sb-posix) +(declaim (inline sb-posix::wait)) +(defun sb-posix::wait (&optional statusptr) + (declare (type (or null (simple-array (signed-byte 32) (1))) statusptr)) + (let* ((ptr (or statusptr (make-array 1 :element-type '(signed-byte 32)))) + (pid (alien-funcall + (extern-alien "wait" (function sb-posix::pid-t (* int))) + (sb-sys:vector-sap ptr)))) + (if (minusp pid) + (syscall-error) + (values pid (aref ptr 0))))) + +(export 'sb-posix::waitpid :sb-posix) +(declaim (inline sb-posix::waitpid)) +(defun sb-posix::waitpid (pid options &optional statusptr) + (declare (type (sb-alien:alien sb-posix::pid-t) pid) + (type (sb-alien:alien int) options) + (type (or null (simple-array (signed-byte 32) (1))) statusptr)) + (let* ((ptr (or statusptr (make-array 1 :element-type '(signed-byte 32)))) + (pid (alien-funcall + (extern-alien "waitpid" (function sb-posix::pid-t + sb-posix::pid-t (* int) int)) + pid (sb-sys:vector-sap ptr) options))) + (if (minusp pid) + (syscall-error) + (values pid (aref ptr 0))))) + +;; waitpid macros +(define-call "wifexited" boolean never-fails (status int)) +(define-call "wexitstatus" int never-fails (status int)) +(define-call "wifsignaled" boolean never-fails (status int)) +(define-call "wtermsig" int never-fails (status int)) +(define-call "wifstopped" boolean never-fails (status int)) +(define-call "wstopsig" int never-fails (status int)) +#+nil ; see alien/waitpid-macros.c +(define-call "wifcontinued" boolean never-fails (status int)) + ;;; mmap, msync (define-call "mmap" sb-sys:system-area-pointer ;; KLUDGE: #XFFFFFFFF is (void *)-1, which is the charming return diff --git a/contrib/sb-posix/sb-posix.asd b/contrib/sb-posix/sb-posix.asd index 3902c11..1407a1e 100644 --- a/contrib/sb-posix/sb-posix.asd +++ b/contrib/sb-posix/sb-posix.asd @@ -80,7 +80,8 @@ :components ((:file "defpackage") (:file "designator" :depends-on ("defpackage")) (:unix-dso "alien" - :components ((:c-source-file "stat-macros"))) + :components ((:c-source-file "stat-macros") + (:c-source-file "waitpid-macros"))) (:file "macros" :depends-on ("designator")) (sb-grovel:grovel-constants-file "constants" diff --git a/version.lisp-expr b/version.lisp-expr index ffba028..f6c9655 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.8.13.21" +"0.8.13.22" -- 1.7.10.4