- kern_return_t rtn = KERN_SUCCESS;
- int retry;
-
- /* Make sure there is room in the queue before doing anything else */
-
- if (gotoSleep) {
- retry = 0;
- do
- rtn = semaphore_wait(producerSema);
- while( (KERN_SUCCESS != rtn)
- && (KERN_OPERATION_TIMED_OUT != rtn)
- && (KERN_SEMAPHORE_DESTROYED != rtn)
- && (KERN_TERMINATED != rtn)
- && ((retry++) < 4));
- } else
- rtn = semaphore_timedwait(producerSema, MACH_TIMESPEC_ZERO);
-
- if (KERN_SUCCESS != rtn)
- return rtn;
-
- /* Block other producers */
- IOTakeLock(producerLock);
-
- /*
- * Make sure that we update the current producer entry before we
- * increment the producer pointer. This avoids a nasty race as the
- * as the test for work is producerIndex != consumerIndex and a signal.
- */
- {
- commandEntryT *q = (commandEntryT *) queue;
- int localIndex = producerIndex;
-
- q[localIndex].f[0] = field0; q[localIndex].f[1] = field1;
- q[localIndex].f[2] = field2; q[localIndex].f[3] = field3;
- }
- if (++producerIndex >= size)
- producerIndex = 0;
-
- /* Clear to allow other producers to go now */
- IOUnlock(producerLock);
-
- /*
- * Right we have created some new work, we had better make sure that
- * we notify the work loop that it has to test producerIndex.
- */
- signalWorkAvailable();
- return rtn;
+ kern_return_t rtn = KERN_SUCCESS;
+ int retry;
+
+ /* Make sure there is room in the queue before doing anything else */
+
+ if (gotoSleep) {
+ retry = 0;
+ do{
+ rtn = semaphore_wait(producerSema);
+ } while ((KERN_SUCCESS != rtn)
+ && (KERN_OPERATION_TIMED_OUT != rtn)
+ && (KERN_SEMAPHORE_DESTROYED != rtn)
+ && (KERN_TERMINATED != rtn)
+ && ((retry++) < 4));
+ } else {
+ rtn = semaphore_timedwait(producerSema, MACH_TIMESPEC_ZERO);
+ }
+
+ if (KERN_SUCCESS != rtn) {
+ return rtn;
+ }
+
+ /* Block other producers */
+ IOTakeLock(producerLock);
+
+ /*
+ * Make sure that we update the current producer entry before we
+ * increment the producer pointer. This avoids a nasty race as the
+ * test for work is producerIndex != consumerIndex and a signal.
+ */
+ {
+ commandEntryT *q = (commandEntryT *) queue;
+ int localIndex = producerIndex;
+
+ q[localIndex].f[0] = field0; q[localIndex].f[1] = field1;
+ q[localIndex].f[2] = field2; q[localIndex].f[3] = field3;
+ }
+ if (++producerIndex >= size) {
+ producerIndex = 0;
+ }
+
+ /* Clear to allow other producers to go now */
+ IOUnlock(producerLock);
+
+ /*
+ * Right we have created some new work, we had better make sure that
+ * we notify the work loop that it has to test producerIndex.
+ */
+ signalWorkAvailable();
+ return rtn;