export CPU-AFFINITY-MASK
[sb-cpu-affinity.git] / sb-cpu-affinity.asd
blobd0ba752ef5a002b9cb09382e356d7161a0f772b9
1 #-(and linux sbcl)
2 (error "SB-CPU-AFFINITY is SBCL/Linux only.")
4 (defpackage :sb-cpu-affinity-system
5   (:use :cl :asdf))
7 (in-package :sb-cpu-affinity-system)
9 (defclass c-so-source-file (c-source-file) ())
11 (defvar *gcc* "/usr/bin/gcc")
12 (defvar *gcc-options* '("-shared" "-fPIC"))
14 (defmethod output-files ((o compile-op) (c c-so-source-file))
15   (list (make-pathname :type "so"
16                        :defaults (component-pathname c))))
18 (defmethod perform ((o load-op) (c c-so-source-file))
19   (destructuring-bind (so) (input-files o c)
20     (sb-alien:load-shared-object so)))
22 (defmethod perform ((o compile-op) (c c-so-source-file))
23   (destructuring-bind (so) (output-files o c)
24     (unless (zerop (run-shell-command 
25                     "~A ~A ~{~A ~}-o ~A"
26                     *gcc*
27                     (sb-ext:native-namestring (component-pathname c) :as-file t)
28                     *gcc-options*
29                     (sb-ext:native-namestring so :as-file t)))
30       (error 'operation-error :operation o :component c))))
32 (defsystem :sb-cpu-affinity
33     :components
34   ((c-so-source-file "cpu-affinity-wrapper")
35    (:file "package")
36    (:file "cpu-affinity" :depends-on ("package" "cpu-affinity-wrapper"))))