olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1579730-3.patch

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