-#if !defined(__GNUC__)
-
-#include <sys/cdefs.h>
-__BEGIN_DECLS
-
-/* Enqueue element to head of queue */
-extern void enqueue_head(
- queue_t que,
- queue_entry_t elt);
-
-/* Enqueue element to tail of queue */
-extern void enqueue_tail(
- queue_t que,
- queue_entry_t elt);
-
-/* Dequeue element from head of queue */
-extern queue_entry_t dequeue_head(
- queue_t que);
-
-/* Dequeue element from tail of queue */
-extern queue_entry_t dequeue_tail(
- queue_t que);
-
-/* Dequeue element */
-extern void remqueue(
- queue_t que,
- queue_entry_t elt);
-
-/* Enqueue element after a particular elem */
-extern void insque(
- queue_entry_t entry,
- queue_entry_t pred);
-
-/* Dequeue element */
-extern int remque(
- queue_entry_t elt);
-
-__END_DECLS
+#ifdef XNU_KERNEL_PRIVATE
+#include <kern/debug.h>
+#include <mach/branch_predicates.h>
+static inline void __QUEUE_ELT_VALIDATE(queue_entry_t elt) {
+ queue_entry_t elt_next, elt_prev;
+
+ if (__improbable(elt == (queue_entry_t)0)) {
+ panic("Invalid queue element %p", elt);
+ }
+
+ elt_next = elt->next;
+ elt_prev = elt->prev;
+
+ if (__improbable(elt_next == (queue_entry_t)0 || elt_prev == (queue_entry_t)0)) {
+ panic("Invalid queue element pointers for %p: next %p prev %p", elt, elt_next, elt_prev);
+ }
+ if (__improbable(elt_next->prev != elt || elt_prev->next != elt)) {
+ panic("Invalid queue element linkage for %p: next %p next->prev %p prev %p prev->next %p",
+ elt, elt_next, elt_next->prev, elt_prev, elt_prev->next);
+ }
+}