Commit dcdc8c35 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-21534 fixup: Remove HAVE_IB_LINUX_FUTEX

Since commit 30ea63b7
we actually depend on futex on Linux. Also, we depend on
std::atomic for even longer.
parent 1e5d989d
...@@ -145,7 +145,7 @@ struct OSTrackMutex { ...@@ -145,7 +145,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>
...@@ -261,7 +261,7 @@ struct TTASFutexMutex { ...@@ -261,7 +261,7 @@ struct TTASFutexMutex {
std::atomic<int32> m_lock_word; std::atomic<int32> m_lock_word;
}; };
#endif /* HAVE_IB_LINUX_FUTEX */ #endif /* __linux__ */
template <template <typename> class Policy> template <template <typename> class Policy>
struct TTASMutex { struct TTASMutex {
......
...@@ -24,11 +24,8 @@ Policy based mutexes. ...@@ -24,11 +24,8 @@ Policy based mutexes.
Created 2012-03-24 Sunny Bains. Created 2012-03-24 Sunny Bains.
***********************************************************************/ ***********************************************************************/
#pragma once
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
#ifndef ut0mutex_h
#define ut0mutex_h
#include "sync0policy.h" #include "sync0policy.h"
#include "ib0mutex.h" #include "ib0mutex.h"
...@@ -38,9 +35,9 @@ Created 2012-03-24 Sunny Bains. ...@@ -38,9 +35,9 @@ Created 2012-03-24 Sunny Bains.
@param[in] T The resulting typedef alias */ @param[in] T The resulting typedef alias */
#define UT_MUTEX_TYPE(M, P, T) typedef PolicyMutex<M<P> > T; #define UT_MUTEX_TYPE(M, P, T) typedef PolicyMutex<M<P> > T;
# ifdef HAVE_IB_LINUX_FUTEX # ifdef __linux__
UT_MUTEX_TYPE(TTASFutexMutex, GenericPolicy, FutexMutex); UT_MUTEX_TYPE(TTASFutexMutex, GenericPolicy, FutexMutex);
# endif /* HAVE_IB_LINUX_FUTEX */ # endif /* __linux__ */
UT_MUTEX_TYPE(TTASMutex, GenericPolicy, SpinMutex); UT_MUTEX_TYPE(TTASMutex, GenericPolicy, SpinMutex);
UT_MUTEX_TYPE(OSTrackMutex, GenericPolicy, SysMutex); UT_MUTEX_TYPE(OSTrackMutex, GenericPolicy, SysMutex);
...@@ -178,6 +175,4 @@ void mutex_destroy( ...@@ -178,6 +175,4 @@ void mutex_destroy(
mutex->destroy(); mutex->destroy();
} }
#endif /* ut0mutex_h */
#endif /* UNIV_INNOCHECKSUM */ #endif /* UNIV_INNOCHECKSUM */
...@@ -82,8 +82,6 @@ IF(INNODB_COMPILER_HINTS) ...@@ -82,8 +82,6 @@ IF(INNODB_COMPILER_HINTS)
ADD_DEFINITIONS("-DCOMPILER_HINTS") ADD_DEFINITIONS("-DCOMPILER_HINTS")
ENDIF() ENDIF()
SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex")
# Enable InnoDB's UNIV_DEBUG in debug builds # Enable InnoDB's UNIV_DEBUG in debug builds
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG")
...@@ -130,48 +128,8 @@ IF(NOT MSVC) ...@@ -130,48 +128,8 @@ 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() ENDIF()
IF(HAVE_IB_LINUX_FUTEX)
ADD_DEFINITIONS(-DHAVE_IB_LINUX_FUTEX=1)
ENDIF()
ENDIF(NOT MSVC)
CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF) CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF)
CHECK_CXX_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS) CHECK_CXX_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS)
...@@ -183,7 +141,7 @@ SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex") ...@@ -183,7 +141,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