X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Funix.lisp;h=ef3159d2343a57c08ca0c0057ac8cba21d9fb87f;hb=b1cd84e0503ff29d72a860ea1709c87f721412ed;hp=d6ac73a336f2a0c1086c8d3f3d981e6a7950b1c7;hpb=fe962ba01d267b92f638c8f0d19be41054219f04;p=sbcl.git diff --git a/src/code/unix.lisp b/src/code/unix.lisp index d6ac73a..ef3159d 100644 --- a/src/code/unix.lisp +++ b/src/code/unix.lisp @@ -107,11 +107,7 @@ SYSCALL-FORM. Repeat evaluation of SYSCALL-FORM if it is interrupted." #!+win32 (progn - (defconstant espipe 29) - ;; For stat-wrapper hack (different-type or non-existing win32 fields). - (define-alien-type nlink-t short) - (define-alien-type uid-t short) - (define-alien-type gid-t short)) + (defconstant espipe 29)) ;;;; hacking the Unix environment @@ -275,7 +271,7 @@ SYSCALL-FORM. Repeat evaluation of SYSCALL-FORM if it is interrupted." #!+largefile "lseek_largefile" (function off-t int off-t int)) fd offset whence))) - (if (minusp result ) + (if (minusp result) (values nil (get-errno)) (values result 0)))) @@ -295,19 +291,19 @@ SYSCALL-FORM. Repeat evaluation of SYSCALL-FORM if it is interrupted." (defun unix-write (fd buf offset len) (declare (type unix-fd fd) (type (unsigned-byte 32) offset len)) - (int-syscall ("write" int (* char) int) - fd - (with-alien ((ptr (* char) (etypecase buf - ((simple-array * (*)) - ;; This SAP-taking is - ;; safe as BUF remains - ;; either in a register - ;; or on stack. - (vector-sap buf)) - (system-area-pointer - buf)))) - (addr (deref ptr offset))) - len)) + (flet ((%write (sap) + (declare (system-area-pointer sap)) + (int-syscall ("write" int (* char) int) + fd + (with-alien ((ptr (* char) sap)) + (addr (deref ptr offset))) + len))) + (etypecase buf + ((simple-array * (*)) + (with-pinned-objects (buf) + (%write (vector-sap buf)))) + (system-area-pointer + (%write buf))))) ;;; Set up a unix-piping mechanism consisting of an input pipe and an ;;; output pipe. Return two values: if no error occurred the first @@ -656,26 +652,22 @@ SYSCALL-FORM. Repeat evaluation of SYSCALL-FORM if it is interrupted." ;;; st_size is a long, not an off-t, because off-t is a 64-bit ;;; quantity on Alpha. And FIXME: "No one would want a file length ;;; longer than 32 bits anyway, right?":-| +;;; +;;; The comment about alien and 64-bit quantities has not been kept in +;;; sync with the comment now in wrap.h (formerly wrap.c), but it's +;;; not clear whether either comment is correct. -- RMK 2007-11-14. (define-alien-type nil (struct wrapped_stat - (st-dev #!-(or mips largefile) unsigned-int - #!+mips unsigned-long - #!+largefile dev-t) + (st-dev wst-dev-t) (st-ino ino-t) (st-mode mode-t) - (st-nlink nlink-t) - (st-uid uid-t) - (st-gid gid-t) - (st-rdev #!-(or mips largefile) unsigned-int - #!+mips unsigned-long - #!+largefile dev-t) - (st-size #!-(or darwin mips largefile) unsigned-int - #!+(or darwin mips largefile) off-t) - #!+(and darwin) - (st-blksize unsigned-int) - #!-(and darwin) - (st-blksize unsigned-long) - (st-blocks unsigned-long) + (st-nlink wst-nlink-t) + (st-uid wst-uid-t) + (st-gid wst-gid-t) + (st-rdev wst-dev-t) + (st-size wst-off-t) + (st-blksize wst-blksize-t) + (st-blocks wst-blkcnt-t) (st-atime time-t) (st-mtime time-t) (st-ctime time-t))) @@ -987,13 +979,14 @@ SYSCALL-FORM. Repeat evaluation of SYSCALL-FORM if it is interrupted." (return pathname) (push pathname previous-pathnames)))) + +(defconstant micro-seconds-per-internal-time-unit + (/ 1000000 sb!xc:internal-time-units-per-second)) + ;;; UNIX specific code, that has been cleanly separated from the ;;; Windows build. #!-win32 (progn - (defconstant micro-seconds-per-internal-time-unit - (/ 1000000 sb!xc:internal-time-units-per-second)) - (declaim (inline system-internal-run-time system-real-time-values))