uint32_t mask = r->prod.mask;
int ret;
+ /* Avoid the unnecessary cmpset operation below, which is also
+ * potentially harmful when n equals 0. */
+ if (n == 0)
+ return 0;
+
/* move prod.head atomically */
do {
/* Reset n to the initial burst count */
unsigned i, rep = 0;
uint32_t mask = r->prod.mask;
+ /* Avoid the unnecessary cmpset operation below, which is also
+ * potentially harmful when n equals 0. */
+ if (n == 0)
+ return 0;
+
/* move cons.head atomically */
do {
/* Restore n as it may change every loop */