1.0.29.27: add shebang line to fasls
[sbcl.git] / src / code / common-os.lisp
index 9846ed6..51ebbc1 100644 (file)
 
 (defvar *software-version* nil)
 
-(defvar *core-pathname* nil
-  #!+sb-doc
-  "The absolute pathname of the running SBCL core.")
+(sb!alien:define-alien-variable ("posix_argv" *native-posix-argv*) (* (* char)))
+(sb!alien:define-alien-variable ("core_string" *native-core-string*) (* char))
+(sb!alien:define-alien-routine os-get-runtime-executable-path sb!alien:c-string)
 
 ;;; if something ever needs to be done differently for one OS, then
 ;;; split out the different part into per-os functions.
 (defun os-cold-init-or-reinit ()
+  (/show0 "setting *CORE-STRING*")
+  (setf *core-string*
+        (sb!alien:cast *native-core-string* sb!alien:c-string))
+  (/show0 "setting *POSIX-ARGV*")
+  (setf sb!ext:*posix-argv*
+        (loop for i from 0
+              for arg = (sb!alien:deref *native-posix-argv* i)
+              until (sb!alien:null-alien arg)
+              collect (sb!alien:cast arg sb!alien:c-string)))
   (/show0 "entering OS-COLD-INIT-OR-REINIT")
   (setf *software-version* nil)
   (/show0 "setting *DEFAULT-PATHNAME-DEFAULTS*")
@@ -33,4 +42,6 @@
   (/show0 "setting *CORE-PATHNAME*")
   (setf *core-pathname*
         (merge-pathnames (native-pathname *core-string*)))
+  (/show0 "setting *RUNTIME-PATHNAME*")
+  (setf *runtime-pathname* (native-pathname (os-get-runtime-executable-path)))
   (/show0 "leaving OS-COLD-INIT-OR-REINIT"))