if (me & 1)
{
AO_t my_counter1;
- if (me != 1)
- fprintf(stderr, "acqrel test: too many threads\n");
- my_counter1 = AO_load(&counter1);
- AO_store(&counter1, my_counter1 + 1);
- AO_store_release_write(&counter2, my_counter1 + 1);
+ if (me != 1)
+ fprintf(stderr, "acqrel test: too many threads\n");
+ my_counter1 = AO_load(&counter1);
+ AO_store(&counter1, my_counter1 + 1);
+ AO_store_release_write(&counter2, my_counter1 + 1);
}
else
{
- AO_t my_counter1a, my_counter2a;
- AO_t my_counter1b, my_counter2b;
-
- my_counter2a = AO_load_acquire_read(&counter2);
- my_counter1a = AO_load(&counter1);
- /* Redo this, to make sure that the second load of counter1 */
- /* is not viewed as a common subexpression. */
- my_counter2b = AO_load_acquire_read(&counter2);
- my_counter1b = AO_load(&counter1);
- if (my_counter1a < my_counter2a)
- {
- fprintf(stderr, "Saw release store out of order: %lu < %lu\n",
- (unsigned long)my_counter1a, (unsigned long)my_counter2a);
- abort();
- }
- if (my_counter1b < my_counter2b)
- {
- fprintf(stderr,
- "Saw release store out of order (bad CSE?): %lu < %lu\n",
- (unsigned long)my_counter1b, (unsigned long)my_counter2b);
- abort();
- }
+ AO_t my_counter1a, my_counter2a;
+ AO_t my_counter1b, my_counter2b;
+
+ my_counter2a = AO_load_acquire_read(&counter2);
+ my_counter1a = AO_load(&counter1);
+ /* Redo this, to make sure that the second load of counter1 */
+ /* is not viewed as a common subexpression. */
+ my_counter2b = AO_load_acquire_read(&counter2);
+ my_counter1b = AO_load(&counter1);
+ if (my_counter1a < my_counter2a)
+ {
+ fprintf(stderr, "Saw release store out of order: %lu < %lu\n",
+ (unsigned long)my_counter1a, (unsigned long)my_counter2a);
+ abort();
+ }
+ if (my_counter1b < my_counter2b)
+ {
+ fprintf(stderr,
+ "Saw release store out of order (bad CSE?): %lu < %lu\n",
+ (unsigned long)my_counter1b, (unsigned long)my_counter2b);
+ abort();
+ }
}
return 0;
++locked_counter;
if (locked_counter != 1)
{
- fprintf(stderr, "Test and set failure 1, counter = %ld\n",
- locked_counter);
+ fprintf(stderr, "Test and set failure 1, counter = %ld, id = %d\n",
+ locked_counter, (int)(AO_PTRDIFF_T)id);
abort();
}
locked_counter *= 2;
locked_counter -= 4;
if (locked_counter != 1)
{
- fprintf(stderr, "Test and set failure 2, counter = %ld\n",
- locked_counter);
+ fprintf(stderr, "Test and set failure 2, counter = %ld, id = %d\n",
+ locked_counter, (int)(AO_PTRDIFF_T)id);
abort();
}
--locked_counter;
size_t my_extra = extra;
ln *result;
int * extras;
- int i;
+ unsigned i;
if (my_extra > 100)
extra = my_extra = 0;
ln *p;
int i;
- for (p = l, i = m; p != 0; p = p -> next, ++i)
+ for (p = l, i = m; p != 0 && i <= n; p = p -> next, ++i)
{
if (i != p -> data)
{
abort();
}
}
+ if (i <= n)
+ {
+ fprintf(stderr, "Number not found: %d\n", i);
+ abort();
+ }
+ if (p != 0)
+ {
+ fprintf(stderr, "Found unexpected number: %d\n", i);
+ abort();
+ }
}
/* Create a list of integers from m to n */
x = reverse(x, 0);
}
check_list(x, 1, LIST_LENGTH);
- return 0;
+ return arg; /* use arg to suppress compiler warning */
}
int main(int argc, char **argv) {