+
+(declaim (inline random-fixnum))
+(defun random-fixnum ()
+ (random (1+ most-positive-fixnum)))
+
+(defconstant n-fixnum-bits #.(integer-length most-positive-fixnum))
+
+;;; Lambda which executes its body (or not) randomly. Used to drop
+;;; random cache entries.
+(defmacro randomly-punting-lambda (lambda-list &body body)
+ (with-unique-names (drops drop-pos)
+ `(let ((,drops (random-fixnum))
+ (,drop-pos n-fixnum-bits))
+ (declare (fixnum ,drops)
+ (type (integer 0 #.n-fixnum-bits) ,drop-pos))
+ (lambda ,lambda-list
+ (when (logbitp (the unsigned-byte (decf ,drop-pos)) ,drops)
+ (locally ,@body))
+ (when (zerop ,drop-pos)
+ (setf ,drops (random-fixnum)
+ ,drop-pos n-fixnum-bits))))))
+\f
+;;;; early definition of WRAPPER
+;;;;
+;;;; Most WRAPPER stuff is defined later, but the DEFSTRUCT itself
+;;;; is here early so that things like (TYPEP .. 'WRAPPER) can be
+;;;; compiled efficiently.
+
+;;; Note that for SBCL, as for CMU CL, the WRAPPER of a built-in or
+;;; structure class will be some other kind of SB-KERNEL:LAYOUT, but
+;;; this shouldn't matter, since the only two slots that WRAPPER adds
+;;; are meaningless in those cases.
+(defstruct (wrapper
+ (:include layout
+ ;; KLUDGE: In CMU CL, the initialization default
+ ;; for LAYOUT-INVALID was NIL. In SBCL, that has
+ ;; changed to :UNINITIALIZED, but PCL code might
+ ;; still expect NIL for the initialization
+ ;; default of WRAPPER-INVALID. Instead of trying
+ ;; to find out, I just overrode the LAYOUT
+ ;; default here. -- WHN 19991204
+ (invalid nil)
+ ;; This allows quick testing of wrapperness.
+ (for-std-class-p t))
+ (:constructor make-wrapper-internal)
+ (:copier nil))
+ (instance-slots-layout nil :type list)
+ (class-slots nil :type list))
+#-sb-fluid (declaim (sb-ext:freeze-type wrapper))