1.0.2.23: Clean up handling SB-POSIX functions with runtime wrappers
authorJuho Snellman <jsnell@iki.fi>
Mon, 12 Feb 2007 03:20:39 +0000 (03:20 +0000)
committerJuho Snellman <jsnell@iki.fi>
Mon, 12 Feb 2007 03:20:39 +0000 (03:20 +0000)
        * Thanks to Richard M Kreuter

contrib/sb-posix/interface.lisp
contrib/sb-posix/macros.lisp
version.lisp-expr

index bdfc14a..779759a 100644 (file)
   (declare (ignore args))
   nil)
 
+;;; Some systems may need C-level wrappers, which can live in the
+;;; runtime (so that save-lisp-and-die can produce standalone
+;;; executables).  See REAL-C-NAME in macros.lisp for the use of this
+;;; variable.
+(eval-when (:compile-toplevel :load-toplevel)
+  (setf *c-functions-in-runtime*
+       '`(#+netbsd ,@("stat" "lstat" "fstat" "readdir" "opendir"))))
+
+
 ;;; filesystem access
 (defmacro define-call* (name &rest arguments)
   #-win32 `(define-call ,name ,@arguments)
               (syscall-error))
             (alien-to-stat a-stat stat)))))))
 
-;; Note: _stat, _lstat, and _fstat for NetBSD are provided in
-;; src/runtime/bsd-os.c.  See comments in that file
-;; for an explanation. -- RMK 2006-10-15
-(define-stat-call #-(or win32 netbsd) "stat" #+(or win32 netbsd) "_stat"
+(define-stat-call #-win32 "stat" #+win32 "_stat"
                   pathname filename
                   (function int c-string (* alien-stat)))
 
 #-win32
-(define-stat-call #-netbsd "lstat" #+netbsd "_lstat"
+(define-stat-call "lstat"
                   pathname filename
                   (function int c-string (* alien-stat)))
 ;;; No symbolic links on Windows, so use stat
   (export (defun lstat (filename &optional stat)
             (if stat (stat filename stat) (stat filename)))))
 
-(define-stat-call #-(or win32 netbsd) "fstat" #+(or win32 netbsd) "_fstat"
+(define-stat-call #-win32 "fstat" #+win32 "_fstat"
                   fd file-descriptor
                   (function int int (* alien-stat)))
 
index dd22a7c..018ff62 100644 (file)
      (let ((root (if (eql #\_ (char name 0)) (subseq name 1) name)))
        (intern (substitute #\- #\_ (string-upcase root)) :sb-posix)))))
 
+;; Note: this variable is set in interface.lisp.  defined here for
+;; clarity and so the real-c-name compile as desired.
+(defparameter *c-functions-in-runtime* nil)
+
 (defun real-c-name (name)
-  (etypecase name
-    (list
-     (destructuring-bind (name &key c-name options) name
-       (if c-name
-           c-name
-           (cond #+largefile
-                 ((or (eql options :largefile)
-                      (member :largefile options))
-                  (format nil "~a_largefile" name))
-                 (t
-                  name)))))
-    (string
-     name)))
+  (let  ((maybe-name
+          (etypecase name
+            (list
+             (destructuring-bind (name &key c-name options) name
+               (if c-name
+                   c-name
+                   (cond #+largefile
+                         ((or (eql options :largefile)
+                              (member :largefile options))
+                          (format nil "~a_largefile" name))
+                         (t
+                          name)))))
+            (string
+             name))))
+    (if (member maybe-name *c-functions-in-runtime*
+                :test #'string=)
+        (format nil "_~A" maybe-name)
+        maybe-name)))
 
 (defmacro define-call-internally (lisp-name c-name return-type error-predicate
                                   &rest arguments)
index 454e5cd..e515900 100644 (file)
@@ -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".)
-"1.0.2.22"
+"1.0.2.23"