You can specify a metaclass using the class option :metaclass in the form of defclass.
CL-USER> (defclass hierarchical-lock (lock) ((parent :initarg :parent :reader parent)) (:metaclass built-in-class)) #<BUILT-IN-CLASS HIERARCHICAL-LOCK>
However, although you can do this and get a class, I'm not sure how you are going to create it. Trying to use make-instance fails:
CL-USER> (make-instance 'hierarchical-lock) ; There is no applicable method for the generic function: ; #<STANDARD-GENERIC-FUNCTION MAKE-INSTANCE #x30200002676F> ; when called with arguments: ; (#<BUILT-IN-CLASS HIERARCHICAL-LOCK>) ; [Condition of type SIMPLE-ERROR]
make-lock implemented in l0-aprims.lisp as
(defun make-lock (&optional name) "Create and return a lock object, which can be used for synchronization between threads." (%make-lock (%make-recursive-lock-ptr) name))
You can keep track of the %make-lock implementation until you get to the implementation details at a low level, but it's clear that locks don't work out the same way as regular CLOS instances.
In addition to Rainer Joswig’s suggestion in a comment on this answer that you let CCL developers know that you think locks are CLOS objects, you can always use some aggregation and define your own hierarchical-lock , which has a slot for its primitive lock and slot for parent. By the magic of common functions, you can implement methods for common functions that work with locks, so your hierarchical-lock behaves like a built-in lock. (This assumes that the locking API is defined in terms of common functions.)
source share