+ // Check for overflow of entrySize
+ if (dataSize > UINT32_MAX - DATA_QUEUE_ENTRY_HEADER_SIZE) {
+ return false;
+ }
+
+ // Force a single read of head and tail
+ head = __c11_atomic_load((_Atomic UInt32 *)&dataQueue->head, __ATOMIC_RELAXED);
+ tail = __c11_atomic_load((_Atomic UInt32 *)&dataQueue->tail, __ATOMIC_RELAXED);
+
+ // Check for underflow of (dataQueue->queueSize - tail)
+ queueSize = ((IODataQueueInternal *) notifyMsg)->queueSize;
+ if ((queueSize < tail) || (queueSize < head)) {
+ return false;
+ }
+