Fix typos in docstrings and function names.
[sbcl.git] / contrib / sb-posix / interface.lisp
index 732922e..8e6be50 100644 (file)
   ((errno :initarg :errno :reader sb-posix:syscall-errno)
    (name :initarg :name :initform nil :reader sb-posix:syscall-name))
   (:report (lambda (c s)
-             (let ((errno (sb-posix:syscall-errno c)))
-               (format s "Error in ~S: ~A (~A)"
-                       (sb-posix:syscall-name c)
-                       (sb-int:strerror errno)
-                       errno)))))
-
-(declaim (ftype (function (symbol) nil) syscall-error))
-(defun syscall-error (name)
+             (let ((errno (sb-posix:syscall-errno c))
+                   (name (sb-posix:syscall-name c)))
+               (if name
+                   (format s "Error in ~S: ~A (~A)"
+                           name
+                           (sb-int:strerror errno)
+                           errno)
+                   (format s "Error in syscall: ~A (~A)"
+                           (sb-int:strerror errno)
+                           errno))))))
+
+(declaim (ftype (function (&optional symbol) nil) syscall-error))
+(defun syscall-error (&optional name)
   (error 'sb-posix:syscall-error
          :name name
          :errno (get-errno)))
 
   ;; uid, gid
   (define-call "geteuid" uid-t never-fails) ; "always successful", it says
-#-sunos  (define-call "getresuid" uid-t never-fails)
+  #-sunos
+  (define-call "getresuid" uid-t never-fails)
   (define-call "getuid" uid-t never-fails)
   (define-call "seteuid" int minusp (uid uid-t))
-#-sunos  (define-call "setfsuid" int minusp (uid uid-t))
+  #-sunos
+  (define-call "setfsuid" int minusp (uid uid-t))
   (define-call "setreuid" int minusp (ruid uid-t) (euid uid-t))
-#-sunos  (define-call "setresuid" int minusp (ruid uid-t) (euid uid-t) (suid uid-t))
+  #-sunos
+  (define-call "setresuid" int minusp (ruid uid-t) (euid uid-t) (suid uid-t))
   (define-call "setuid" int minusp (uid uid-t))
   (define-call "getegid" gid-t never-fails)
   (define-call "getgid" gid-t never-fails)
-#-sunos  (define-call "getresgid" gid-t never-fails)
+  #-sunos
+  (define-call "getresgid" gid-t never-fails)
   (define-call "setegid" int minusp (gid gid-t))
-#-sunos  (define-call "setfsgid" int minusp (gid gid-t))
+  #-sunos
+  (define-call "setfsgid" int minusp (gid gid-t))
   (define-call "setgid" int minusp (gid gid-t))
   (define-call "setregid" int minusp (rgid gid-t) (egid gid-t))
-#-sunos  (define-call "setresgid" int minusp (rgid gid-t) (egid gid-t) (sgid gid-t))
+  #-sunos
+  (define-call "setresgid" int minusp (rgid gid-t) (egid gid-t) (sgid gid-t))
 
   ;; processes, signals
   (define-call "alarm" int never-fails (seconds unsigned))
 
-
+  ;; exit and abort, not much point inlining these
+  (define-simple-call abort void)
+  (define-simple-call exit void (status int))
+  (define-simple-call _exit void (status int))
 
   ;; FIXME this is a lie, of course this can fail, but there's no
   ;; error handling here yet!
@@ -437,8 +451,29 @@ not supported."
  (define-call "munmap" int minusp
    (start sb-sys:system-area-pointer) (length unsigned))
 
+#-win32
 (define-call "msync" int minusp
   (addr sb-sys:system-area-pointer) (length unsigned) (flags int)))
+#+win32
+(progn
+  ;; No attempt is made to offer a full mmap-like interface on Windows.
+  ;; It would be possible to do so (and has been done by AK on his
+  ;; branch), but the use case is unclear to me.  However, the following
+  ;; definitions are needed to keep existing code in sb-simple-streams
+  ;; running. --DFL
+  (defconstant PROT-READ #x02)
+  (defconstant PROT-WRITE #x04)
+  (defconstant PROT-EXEC #x10)
+  (defconstant PROT-NONE 0)
+  (defconstant MAP-SHARED 0)
+  (defconstant MAP-PRIVATE 1)
+  (defconstant MS-ASYNC nil)
+  (defconstant MS-SYNC nil)
+  (export                            ;export on the fly like define-call
+   (defun msync (address length flags)
+     (declare (ignore flags))
+     (when (zerop (sb-win32:flush-view-of-file address length))
+       (sb-win32::win32-error "FlushViewOfFile")))))
 
 ;;; mlockall, munlockall
 (define-call "mlockall" int minusp (flags int))
@@ -471,8 +506,8 @@ not supported."
         :documentation "Initial working directory.")
    (shell :initarg :shell :accessor passwd-shell
           :documentation "Program to use as shell."))
-  (:documentation "Instances of this class represent entries in
-                   the system's user database."))
+  (:documentation
+   "Instances of this class represent entries in the system's user database."))
 
 ;;; group database
 #-win32
@@ -537,9 +572,8 @@ not supported."
    (mtime :initarg :mtime :reader stat-mtime
           :documentation "Time of last data modification.")
    (ctime :initarg :ctime :reader stat-ctime
-          :documentation "Time of last status change"))
-  (:documentation "Instances of this class represent Posix file
-                   metadata."))
+          :documentation "Time of last status change."))
+  (:documentation "Instances of this class represent POSIX file metadata."))
 
 (defmacro define-stat-call (name arg designator-fun type)
   ;; FIXME: this isn't the documented way of doing this, surely?
@@ -618,8 +652,8 @@ not supported."
           :documentation "Local modes.")
    (cc :initarg :cc :accessor sb-posix:termios-cc :array-length nccs
        :documentation "Control characters."))
-  (:documentation "Instances of this class represent I/O
-                   characteristics of the terminal."))
+  (:documentation
+   "Instances of this class represent I/O characteristics of the terminal."))
 
 #-win32
 (progn
@@ -717,8 +751,9 @@ not supported."
           result)))
   (export 'utime :sb-posix)
   (defun utime (filename &optional access-time modification-time)
-    (let ((fun (extern-alien "utime" (function int (c-string :not-null t)
-                                               (* alien-utimbuf))))
+    (let ((fun (extern-alien #-netbsd "utime" #+netbsd "_utime"
+                             (function int (c-string :not-null t)
+                                       (* alien-utimbuf))))
           (name (filename filename)))
       (if (not (and access-time modification-time))
           (alien-funcall fun name nil)