Remove remnants of non-interleavable raw slot spport.
[sbcl.git] / src / code / common-os.lisp
blob6ff09bc70d61b8e9d0796bde38542e5ebb028212
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
4 ;;;; more information.
5 ;;;;
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.
12 (in-package "SB!SYS")
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
22 form
23 &key default
24 explanation
25 (condition 'error))
26 `(setf ,variable
27 (handler-case ,form
28 (,condition (c)
29 (let ((default ,default))
30 (warn "Error initializing ~a~@[ ~a~]:~@
32 ~% Using ~s instead."
33 ',variable
34 ,explanation
36 default)
37 default)))))
39 ;;; If something ever needs to be done differently for one OS, then
40 ;;; split out the different part into per-os functions.
42 (defun os-deinit ()
43 (setf *default-pathname-defaults* (make-trivial-default-pathname)
44 *core-string* ""
45 *software-version* nil
46 *runtime-pathname* nil
47 *core-pathname* nil
48 *posix-argv* 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
55 *core-string*
56 (sb!alien:cast *native-core-string* sb!alien:c-string)
57 :default "")
58 (/show0 "setting *POSIX-ARGV*")
59 (init-var-ignoring-errors
60 *posix-argv*
61 (loop for i from 0
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
78 *runtime-pathname*
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"))