2 /* { dg-final { simulate-thread } } */
5 #include "simulate-thread.h"
7 /* This test verifies that data races aren't introduced by structure subfield
18 /* This routine sets field a to 'x'. If executed properly, it will
19 not affect any of the other fields in the structure. An improper
20 implementation may load an entire word, change the 8 bits for field
21 'a' and write the entire word back out. */
22 __attribute__((noinline
))
28 static int global
= 0;
30 /* The other thread increments the value of each of the other fields
31 in the structure every cycle. If the store to the 'a' field does
32 an incorrect full or partial word load, mask and store, it will
33 write back an incorrect value to one or more of the other
35 void simulate_thread_other_threads()
44 /* Make sure that none of the other fields have been changed. */
45 int simulate_thread_step_verify()
50 printf("FAIL: Unexpected value. var.b is %d, should be %d\n",
56 printf("FAIL: Unexpected value. var.c is %d, should be %d\n",
62 printf("FAIL: Unexpected value. var.d is %d, should be %d\n",
69 /* Verify that every variable has the correct value. */
70 int simulate_thread_final_verify()
72 int ret
= simulate_thread_step_verify();
75 printf("FAIL: Unexpected value. var.a is %d, should be %d\n", var
.a
, 1);
81 __attribute__((noinline
))
82 void simulate_thread_main()
89 simulate_thread_main();
90 simulate_thread_done();