arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1248208-2.patch

147e83
diff -pruN glibc-2.17-c758a686/nptl/tst-join7mod.c glibc-2.17-c758a686.new/nptl/tst-join7mod.c
147e83
--- glibc-2.17-c758a686/nptl/tst-join7mod.c	2015-08-13 17:06:56.505685552 +0530
147e83
+++ glibc-2.17-c758a686.new/nptl/tst-join7mod.c	2015-08-14 12:42:10.446315345 +0530
147e83
@@ -18,6 +18,7 @@
147e83
    <http://www.gnu.org/licenses/>.  */
147e83
 
147e83
 #include <stdio.h>
147e83
+#include <string.h>
147e83
 #include <pthread.h>
147e83
 #include <atomic.h>
147e83
 
147e83
@@ -27,7 +28,14 @@ static int running = 1;
147e83
 static void *
147e83
 test_run (void *p)
147e83
 {
147e83
-  while (atomic_load_relaxed (&running))
147e83
+  /* Spin on the value of RUNNING till it is 1.  The RHEL-7 version of atomic.h
147e83
+     does not yet have an atomic_load.  We don't need an acquire/release
147e83
+     barrier either since there is no ordering to worry about, but again,
147e83
+     atomic.h does not have relaxed atomic operations.  */
147e83
+  int oldval;
147e83
+  do
147e83
+    oldval = atomic_compare_and_exchange_val_acq (&running, 0, 0);
147e83
+  while (oldval == 1);
147e83
     printf ("Test running\n");
147e83
   printf ("Test finished\n");
147e83
   return NULL;
147e83
@@ -48,7 +56,7 @@ do_init (void)
147e83
 static void __attribute__ ((destructor))
147e83
 do_end (void)
147e83
 {
147e83
-  atomic_store_relaxed (&running, 0);
147e83
+  atomic_exchange_rel (&running, 0);
147e83
   int ret = pthread_join (th, NULL);
147e83
 
147e83
   if (ret != 0)