diff --git a/libgomp/config/linux/x86/futex.h b/libgomp/config/linux/x86/futex.h
index 02d5b95..23c019a 100644
--- a/libgomp/config/linux/x86/futex.h
+++ b/libgomp/config/linux/x86/futex.h
@@ -30,10 +30,25 @@
 #  define SYS_futex	202
 # endif
 
+#pragma GCC visibility push(default)
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#pragma GCC visibility pop
+
 static inline void
 futex_wait (int *addr, int val)
 {
-  long res;
+  int err = syscall (SYS_futex, addr, gomp_futex_wait, val, NULL);
+  if (__builtin_expect (err < 0 && errno == ENOSYS, 0))
+    {
+      gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
+      gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
+      syscall (SYS_futex, addr, gomp_futex_wait, val, NULL);
+    }
+
+/*  long res;
 
   register long r10 __asm__("%r10") = 0;
   __asm volatile ("syscall"
@@ -51,12 +66,21 @@ futex_wait (int *addr, int val)
 			"d" (val), "r" (r10)
 		      : "r11", "rcx", "memory");
     }
+*/
 }
 
 static inline void
 futex_wake (int *addr, int count)
 {
-  long res;
+  int err = syscall (SYS_futex, addr, gomp_futex_wake, count);
+  if (__builtin_expect (err < 0 && errno == ENOSYS, 0))
+    {
+      gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
+      gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
+      syscall (SYS_futex, addr, gomp_futex_wake, count);
+    }
+
+/*  long res;
 
   __asm volatile ("syscall"
 		  : "=a" (res)
@@ -73,6 +97,7 @@ futex_wake (int *addr, int count)
 			"d" (count)
 		      : "r11", "rcx", "memory");
     }
+*/
 }
 #else
 # ifndef SYS_futex
