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 (sb!alien
:define-alien-variable
("posix_argv" *native-posix-argv
*) (* (* char
)))
15 (sb!alien
:define-alien-variable
("core_string" *native-core-string
*) (* char
))
16 (sb!alien
:define-alien-routine
17 os-get-runtime-executable-path sb
!alien
:c-string
(external-path boolean
))
18 (sb!alien
:define-alien-variable
19 ("saved_runtime_path" *native-saved-runtime-path
*) (* char
))
21 (defmacro init-var-ignoring-errors
(variable
29 (let ((default ,default
))
30 (warn "Error initializing ~a~@[ ~a~]:~@
39 ;;; If something ever needs to be done differently for one OS, then
40 ;;; split out the different part into per-os functions.
43 (setf *default-pathname-defaults
* (make-trivial-default-pathname)
45 *software-version
* nil
46 *runtime-pathname
* nil
49 (sb!impl
::%makunbound
'*machine-version
*))
51 (defun os-cold-init-or-reinit ()
52 (/show0
"entering OS-COLD-INIT-OR-REINIT")
53 (/show0
"setting *CORE-STRING*")
54 (init-var-ignoring-errors
56 (sb!alien
:cast
*native-core-string
* sb
!alien
:c-string
)
58 (/show0
"setting *POSIX-ARGV*")
59 (init-var-ignoring-errors
62 for arg
= (sb!alien
:deref
*native-posix-argv
* i
)
63 until
(sb!alien
:null-alien arg
)
64 collect
(sb!alien
:cast arg sb
!alien
:c-string
)))
65 (/show0
"setting *DEFAULT-PATHNAME-DEFAULTS*")
66 ;; Temporary value, so that #'PARSE-NATIVE-NAMESTRING won't blow up
67 ;; when we call it below.
68 (setf *default-pathname-defaults
* (make-trivial-default-pathname))
69 (init-var-ignoring-errors
70 *default-pathname-defaults
*
71 (parse-native-namestring (sb!unix
:posix-getcwd
/))
72 :default
*default-pathname-defaults
*
73 :explanation
"with the current directory")
74 (/show0
"setting *CORE-PATHNAME*")
75 (setf *core-pathname
* (merge-pathnames (native-pathname *core-string
*)))
76 (/show0
"setting *RUNTIME-PATHNAME*")
77 (init-var-ignoring-errors
79 (let ((exe (os-get-runtime-executable-path t
))
80 (saved (sb!alien
:cast
*native-saved-runtime-path
* sb
!alien
:c-string
)))
81 (when (or exe saved
) (native-pathname (or exe saved
)))))
82 (/show0
"leaving OS-COLD-INIT-OR-REINIT"))