Hello!

This patch avoids unnecessary clearing of 4th argument for futex_wake
syscall for 32bit targets.

2015-05-28  Uros Bizjak  <ubiz...@gmail.com>

    * config/linux/x86/futex.h (sys_futex0) [!__x86_64__]: Remove function.
    (futex_wait) [!__x86_64__]: Use __asm operand instead of sys_futex0.
    (futex_wake) [!__x86_64__]: Ditto.

Tested on x86_64-linux-gnu {,-m32} and committed to mainline SVN.

Uros.
Index: config/linux/x86/futex.h
===================================================================
--- config/linux/x86/futex.h    (revision 223796)
+++ config/linux/x86/futex.h    (working copy)
@@ -81,43 +81,49 @@
 #  define SYS_futex    240
 # endif
 
-static inline long
-sys_futex0 (int *addr, int op, int val)
+static inline void
+futex_wait (int *addr, int val)
 {
   long res;
 
   __asm volatile ("int $0x80"
                  : "=a" (res)
-                 : "0"(SYS_futex), "b" (addr), "c"(op),
-                   "d"(val), "S"(0)
+                 : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wait),
+                   "d" (val), "S" (0)
                  : "memory");
-  return res;
-}
-
-static inline void
-futex_wait (int *addr, int val)
-{
-  long res = sys_futex0 (addr, gomp_futex_wait, val);
   if (__builtin_expect (res == -ENOSYS, 0))
     {
       gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
       gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
-      sys_futex0 (addr, gomp_futex_wait, val);
+      __asm volatile ("int $0x80"
+                     : "=a" (res)
+                     : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wait),
+                       "d" (val), "S" (0)
+                     : "memory");
     }
 }
 
 static inline void
 futex_wake (int *addr, int count)
 {
-  long res = sys_futex0 (addr, gomp_futex_wake, count);
+  long res;
+
+  __asm volatile ("int $0x80"
+                 : "=a" (res)
+                 : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wake),
+                   "d" (count)
+                 : "memory");
   if (__builtin_expect (res == -ENOSYS, 0))
     {
       gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
       gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
-      sys_futex0 (addr, gomp_futex_wake, count);
+      __asm volatile ("int $0x80"
+                     : "=a" (res)
+                     : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wake),
+                       "d" (count)
+                     : "memory");
     }
 }
-
 #endif /* __x86_64__ */
 
 static inline void

Reply via email to