Commit 73658ede authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 4c8b65db
/***************************************************************************** /*****************************************************************************
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -146,7 +146,7 @@ struct OSTrackMutex { ...@@ -146,7 +146,7 @@ struct OSTrackMutex {
}; };
#ifdef HAVE_IB_LINUX_FUTEX #ifdef __linux__
#include <linux/futex.h> #include <linux/futex.h>
#include <sys/syscall.h> #include <sys/syscall.h>
...@@ -260,7 +260,7 @@ struct TTASFutexMutex { ...@@ -260,7 +260,7 @@ struct TTASFutexMutex {
int32 m_lock_word; int32 m_lock_word;
}; };
#endif /* HAVE_IB_LINUX_FUTEX */ #endif /* __linux__ */
template <template <typename> class Policy = NoPolicy> template <template <typename> class Policy = NoPolicy>
struct TTASMutex { struct TTASMutex {
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2012, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -40,10 +40,10 @@ Created 2012-03-24 Sunny Bains. ...@@ -40,10 +40,10 @@ Created 2012-03-24 Sunny Bains.
typedef OSMutex EventMutex; typedef OSMutex EventMutex;
# ifdef HAVE_IB_LINUX_FUTEX # ifdef __linux__
UT_MUTEX_TYPE(TTASFutexMutex, GenericPolicy, FutexMutex); UT_MUTEX_TYPE(TTASFutexMutex, GenericPolicy, FutexMutex);
UT_MUTEX_TYPE(TTASFutexMutex, BlockMutexPolicy, BlockFutexMutex); UT_MUTEX_TYPE(TTASFutexMutex, BlockMutexPolicy, BlockFutexMutex);
# endif /* HAVE_IB_LINUX_FUTEX */ # endif /* __linux__ */
UT_MUTEX_TYPE(TTASMutex, GenericPolicy, SpinMutex); UT_MUTEX_TYPE(TTASMutex, GenericPolicy, SpinMutex);
UT_MUTEX_TYPE(TTASMutex, BlockMutexPolicy, BlockSpinMutex); UT_MUTEX_TYPE(TTASMutex, BlockMutexPolicy, BlockSpinMutex);
......
...@@ -146,46 +146,6 @@ IF(NOT MSVC) ...@@ -146,46 +146,6 @@ IF(NOT MSVC)
CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0") CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0")
SET_SOURCE_FILES_PROPERTIES(trx/trx0rec.cc PROPERTIES COMPILE_FLAGS -O1) SET_SOURCE_FILES_PROPERTIES(trx/trx0rec.cc PROPERTIES COMPILE_FLAGS -O1)
ENDIF() 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) ENDIF(NOT MSVC)
CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF) CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF)
...@@ -194,7 +154,7 @@ SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex") ...@@ -194,7 +154,7 @@ SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex")
IF(MUTEXTYPE MATCHES "event") IF(MUTEXTYPE MATCHES "event")
ADD_DEFINITIONS(-DMUTEX_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) ADD_DEFINITIONS(-DMUTEX_FUTEX)
ELSE() ELSE()
ADD_DEFINITIONS(-DMUTEX_SYS) ADD_DEFINITIONS(-DMUTEX_SYS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment