[Openmcl-cvs-notifications] r8587 - in /trunk/source: level-0/l0-cfm-support.lisp level-1/linux-files.lisp
gb at clozure.com
gb at clozure.com
Mon Feb 25 06:40:45 EST 2008
Author: gb
Date: Mon Feb 25 06:40:45 2008
New Revision: 8587
Log:
On ELF platforms, distinguish between link-map and handle returned
by #_dlopen. (They're EQL on Linux but differ on FreeBSD.) Note
that we only set the handle for libraries opened explicitly by
user code, which allows us to usurp the old opened-by-lisp-kernel
slot.
Ensure that CLOSE-SHARED-LIBRARY is defined on FreeBSD; make the ELF
version call #_dlclose on the handle if it exists, not the link map.
Modified:
trunk/source/level-0/l0-cfm-support.lisp
trunk/source/level-1/linux-files.lisp
Modified: trunk/source/level-0/l0-cfm-support.lisp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/level-0/l0-cfm-support.lisp (original)
+++ trunk/source/level-0/l0-cfm-support.lisp Mon Feb 25 06:40:45 2008
@@ -66,7 +66,7 @@
nil ;'shlib
shlib.soname
shlib.pathname
- shlib.opened-by-lisp-kernel
+ shlib.handle ; if explicitly opened
shlib.map
shlib.base
shlib.opencount)
@@ -262,13 +262,12 @@
(setq *dladdr-entry* (foreign-symbol-entry "dladdr"))
(when (null *shared-libraries*)
(%walk-shared-libraries #'shlib-from-map-entry)
- (dolist (l *shared-libraries*)
;;; On Linux, it seems to be necessary to open each of these
;;; libraries yet again, specifying the RTLD_GLOBAL flag.
;;; On FreeBSD, it seems desirable -not- to do that.
- #+linux-target
- (%dlopen-shlib l)
- (setf (shlib.opened-by-lisp-kernel l) t))))
+ #+linux-target
+ (dolist (l *shared-libraries*)
+ (%dlopen-shlib l))))
=
(init-shared-libraries)
=
@@ -296,29 +295,29 @@
is already open, increment a reference count. If the library can't be
loaded, signal a SIMPLE-ERROR which contains an often-cryptic message from
the operating system."
- (let* ((link-map
- (let* ((lib (with-cstrs ((name name))
+ (let* ((handle (with-cstrs ((name name))
(ff-call
(%kernel-import target::kernel-import-GetSharedLi=
brary)
:address name
:unsigned-fullword *dlopen-flags*
- :address))))
- #+linux-target lib
- #+freebsd-target (if (%null-ptr-p lib)
- lib
- (rlet ((p :address))
- (if (eql 0 (ff-call
- (foreign-symbol-entry "dlinfo=
")
- :address lib
- :int #$RTLD_DI_LINKMAP
- :address p
- :int))
- (pref p :address)
- (%null-ptr)))))))
+ :address)))
+ (link-map #-freebsd-target handle
+ #+freebsd-target (if (%null-ptr-p handle)
+ handle
+ (rlet ((p :address))
+ (if (eql 0 (ff-call
+ (foreign-symbol-entry =
"dlinfo")
+ :address handle
+ :int #$RTLD_DI_LINKMAP
+ :address p
+ :int))
+ (pref p :address)
+ (%null-ptr))))))
(if (%null-ptr-p link-map)
(error "Error opening shared library ~s: ~a" name (dlerror))
(prog1 (let* ((lib (shlib-from-map-entry link-map)))
(incf (shlib.opencount lib))
+ (setf (shlib.handle lib) handle)
lib)
(%walk-shared-libraries
#'(lambda (map)
Modified: trunk/source/level-1/linux-files.lisp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/level-1/linux-files.lisp (original)
+++ trunk/source/level-1/linux-files.lisp Mon Feb 25 06:40:45 2008
@@ -595,7 +595,7 @@
(%get-cstring p))))
=
;;; Kind of has something to do with files, and doesn't work in level-0.
-#+linux-target
+#+(or linux-target freebsd-target)
(defun close-shared-library (lib &key (completely t))
"If completely is T, set the reference count of library to 0. Otherwise,
decrements it by 1. In either case, if the reference count becomes 0,
@@ -605,22 +605,22 @@
(or (shared-library-with-name lib)
(error "Shared library ~s not found." lib))
(require-type lib 'shlib)))
- (map (shlib.map lib)))
- (unless (shlib.opened-by-lisp-kernel lib)
- (when map
+ (handle (shlib.handle lib)))
+ (when handle
(let* ((found nil)
(base (shlib.base lib)))
(do* ()
((progn =
- (#_dlclose map)
+ (#_dlclose handle)
(or (not (setq found (shlib-containing-address base)))
(not completely)))))
(when (not found)
(setf (shlib.pathname lib) nil
(shlib.base lib) nil
+ (shlib.handle lib) nil
(shlib.map lib) nil)
(unload-foreign-variables lib)
- (unload-library-entrypoints lib)))))))
+ (unload-library-entrypoints lib))))))
=
#+darwin-target
;; completely specifies whether to remove it totally from our list
More information about the Openmcl-cvs-notifications
mailing list