1 ;;;; OS interface functions for SBCL common to all target OSes
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
14 (defvar *software-version* nil)
16 (sb!alien:define-alien-variable ("posix_argv" *native-posix-argv*) (* (* char)))
17 (sb!alien:define-alien-variable ("core_string" *native-core-string*) (* char))
18 (sb!alien:define-alien-routine
19 os-get-runtime-executable-path sb!alien:c-string (external-path boolean))
20 (sb!alien:define-alien-variable
21 ("saved_runtime_path" *native-saved-runtime-path*) (* char))
23 (defmacro init-var-ignoring-errors (variable
31 (let ((default ,default))
32 (warn "Error initializing ~a~@[ ~a~]:~@
41 ;;; If something ever needs to be done differently for one OS, then
42 ;;; split out the different part into per-os functions.
43 (defun os-cold-init-or-reinit ()
44 (/show0 "setting *CORE-STRING*")
45 (init-var-ignoring-errors
47 (sb!alien:cast *native-core-string* sb!alien:c-string)
49 (/show0 "setting *POSIX-ARGV*")
50 (init-var-ignoring-errors
53 for arg = (sb!alien:deref *native-posix-argv* i)
54 until (sb!alien:null-alien arg)
55 collect (sb!alien:cast arg sb!alien:c-string)))
56 (/show0 "entering OS-COLD-INIT-OR-REINIT")
57 (setf *software-version* nil)
58 (/show0 "setting *DEFAULT-PATHNAME-DEFAULTS*")
59 ;; Temporary value, so that #'NATIVE-PATHNAME won't blow up when
61 (setf *default-pathname-defaults* (make-trivial-default-pathname))
62 (init-var-ignoring-errors
63 *default-pathname-defaults* (native-pathname (sb!unix:posix-getcwd/))
64 :default (make-trivial-default-pathname)
65 :explanation "with the current directory")
66 (/show0 "setting *CORE-PATHNAME*")
67 (setf *core-pathname* (merge-pathnames (native-pathname *core-string*)))
68 (/show0 "setting *RUNTIME-PATHNAME*")
69 (init-var-ignoring-errors
71 (let ((exe (os-get-runtime-executable-path t))
72 (saved (sb!alien:cast *native-saved-runtime-path* sb!alien:c-string)))
73 (when (or exe saved) (native-pathname (or exe saved)))))
74 (/show0 "leaving OS-COLD-INIT-OR-REINIT"))