+#ifdef CMPXCHG8B
+void * OSDequeueAtomic(void * volatile * inList, SInt32 inOffset)
+{
+ /* The _pointer_ is volatile, not the listhead itself */
+ void * volatile oldListHead;
+ void * volatile newListHead;
+
+ do {
+ oldListHead = *inList;
+ if (oldListHead == NULL) {
+ break;
+ }
+
+ newListHead = *(void * volatile *) (((char *) oldListHead) + inOffset);
+ } while (! OSCompareAndSwap((UInt32)oldListHead,
+ (UInt32)newListHead, (volatile UInt32 *)inList));
+ return oldListHead;
+}
+
+void OSEnqueueAtomic(void * volatile * inList, void * inNewLink, SInt32 inOffset)
+{
+ /* The _pointer_ is volatile, not the listhead itself */
+ void * volatile oldListHead;
+ void * volatile newListHead = inNewLink;
+ void * volatile * newLinkNextPtr = (void * volatile *) (((char *) inNewLink) + inOffset);
+
+ do {
+ oldListHead = *inList;
+ *newLinkNextPtr = oldListHead;
+ } while (! OSCompareAndSwap((UInt32)oldListHead, (UInt32)newListHead,
+ (volatile UInt32 *)inList));
+}
+#endif /* CMPXCHG8B */