Commit b8e267c0 authored by Teodor Mircea Ionita's avatar Teodor Mircea Ionita Committed by Vicențiu-Marian Ciorbaru

MDEV-15778: Manually backport TokuDB macOS fixes from 10.0

Fix build on macOS 10.13:

39dceaae MDEV-10983: TokuDB does not compile on OS X 10.12
Make use of a different function to get the current tid.
Additionally, librt doesn't exist on OS X. Use System library instead.

 storage/tokudb/PerconaFT/cmake_modules/TokuFeatureDetection.cmake | 4 +++-
 storage/tokudb/PerconaFT/portability/portability.cc               | 9 ++++++++-
 storage/tokudb/PerconaFT/portability/tests/test-xid.cc            | 9 ++++++++-
 storage/tokudb/PerconaFT/portability/toku_config.h.in             | 1 +
 4 files changed, 20 insertions(+), 3 deletions(-)
parent d9b159a2
......@@ -96,7 +96,7 @@ if (NOT HAVE_BACKTRACE_WITHOUT_EXECINFO)
endif ()
endif ()
if(HAVE_CLOCK_REALTIME)
if(HAVE_CLOCK_REALTIME AND (NOT APPLE))
list(APPEND EXTRA_SYSTEM_LIBS rt)
else()
list(APPEND EXTRA_SYSTEM_LIBS System)
......@@ -108,6 +108,8 @@ check_function_exists(pthread_rwlockattr_setkind_np HAVE_PTHREAD_RWLOCKATTR_SETK
## check for the right way to yield using pthreads
check_function_exists(pthread_yield HAVE_PTHREAD_YIELD)
check_function_exists(pthread_yield_np HAVE_PTHREAD_YIELD_NP)
## check if we have pthread_threadid_np() (i.e. osx)
check_function_exists(pthread_threadid_np HAVE_PTHREAD_THREADID_NP)
## check if we have pthread_getthreadid_np() (i.e. freebsd)
check_function_exists(pthread_getthreadid_np HAVE_PTHREAD_GETTHREADID_NP)
......
......@@ -115,6 +115,9 @@ PATENT RIGHTS GRANT:
#if defined(HAVE_SYS_SYSCTL_H)
# include <sys/sysctl.h>
#endif
#if defined(HAVE_PTHREAD_H)
# include <pthread.h>
#endif
#if defined(HAVE_PTHREAD_NP_H)
# include <pthread_np.h>
#endif
......@@ -154,7 +157,11 @@ toku_os_getpid(void) {
int
toku_os_gettid(void) {
#if defined(__NR_gettid)
#if defined(HAVE_PTHREAD_THREADID_NP)
uint64_t result;
pthread_threadid_np(NULL, &result);
return (int) result; // Used for instrumentation so overflow is ok here.
#elif defined(__NR_gettid)
return syscall(__NR_gettid);
#elif defined(SYS_gettid)
return syscall(SYS_gettid);
......
......@@ -103,11 +103,18 @@ PATENT RIGHTS GRANT:
#if defined(HAVE_PTHREAD_NP_H)
# include <pthread_np.h>
#endif
#if defined(HAVE_PTHREAD_H)
# include <pthread.h>
#endif
// since we implement the same thing here as in toku_os_gettid, this test
// is pretty pointless
static int gettid(void) {
#if defined(__NR_gettid)
#if defined(HAVE_PTHREAD_THREADID_NP)
uint64_t result;
pthread_threadid_np(NULL, &result);
return (int) result;
#elif defined(__NR_gettid)
return syscall(__NR_gettid);
#elif defined(SYS_gettid)
return syscall(SYS_gettid);
......
......@@ -57,6 +57,7 @@
#cmakedefine HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP 1
#cmakedefine HAVE_PTHREAD_YIELD 1
#cmakedefine HAVE_PTHREAD_YIELD_NP 1
#cmakedefine HAVE_PTHREAD_THREADID_NP 1
#cmakedefine HAVE_PTHREAD_GETTHREADID_NP 1
#cmakedefine PTHREAD_YIELD_RETURNS_INT 1
......
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