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.
45 (setf *default-pathname-defaults
* (make-trivial-default-pathname)
47 *software-version
* nil
48 *runtime-pathname
* nil
51 (sb!impl
::%makunbound
'*machine-version
*))
53 (defun os-cold-init-or-reinit ()
54 (/show0
"entering OS-COLD-INIT-OR-REINIT")
55 (/show0
"setting *CORE-STRING*")
56 (init-var-ignoring-errors
58 (sb!alien
:cast
*native-core-string
* sb
!alien
:c-string
)
60 (/show0
"setting *POSIX-ARGV*")
61 (init-var-ignoring-errors
64 for arg
= (sb!alien
:deref
*native-posix-argv
* i
)
65 until
(sb!alien
:null-alien arg
)
66 collect
(sb!alien
:cast arg sb
!alien
:c-string
)))
67 (/show0
"setting *DEFAULT-PATHNAME-DEFAULTS*")
68 ;; Temporary value, so that #'PARSE-NATIVE-NAMESTRING won't blow up
69 ;; when we call it below.
70 (setf *default-pathname-defaults
* (make-trivial-default-pathname))
71 (init-var-ignoring-errors
72 *default-pathname-defaults
*
73 (parse-native-namestring (sb!unix
:posix-getcwd
/))
74 :default
*default-pathname-defaults
*
75 :explanation
"with the current directory")
76 (/show0
"setting *CORE-PATHNAME*")
77 (setf *core-pathname
* (merge-pathnames (native-pathname *core-string
*)))
78 (/show0
"setting *RUNTIME-PATHNAME*")
79 (init-var-ignoring-errors
81 (let ((exe (os-get-runtime-executable-path t
))
82 (saved (sb!alien
:cast
*native-saved-runtime-path
* sb
!alien
:c-string
)))
83 (when (or exe saved
) (native-pathname (or exe saved
)))))
84 (/show0
"leaving OS-COLD-INIT-OR-REINIT"))