Changeset 14645


Ignore:
Timestamp:
Feb 7, 2011, 11:28:51 PM (9 years ago)
Author:
gb
Message:

Start trying to get CLOSE-SHARED-LIBRARY working on all platforms.
(It's never worked on Darwin or Windows and has likely bitrotted
on ELF systems.)

Seems to still work (or work again) on Linux; needs testing (and
possibly more work) elsewhere.

One of the changes: make UNLOAD-FOREIGN-VARIABLES and
UNLOAD-LIBRARY-ENTRYPOINTS invaliate all addresses if their
LIB argument is NIL.

Location:
trunk/source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-0/l0-cfm-support.lisp

    r14575 r14645  
    115115      (maphash #'(lambda (k fv)
    116116                   (declare (ignore k))
    117                    (when (eq (fv.container fv) lib)
    118                      (setf (fv.addr fv) nil)))
     117                   (when (fv.addr fv)
     118                     (when (or (null lib) (eq (fv.container fv) lib))
     119                       (setf (fv.addr fv) nil))))
    119120               fvs))))
    120121
     
    433434    (maphash #'(lambda (k eep)
    434435                 (declare (ignore k))
    435                  (when (eq (eep.container eep) lib)
    436                    (setf (eep.address eep) nil)
    437                    (incf count)))
     436                 (when (eep.address eep)
     437                   (when (or (null lib) (eq (eep.container eep) lib))
     438                     (setf (eep.address eep) nil)
     439                     (incf count))))
    438440             (eeps))   
    439441    (not (zerop count))))
  • trunk/source/level-1/linux-files.lisp

    r14582 r14645  
    976976)
    977977       
    978                      
     978(defun %probe-shared-library (shlib)
     979  #-(or windows-target freebsd-target)
     980  (with-cstrs ((name (shlib.pathname shlib)))
     981    (not (%null-ptr-p (#_dlopen name (logior #$RTLD_NOW #$RTLD_NOLOAD)))))
     982  ;; FreeBSD may support #$RTLD_NOLOAD in 8.0, and that support may
     983  ;; have been backported to 7.2.  Until then ...
     984  #+freebsd-target                     
     985  (rlet ((info #>Dl_info))
     986    (not (eql 0 (#_dladdr (shlib.base shlib) info))))
     987  #+windows-target
     988  (with-filename-cstrs ((name (shlib.pathname shlib)))
     989    (not (%null-ptr-p (#_FindModuleW name)))))
     990
    979991
    980992;;; Kind of has something to do with files, and doesn't work in level-0.
    981 #+(or linux-target freebsd-target solaris-target)
    982993(defun close-shared-library (lib &key (completely t))
    983994  "If completely is T, set the reference count of library to 0. Otherwise,
     
    9911002         (handle (shlib.handle lib)))
    9921003      (when handle
    993         (let* ((found nil)
    994                (base (shlib.base lib)))
     1004        (let* ((found nil))
    9951005          (do* ()
    996                ((progn           
    997                   (#_dlclose handle)
    998                   (or (not (setq found (shlib-containing-address base)))
     1006               ((progn
     1007                  #-windows-target (#_dlclose handle)
     1008                  #+windows-target (#_FreeLibrary handle)
     1009                  (or (not (setq found
     1010                                 (%probe-shared-library lib)))
    9991011                      (not completely)))))
    10001012          (when (not found)
    10011013            (setf (shlib.pathname lib) nil
    1002               (shlib.base lib) nil
    1003               (shlib.handle lib) nil
    1004               (shlib.map lib) nil)
    1005             (unload-foreign-variables lib)
    1006             (unload-library-entrypoints lib))))))
     1014                  (shlib.base lib) nil
     1015                  (shlib.handle lib) nil
     1016                  (shlib.map lib) nil)
     1017            (unload-foreign-variables nil)
     1018            (unload-library-entrypoints nil))))))
    10071019
    10081020#+darwin-target
Note: See TracChangeset for help on using the changeset viewer.