Skip to content
Permalink
Browse files
Cleanup: Remove HAVE_IB_LINUX_FUTEX
The futex system calls were introduced in Linux 2.6.0,
which was released in December 2003. It should be safe to assume
that the system calls are always available on the Linux kernels
that MariaDB Server 10.3 would run on.
  • Loading branch information
dr-m committed Sep 19, 2022
1 parent 4c8b65d commit 73658ed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 47 deletions.
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation.
Copyright (c) 2017, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -146,7 +146,7 @@ struct OSTrackMutex {
};


#ifdef HAVE_IB_LINUX_FUTEX
#ifdef __linux__

#include <linux/futex.h>
#include <sys/syscall.h>
@@ -260,7 +260,7 @@ struct TTASFutexMutex {
int32 m_lock_word;
};

#endif /* HAVE_IB_LINUX_FUTEX */
#endif /* __linux__ */

template <template <typename> class Policy = NoPolicy>
struct TTASMutex {
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2012, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2020, MariaDB Corporation.
Copyright (c) 2017, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -40,10 +40,10 @@ Created 2012-03-24 Sunny Bains.

typedef OSMutex EventMutex;

# ifdef HAVE_IB_LINUX_FUTEX
# ifdef __linux__
UT_MUTEX_TYPE(TTASFutexMutex, GenericPolicy, FutexMutex);
UT_MUTEX_TYPE(TTASFutexMutex, BlockMutexPolicy, BlockFutexMutex);
# endif /* HAVE_IB_LINUX_FUTEX */
# endif /* __linux__ */

UT_MUTEX_TYPE(TTASMutex, GenericPolicy, SpinMutex);
UT_MUTEX_TYPE(TTASMutex, BlockMutexPolicy, BlockSpinMutex);
@@ -146,46 +146,6 @@ IF(NOT MSVC)
CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0")
SET_SOURCE_FILES_PROPERTIES(trx/trx0rec.cc PROPERTIES COMPILE_FLAGS -O1)
ENDIF()

# Only use futexes on Linux if GCC atomics are available
IF(NOT MSVC AND NOT CMAKE_CROSSCOMPILING)
CHECK_C_SOURCE_RUNS(
"
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
#include <linux/futex.h>
#include <unistd.h>
#include <sys/syscall.h>
int futex_wait(int* futex, int v) {
return(syscall(SYS_futex, futex, FUTEX_WAIT_PRIVATE, v, NULL, NULL, 0));
}
int futex_signal(int* futex) {
return(syscall(SYS_futex, futex, FUTEX_WAKE, 1, NULL, NULL, 0));
}
int main() {
int ret;
int m = 1;
/* It is setup to fail and return EWOULDBLOCK. */
ret = futex_wait(&m, 0);
assert(ret == -1 && errno == EWOULDBLOCK);
/* Shouldn't wake up any threads. */
assert(futex_signal(&m) == 0);
return(0);
}"
HAVE_IB_LINUX_FUTEX)
ENDIF()

IF(HAVE_IB_LINUX_FUTEX)
ADD_DEFINITIONS(-DHAVE_IB_LINUX_FUTEX=1)
ENDIF()

ENDIF(NOT MSVC)

CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF)
@@ -194,7 +154,7 @@ SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex")

IF(MUTEXTYPE MATCHES "event")
ADD_DEFINITIONS(-DMUTEX_EVENT)
ELSEIF(MUTEXTYPE MATCHES "futex" AND DEFINED HAVE_IB_LINUX_FUTEX)
ELSEIF(MUTEXTYPE MATCHES "futex" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
ADD_DEFINITIONS(-DMUTEX_FUTEX)
ELSE()
ADD_DEFINITIONS(-DMUTEX_SYS)

0 comments on commit 73658ed

Please sign in to comment.