Systems without preemptive multi-threading require sched_yield calls
to be placed at points in which a context switch might be needed to
enable the test to complete.
Regstrapped on x86_64-linux-gnu, also tested with a cross to
aarch64-rtems6. Ok to install?
for gcc/testsuite/ChangeLog
* gcc.dg/atomic/c11-atomic-exec-4.c: Call sched_yield.
* gcc.dg/atomic/c11-atomic-exec-5.c: Likewise.
* gcc.dg/atomic/pr80640-2.c: Likewise.
* gcc.dg/atomic/pr80640.c: Likewise.
* gcc.dg/atomic/pr81316.c: Likewise.
* gcc.dg/di-sync-multithread.c: Likewise.
---
gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-4.c | 12 +---
gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-5.c |6 +-
gcc/testsuite/gcc.dg/atomic/pr80640-2.c |6 --
gcc/testsuite/gcc.dg/atomic/pr80640.c |6 --
gcc/testsuite/gcc.dg/atomic/pr81316.c |9 +++--
gcc/testsuite/gcc.dg/di-sync-multithread.c |8
6 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-4.c
b/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-4.c
index d6bb629f59ffa..669e7c058c39e 100644
--- a/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-4.c
+++ b/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-4.c
@@ -32,7 +32,10 @@ test_thread_##NAME (void *arg)
\
{ \
thread_ready = true; \
for (int i = 0; i < ITER_COUNT; i++) \
-PRE var_##NAME POST; \
+{ \
+ sched_yield (); \
+ PRE var_##NAME POST; \
+} \
return NULL; \
} \
\
@@ -49,9 +52,12 @@ test_main_##NAME (void)
\
return 1;
\
} \
while (!thread_ready)
\
-; \
+sched_yield ();\
for (int i = 0; i < ITER_COUNT; i++) \
-PRE var_##NAME POST; \
+{ \
+ PRE var_##NAME POST; \
+ sched_yield (); \
+} \
pthread_join (thread_id, NULL); \
if (var_##NAME != (FINAL)) \
{ \
diff --git a/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-5.c
b/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-5.c
index 692c64ad20737..f8bfa63b4cc8a 100644
--- a/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-5.c
+++ b/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-5.c
@@ -53,8 +53,11 @@ test_thread_##NAME (void *arg)
\
thread_ready = true; \
while (!thread_stop) \
{ \
+ sched_yield (); \
var_##NAME = (INIT1);\
+ sched_yield (); \
var_##NAME = (INIT2);\
+ sched_yield (); \
} \
return NULL; \
} \
@@ -75,13 +78,14 @@ test_main_##NAME (void)
\
} \
int num_1_pass = 0, num_1_fail = 0, num_2_pass = 0, num_2_fail = 0; \
while (!thread_ready)
\
-; \
+sched_yield ();