Blame SOURCES/glibc-rh1579730-3.patch

147e83
Port sysdeps/unix/sysv/linux/i386/tst-bz21269.c to __atomic builtins
147e83
147e83
The upstream test uses <stdatomic.h>, which is not supported in the
147e83
Red Hat Enterprise Linux 7 system compiler.
147e83
147e83
The port uses __ATOMIC_SEQ_CST for consistency with the upstream test;
147e83
such as trong memory ordering is not actually required here.
147e83
147e83
Furthermore, it is necessary to change the SYS_ system call constants
147e83
to __NR_ constants.  Downstream builts the test with internal headers,
147e83
and those only have the __NR_ constants from the kernel.
147e83
147e83
The initializer of sa in xsethandler was replaced with a memset, to
147e83
avoid a warning about missing braces in an initializer (something that
147e83
later GCC versions do not warn about).
147e83
147e83
diff --git a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
147e83
index 6ee3fc62be0d3312..f58395cedc6972c4 100644
147e83
--- a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
147e83
+++ b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
147e83
@@ -26,8 +26,6 @@
147e83
    - Replicate only the test required to trigger the issue for the
147e83
      BZ#21269.  */
147e83
 
147e83
-#include <stdatomic.h>
147e83
-
147e83
 #include <asm/ldt.h>
147e83
 #include <linux/futex.h>
147e83
 
147e83
@@ -36,6 +34,7 @@
147e83
 #include <errno.h>
147e83
 #include <sys/syscall.h>
147e83
 #include <sys/mman.h>
147e83
+#include <string.h>
147e83
 
147e83
 #include <support/xunistd.h>
147e83
 #include <support/check.h>
147e83
@@ -44,7 +43,7 @@
147e83
 static int
147e83
 xset_thread_area (struct user_desc *u_info)
147e83
 {
147e83
-  long ret = syscall (SYS_set_thread_area, u_info);
147e83
+  long ret = syscall (__NR_set_thread_area, u_info);
147e83
   TEST_VERIFY_EXIT (ret == 0);
147e83
   return ret;
147e83
 }
147e83
@@ -52,20 +51,21 @@ xset_thread_area (struct user_desc *u_info)
147e83
 static void
147e83
 xmodify_ldt (int func, const void *ptr, unsigned long bytecount)
147e83
 {
147e83
-  TEST_VERIFY_EXIT (syscall (SYS_modify_ldt, 1, ptr, bytecount) == 0);
147e83
+  TEST_VERIFY_EXIT (syscall (__NR_modify_ldt, 1, ptr, bytecount) == 0);
147e83
 }
147e83
 
147e83
 static int
147e83
 futex (int *uaddr, int futex_op, int val, void *timeout, int *uaddr2,
147e83
 	int val3)
147e83
 {
147e83
-  return syscall (SYS_futex, uaddr, futex_op, val, timeout, uaddr2, val3);
147e83
+  return syscall (__NR_futex, uaddr, futex_op, val, timeout, uaddr2, val3);
147e83
 }
147e83
 
147e83
 static void
147e83
 xsethandler (int sig, void (*handler)(int, siginfo_t *, void *), int flags)
147e83
 {
147e83
-  struct sigaction sa = { 0 };
147e83
+  struct sigaction sa;
147e83
+  memset (&sa, 0, sizeof (sa));
147e83
   sa.sa_sigaction = handler;
147e83
   sa.sa_flags = SA_SIGINFO | flags;
147e83
   TEST_VERIFY_EXIT (sigemptyset (&sa.sa_mask) == 0);
147e83
@@ -128,7 +128,7 @@ setup_low_user_desc (void)
147e83
    1: thread armed.
147e83
    2: thread should clear LDT entry 0.
147e83
    3: thread should exit.  */
147e83
-static atomic_uint ftx;
147e83
+static unsigned int ftx;
147e83
 
147e83
 static void *
147e83
 threadproc (void *ctx)
147e83
@@ -136,9 +136,9 @@ threadproc (void *ctx)
147e83
   while (1)
147e83
     {
147e83
       futex ((int *) &ftx, FUTEX_WAIT, 1, NULL, NULL, 0);
147e83
-      while (atomic_load (&ftx) != 2)
147e83
+      while (__atomic_load_n (&ftx, __ATOMIC_SEQ_CST) != 2)
147e83
 	{
147e83
-	  if (atomic_load (&ftx) >= 3)
147e83
+	  if (__atomic_load_n (&ftx, __ATOMIC_SEQ_CST) >= 3)
147e83
 	    return NULL;
147e83
 	}
147e83
 
147e83
@@ -147,7 +147,7 @@ threadproc (void *ctx)
147e83
       xmodify_ldt (1, &desc, sizeof (desc));
147e83
 
147e83
       /* If ftx == 2, set it to zero,  If ftx == 100, quit.  */
147e83
-      if (atomic_fetch_add (&ftx, -2) != 2)
147e83
+      if (__atomic_fetch_add (&ftx, -2, __ATOMIC_SEQ_CST) != 2)
147e83
 	return NULL;
147e83
     }
147e83
 }
147e83
@@ -190,7 +190,7 @@ do_test (void)
147e83
 	continue;
147e83
 
147e83
       /* Make sure the thread is ready after the last test. */
147e83
-      while (atomic_load (&ftx) != 0)
147e83
+      while (__atomic_load_n (&ftx, __ATOMIC_SEQ_CST) != 0)
147e83
 	;
147e83
 
147e83
       struct user_desc desc = {
147e83
@@ -214,9 +214,9 @@ do_test (void)
147e83
       asm volatile ("mov %0, %%ss" : : "r" (0x7));
147e83
 
147e83
       /* Fire up thread modify_ldt call.  */
147e83
-      atomic_store (&ftx, 2);
147e83
+      __atomic_store_n (&ftx, 2, __ATOMIC_SEQ_CST);
147e83
 
147e83
-      while (atomic_load (&ftx) != 0)
147e83
+      while (__atomic_load_n (&ftx, __ATOMIC_SEQ_CST) != 0)
147e83
 	;
147e83
 
147e83
       /* On success, modify_ldt will segfault us synchronously and we will
147e83
@@ -224,7 +224,7 @@ do_test (void)
147e83
       support_record_failure ();
147e83
     }
147e83
 
147e83
-  atomic_store (&ftx, 100);
147e83
+  __atomic_store_n (&ftx, 100, __ATOMIC_SEQ_CST);
147e83
   futex ((int*) &ftx, FUTEX_WAKE, 0, NULL, NULL, 0);
147e83
 
147e83
   xpthread_join (thread);