3 (defpackage #:sb-posix-system (:use #:asdf #:cl #:sb-grovel))
4 (in-package #:sb-posix-system)
7 ;;; we also have a shared library with some .o files in it
9 ;;; FIXME: we share this with SB-BSD-SOCKETS. This should either (a)
10 ;;; be part of ASDF itself, or (b) be in a shared file that we can
11 ;;; LOAD at this point.
12 (defclass unix-dso (module) ())
13 (defun unix-name (pathname)
16 (logical-pathname (translate-logical-pathname pathname))
19 (defmethod asdf::input-files ((operation compile-op) (dso unix-dso))
20 (mapcar #'component-pathname (module-components dso)))
22 (defmethod output-files ((operation compile-op) (dso unix-dso))
23 (let ((dir (component-pathname dso)))
25 (make-pathname :type "so"
26 :name (car (last (pathname-directory dir)))
27 :directory (butlast (pathname-directory dir))
31 (defmethod perform :after ((operation compile-op) (dso unix-dso))
32 (let ((dso-name (unix-name (car (output-files operation dso)))))
35 "gcc ~A -o ~S ~{~S ~}"
37 (sb-ext:posix-getenv "EXTRA_LDFLAGS")
39 #+sunos "-shared -lresolv -lsocket -lnsl"
41 #-(or darwin sunos) "-shared")
45 (output-files operation c))
46 (module-components dso)))))
47 (error 'operation-error :operation operation :component dso))))
49 ;;; if this goes into the standard asdf, it could reasonably be extended
50 ;;; to allow cflags to be set somehow
51 (defmethod output-files ((op compile-op) (c c-source-file))
53 (make-pathname :type "o" :defaults
54 (component-pathname c))))
55 (defmethod perform ((op compile-op) (c c-source-file))
57 (= 0 (run-shell-command "gcc ~A -o ~S -c ~S"
60 (sb-ext:posix-getenv "EXTRA_CFLAGS")
63 (unix-name (car (output-files op c)))
64 (unix-name (component-pathname c))))
65 (error 'operation-error :operation op :component c)))
67 (defmethod perform ((operation load-op) (c c-source-file))
70 (defmethod perform ((o load-op) (c unix-dso))
71 (let ((co (make-instance 'compile-op)))
72 (let ((filename (car (output-files co c))))
73 #+cmu (ext:load-foreign filename)
74 #+sbcl (sb-alien:load-shared-object filename))))
77 :depends-on (sb-grovel)
78 #+sb-building-contrib :pathname
79 #+sb-building-contrib "SYS:CONTRIB;SB-POSIX;"
80 :components ((:file "defpackage")
81 (:file "designator" :depends-on ("defpackage"))
83 :components ((:c-source-file "stat-macros")))
84 (:file "macros" :depends-on ("designator"))
85 (sb-grovel:grovel-constants-file
87 :package :sb-posix :depends-on ("defpackage"))
88 (:file "interface" :depends-on ("constants" "macros" "designator" "alien"))))
90 (defsystem sb-posix-tests
92 :components ((:file "posix-tests")))
94 (defmethod perform :after ((o load-op) (c (eql (find-system :sb-posix))))
97 (defmethod perform ((o test-op) (c (eql (find-system :sb-posix))))
98 (operate 'load-op 'sb-posix-tests)
99 (operate 'test-op 'sb-posix-tests))
101 (defmethod perform ((o test-op) (c (eql (find-system :sb-posix-tests))))
102 (funcall (intern "DO-TESTS" (find-package "SB-RT")))
103 (let ((failures (funcall (intern "PENDING-TESTS" "SB-RT")))
104 (ignored-failures (loop for sym being the symbols of :sb-posix-tests
105 if (search ".ERROR" (symbol-name sym))
110 ((null (set-difference failures ignored-failures))
111 (warn "~@<some POSIX implementations return incorrect error values for ~
112 failing calls, but there is legitimate variation between ~
113 implementations too. If you think the errno ~
114 from your platform is valid, please contact the sbcl ~
115 developers; otherwise, please submit a bug report to your ~
116 kernel distributor~@:>")
119 (error "non-errno tests failed!")))))