diff --git a/src/org/armedbear/lisp/compile-system.lisp b/src/org/armedbear/lisp/compile-system.lisp index 50a496f324b222267b903a9aecc4e75dd0b28cfe..1ec938ee39f15af9a4f2221843b377def0779b4b 100644 --- a/src/org/armedbear/lisp/compile-system.lisp +++ b/src/org/armedbear/lisp/compile-system.lisp @@ -317,6 +317,8 @@ (load (do-compile "concatenate.lisp")) (load (do-compile "ldb.lisp")) (load (do-compile "destructuring-bind.lisp")) + (load (do-compile "featurep.lisp")) + ;; But not for these. (mapc #'do-compile '("adjoin.lisp" "and.lisp" @@ -368,7 +370,6 @@ "error.lisp" "extensible-sequences.lisp" "fasl-concat.lisp" - "featurep.lisp" "fdefinition.lisp" "fill.lisp" "find-all-symbols.lisp" diff --git a/src/org/armedbear/lisp/featurep.lisp b/src/org/armedbear/lisp/featurep.lisp index cc8b282e930e0e878a30fc78ece3e2c92286479d..d9edcae1a4e074d9f02b5dca60591ca38f1e4b89 100644 --- a/src/org/armedbear/lisp/featurep.lisp +++ b/src/org/armedbear/lisp/featurep.lisp @@ -51,3 +51,33 @@ (when (featurep subform) (return t)))) (t (error "Unknown operator in feature expression: ~S" form))))) + +;;;; Cribbed from ASDF 3.1.7; duplicated to establish runtime conditionals before ASDF is constructed +(defun os-macosx-p () + "Is the underlying operating system MacOS X?" + ;; OS-MACOSX is not mutually exclusive with OS-UNIX, + ;; in fact the former implies the latter. + (featurep '(:or :darwin (:and :allegro :macosx) (:and :clisp :macos)))) + +(defun os-unix-p () + "Is the underlying operating system some Unix variant?" + (or (featurep '(:or :unix :cygwin)) (os-macosx-p))) + +(defun os-windows-p () + "Is the underlying operating system Microsoft Windows?" + (and (not (os-unix-p)) (featurep '(:or :win32 :windows :mswindows :mingw32 :mingw64)))) + +(defun os-genera-p () + "Is the underlying operating system Genera (running on a Symbolics Lisp Machine)?" + (featurep :genera)) + +(defun os-oldmac-p () + "Is the underlying operating system an (emulated?) MacOS 9 or earlier?" + (featurep :mcl)) + +(defun os-haiku-p () + "Is the underlying operating system Haiku?" + (featurep :haiku)) + +(export '(os-unix-p os-windows-p)) + diff --git a/src/org/armedbear/lisp/run-program.lisp b/src/org/armedbear/lisp/run-program.lisp index 2a737c73c98f0cc377cf3161e4250266d3a3526f..173074cf2f301aa198fa30a903901896664738c2 100644 --- a/src/org/armedbear/lisp/run-program.lisp +++ b/src/org/armedbear/lisp/run-program.lisp @@ -170,9 +170,13 @@ The &key arguments have the following meanings: "java.io.File" (if value (namestring value) - #+unix "/dev/null" - #+windows "nul" - #-(or unix windows) (error "Don't know how to set up null stream on this platform.")))) + (cond + ((ext:os-unix-p) + "/dev/null") + ((ext:os-windows-p) + "nul") + (t + (error "Don't know how to set up null stream on this platform.")))))) (defun setup-input-redirection (process-builder value if-does-not-exist) (let ((redirect (if (eq value T) @@ -298,15 +302,13 @@ The &key arguments have the following meanings: (defun %process-exit-code (jprocess) (ignore-errors (java:jcall "exitValue" jprocess))) -#+unix -(defconstant +pid-field+ - (let ((field (java:jcall "getDeclaredField" (java:jclass "java.lang.UNIXProcess") "pid"))) - (java:jcall "setAccessible" field java:+true+) - field)) - (defun %process-pid (jprocess) - #+unix (java:jcall "get" +pid-field+ jprocess) - #-unix (error "Can't retrieve PID on this platform.")) + (if (ext:os-unix-p) + ;; TODO: memoize this + (let ((field (java:jcall "getDeclaredField" (java:jclass "java.lang.UNIXProcess") "pid"))) + (java:jcall "setAccessible" field java:+true+) + (java:jcall "get" field jprocess)) + (error "Can't retrieve PID on this platform."))) (defun %process-kill (jprocess) (java:jcall "destroy" jprocess))