Badichi)
* enhancement: :DONT-SAVE keyword argument has been added to
LOAD-SHARED-OBJECT for controlling interaction with
- SAVE-LISP-AND-DIE.
+ SAVE-LISP-AND-DIE, and UNLOAD-SHARED-OBJECT can be used to undo
+ the effects of an earlier LOAD-SHARED-OBJECT call.
* bug fix: ADJUST-ARRAY on multidimensional arrays used bogusly give
them a fill pointer unless :DISPLACED-TO or :INITIAL-CONTENTS were
provided. (reported by Cedric St-Jean)
(defstruct shared-object pathname namestring handle dont-save)
(defun load-shared-object (pathname &key dont-save)
+ #!+sb-doc
"Load a shared library / dynamic shared object file / similar foreign
container specified by designated PATHNAME, such as a .so on an ELF platform.
(update-linkage-table))))
pathname))
+(defun unload-shared-object (pathname)
+ #!+sb-doc
+ "Unloads the shared object loaded earlier using the designated PATHNAME with
+LOAD-SHARED-OBJECT, to the degree supported on the platform.
+
+Experimental."
+ (let ((pathname (pathname pathname)))
+ (sb!thread:with-mutex (*shared-objects-lock*)
+ (let ((old (find pathname *shared-objects*
+ :key #'shared-object-pathname
+ :test #'equal)))
+ (when old
+ (dlclose-or-lose old)
+ (setf *shared-objects* (remove old *shared-objects*))
+ #!+(and linkage-table (not win32))
+ (update-linkage-table))))))
+
(defun try-reopen-shared-object (obj)
(declare (type shared-object obj))
(tagbody :dlopen
(unless (pathnamep pathname)
(format *query-io* "~&Error: invalid pathname.~%")
(go :query))
- (setf (shared-object-pathname obj) pathname
- (shared-object-namestring obj) (native-namestring pathname :as-file t))))
+ (setf (shared-object-pathname obj) pathname)
+ (setf (shared-object-namestring obj)
+ (native-namestring (translate-logical-pathname pathname)
+ :as-file t))))
(go :dlopen))))
obj)
(load-shared-object (truename "$TEST_FILESTEM-c.so"))
(assert (= 43 late-foo))
(assert (= 14 (late-bar)))
+ (unload-shared-object (truename "$TEST_FILESTEM-c.so"))
+ (multiple-value-bind (val err) (ignore-errors late-foo)
+ (assert (not val))
+ (assert (typep err 'undefined-alien-error)))
+ (multiple-value-bind (val err) (ignore-errors (late-bar))
+ (assert (not val))
+ (assert (typep err 'undefined-alien-error)))
(note "/linkage table ok"))
(sb-ext:quit :unix-status $EXIT_LISP_WIN) ; success convention for Lisp program
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.21.27"
+"1.0.21.28"