2 (cl:eval-when (:compile-toplevel :load-toplevel :execute)
3 (asdf:oos 'asdf:load-op :sb-grovel))
4 (defpackage #:sb-posix-system (:use #:asdf #:cl #:sb-grovel))
5 (in-package #:sb-posix-system)
8 ;;; we also have a shared library with some .o files in it
10 ;;; FIXME: we share this with SB-BSD-SOCKETS. This should either (a)
11 ;;; be part of ASDF itself, or (b) be in a shared file that we can
12 ;;; LOAD at this point.
13 (defclass unix-dso (module) ())
14 (defun unix-name (pathname)
17 (logical-pathname (translate-logical-pathname pathname))
20 (defmethod asdf::input-files ((operation compile-op) (dso unix-dso))
21 (mapcar #'component-pathname (module-components dso)))
23 (defmethod output-files ((operation compile-op) (dso unix-dso))
24 (let ((dir (component-pathname dso)))
26 (make-pathname :type "so"
27 :name (car (last (pathname-directory dir)))
28 :directory (butlast (pathname-directory dir))
32 (defmethod perform :after ((operation compile-op) (dso unix-dso))
33 (let ((dso-name (unix-name (car (output-files operation dso)))))
36 "gcc ~A -o ~S ~{~S ~}"
38 (sb-ext:posix-getenv "EXTRA_LDFLAGS")
40 #+sunos "-shared -lresolv -lsocket -lnsl"
42 #-(or darwin sunos) "-shared")
46 (output-files operation c))
47 (module-components dso)))))
48 (error 'operation-error :operation operation :component dso))))
50 ;;; if this goes into the standard asdf, it could reasonably be extended
51 ;;; to allow cflags to be set somehow
52 (defmethod output-files ((op compile-op) (c c-source-file))
54 (make-pathname :type "o" :defaults
55 (component-pathname c))))
56 (defmethod perform ((op compile-op) (c c-source-file))
58 (= 0 (run-shell-command "gcc ~A -o ~S -c ~S"
61 (sb-ext:posix-getenv "EXTRA_CFLAGS")
64 (unix-name (car (output-files op c)))
65 (unix-name (component-pathname c))))
66 (error 'operation-error :operation op :component c)))
68 (defmethod perform ((operation load-op) (c c-source-file))
71 (defmethod perform ((o load-op) (c unix-dso))
72 (let ((co (make-instance 'compile-op)))
73 (let ((filename (car (output-files co c))))
74 #+cmu (ext:load-foreign filename)
75 #+sbcl (sb-alien:load-shared-object filename))))
78 :depends-on (sb-grovel)
79 #+sb-building-contrib :pathname
80 #+sb-building-contrib "SYS:CONTRIB;SB-POSIX;"
81 :components ((:file "defpackage")
82 (:file "designator" :depends-on ("defpackage"))
84 :components ((:c-source-file "stat-macros")
85 (:c-source-file "waitpid-macros")))
86 (:file "macros" :depends-on ("designator"))
87 (sb-grovel:grovel-constants-file
89 :package :sb-posix :depends-on ("defpackage"))
90 (:file "interface" :depends-on ("constants" "macros" "designator" "alien"))))
92 (defsystem sb-posix-tests
94 :components ((:file "posix-tests")))
96 (defmethod perform :after ((o load-op) (c (eql (find-system :sb-posix))))
99 (defmethod perform ((o test-op) (c (eql (find-system :sb-posix))))
100 (operate 'load-op 'sb-posix-tests)
101 (operate 'test-op 'sb-posix-tests))
103 (defmethod perform ((o test-op) (c (eql (find-system :sb-posix-tests))))
104 (funcall (intern "DO-TESTS" (find-package "SB-RT")))
105 (let ((failures (funcall (intern "PENDING-TESTS" "SB-RT")))
106 (ignored-failures (loop for sym being the symbols of :sb-posix-tests
107 if (search ".ERROR" (symbol-name sym))
112 ((null (set-difference failures ignored-failures))
113 (warn "~@<some POSIX implementations return incorrect error values for ~
114 failing calls, but there is legitimate variation between ~
115 implementations too. If you think the errno ~
116 from your platform is valid, please contact the sbcl ~
117 developers; otherwise, please submit a bug report to your ~
118 kernel distributor~@:>")
121 (error "non-errno tests failed!")))))