(defvar *package-lock*)
(!cold-init-forms
- (setf *package-lock* (sb!thread::make-spinlock :name "Package Lock")))
+ (setf *package-lock* (sb!thread:make-mutex :name "Package Lock")))
(defmacro with-packages ((&key) &body forms)
- `(sb!thread::with-recursive-spinlock (*package-lock*)
+ ;; FIXME: Since name conflicts can be signalled while holding the
+ ;; mutex, user code can be run leading to lock ordering problems.
+ ;;
+ ;; This used to be a spinlock, but there it can be held for a long
+ ;; time while the debugger waits for user input.
+ `(sb!thread:with-recursive-lock (*package-lock*)
,@forms))
;;; Make a package hashtable having a prime number of entries at least
`(let* ((,vec (package-hashtable-table ,table))
(,hash (package-hashtable-hash ,table))
(,len (length ,vec))
- (,h2 (1+ (the index (rem (the index ,sxhash)
+ (,h2 (1+ (the index (rem (the hash ,sxhash)
(the index (- ,len 2)))))))
(declare (type index ,len ,h2))
- (prog ((,index-var (rem (the index ,sxhash) ,len))
+ (prog ((,index-var (rem (the hash ,sxhash) ,len))
,symbol-var ,ehash)
(declare (type (or index null) ,index-var))
LOOP
(let* ((length (length string))
(hash (%sxhash-simple-string string))
(ehash (entry-hash length hash)))
- (declare (type index length hash))
+ (declare (type index length)
+ (type hash hash))
(with-symbol (index symbol table string length hash ehash)
(setf (aref (package-hashtable-hash table) index) 1)
(setf (aref (package-hashtable-table table) index) nil)
(type index length))
(let* ((hash (%sxhash-simple-substring string length))
(ehash (entry-hash length hash)))
- (declare (type index hash ehash))
+ (declare (type hash hash ehash))
(with-symbol (found symbol (package-internal-symbols package)
string length hash ehash)
(when found
(let* ((length (length string))
(hash (%sxhash-simple-string string))
(ehash (entry-hash length hash)))
- (declare (type index length hash))
+ (declare (type index length)
+ (type hash hash))
(with-symbol (found symbol (package-external-symbols package)
string length hash ehash)
(values symbol found))))
(if (eq package-symbol chosen-symbol)
nil ; re-importing the same symbol
(shadowing-import (list chosen-symbol) package))
- (shadowing-import chosen-symbol package)))))))))
+ (shadowing-import (list chosen-symbol) package)))))))))
;;; If we are uninterning a shadowing symbol, then a name conflict can
;;; result, otherwise just nuke the symbol.