Compile time futex syscall detection
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 17 Nov 2020 23:28:20 +0000 (18:28 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 20 Nov 2020 19:32:56 +0000 (14:32 -0500)
The futex syscall availability is detected at configure time using a
simple compile test. Replace this with compile time detection using the
same test. This would allow sharing headers in a multi-arch environment
and reduce the build system complexity.

Change-Id: Ief709429e8908d0fd2d268d42f4a89d9fc14b91b
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
configure.ac
include/urcu/config.h.in
include/urcu/futex.h

index 82f0c46712f2545ebe661a1a01a996727593bba2..d1d43e645c3366e457c5d34d8475a21af5cc80e2 100644 (file)
@@ -21,7 +21,6 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 AC_REQUIRE_AUX_FILE([tap-driver.sh])
 
 AH_TEMPLATE([CONFIG_RCU_SMP], [Enable SMP support. With SMP support enabled, uniprocessors are also supported. With SMP support disabled, UP systems work fine, but the behavior of SMP systems is undefined.])
-AH_TEMPLATE([CONFIG_RCU_HAVE_FUTEX], [Defined when on a system with futex support.])
 AH_TEMPLATE([CONFIG_RCU_ARM_HAVE_DMB], [Use the dmb instruction if available for use on ARM.])
 AH_TEMPLATE([CONFIG_RCU_TLS], [TLS provided by the compiler.])
 AH_TEMPLATE([CONFIG_RCU_HAVE_CLOCK_GETTIME], [clock_gettime() is detected.])
@@ -143,30 +142,12 @@ AS_CASE([$host_cpu], [arm*], [
        ])
 ])
 
-# Check if sys_futex() is available
-AC_MSG_CHECKING([for sys_futex()])
-AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
-               #include <sys/syscall.h>
-               #ifndef __NR_futex
-               #error "futexes not available"
-               #endif
-       ]])
-],[
-       AC_MSG_RESULT([yes])
-       AC_DEFINE([CONFIG_RCU_HAVE_FUTEX], [1])
-       compat_futex_test=0
-],[
-       AC_MSG_RESULT([no])
-       compat_futex_test=1
-])
-
 # Search for clock_gettime
 AC_SEARCH_LIBS([clock_gettime], [rt], [
        AC_DEFINE([CONFIG_RCU_HAVE_CLOCK_GETTIME], [1])
        config_rcu_have_clock_gettime=yes
 ], [])
 
-AM_CONDITIONAL([COMPAT_FUTEX], [test "x$compat_futex_test" = "x1"])
 AM_CONDITIONAL([NO_SHARED], [test "x$enable_shared" = "xno"])
 
 # smp-support configure option
@@ -403,10 +384,6 @@ PPRINT_PROP_STRING([Target architecture], $host_cpu)
 test "x$def_smp_support" = "xyes" && value=1 || value=0
 PPRINT_PROP_BOOL([SMP support], $value)
 
-# Futex support available
-test "x$compat_futex_test" = "x0" && value=1 || value=0
-PPRINT_PROP_BOOL([Futex support], $value)
-
 # TLS
 test "x$def_compiler_tls" = "xyes" && value="compiler TLS" || value="pthread_getspecific()"
 PPRINT_PROP_STRING([Thread Local Storage (TLS)], [$value])
index 38094a6d57bd8e14b2556ee822847ec86c8bf01a..faf7817ba257f779a11af5b463973eb045dd1834 100644 (file)
@@ -1,8 +1,5 @@
 /* urcu/config.h.in. Manually generated for control over the contained defs. */
 
-/* Defined when on a system with futex support. */
-#undef CONFIG_RCU_HAVE_FUTEX
-
 /* Enable SMP support. With SMP support enabled, uniprocessors are also
    supported. With SMP support disabled, UP systems work fine, but the
    behavior of SMP systems is undefined. */
index f720cdc0db52ed41cd391bec9b570464492a026e..039d3930c45f99eb26baa2f342a8837e8f39853f 100644 (file)
@@ -24,6 +24,8 @@
  */
 
 #include <urcu/config.h>
+#include <urcu/syscall-compat.h>
+
 #include <errno.h>
 #include <stdint.h>
 #include <time.h>
@@ -54,7 +56,10 @@ extern int compat_futex_noasync(int32_t *uaddr, int op, int32_t val,
 extern int compat_futex_async(int32_t *uaddr, int op, int32_t val,
                const struct timespec *timeout, int32_t *uaddr2, int32_t val3);
 
-#ifdef CONFIG_RCU_HAVE_FUTEX
+#if (defined(__linux__) && defined(__NR_futex_))
+
+/* For backwards compat */
+#define CONFIG_RCU_HAVE_FUTEX 1
 
 #include <unistd.h>
 #include <errno.h>
This page took 0.027115 seconds and 4 git commands to generate.