[Commits] 4dea848: MDEV-10983: TokuDB does not compile on OS X 10.12

Vicentiu Ciorbaru vicentiu at mariadb.org
Sun Oct 9 16:52:06 EEST 2016


revision-id: 4dea84837ff0f9d587f3bc29efceea5c251d1c9c (mariadb-10.2.2-35-g4dea848)
parent(s): 553ca406cd44946d454d84c08a7247ef595378f5
author: Vicențiu Ciorbaru
committer: Vicențiu Ciorbaru
timestamp: 2016-10-09 15:44:35 +0200
message:

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.

---
 .../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(-)

diff --git a/storage/tokudb/PerconaFT/cmake_modules/TokuFeatureDetection.cmake b/storage/tokudb/PerconaFT/cmake_modules/TokuFeatureDetection.cmake
index e3c900f..2f04a33 100644
--- a/storage/tokudb/PerconaFT/cmake_modules/TokuFeatureDetection.cmake
+++ b/storage/tokudb/PerconaFT/cmake_modules/TokuFeatureDetection.cmake
@@ -97,7 +97,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)
@@ -109,6 +109,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)
 check_function_exists(sched_getcpu HAVE_SCHED_GETCPU)
diff --git a/storage/tokudb/PerconaFT/portability/portability.cc b/storage/tokudb/PerconaFT/portability/portability.cc
index ba9f8d4..19f445a 100644
--- a/storage/tokudb/PerconaFT/portability/portability.cc
+++ b/storage/tokudb/PerconaFT/portability/portability.cc
@@ -63,6 +63,9 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
 #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
@@ -102,7 +105,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);
diff --git a/storage/tokudb/PerconaFT/portability/tests/test-xid.cc b/storage/tokudb/PerconaFT/portability/tests/test-xid.cc
index 9ee6890..71736f8 100644
--- a/storage/tokudb/PerconaFT/portability/tests/test-xid.cc
+++ b/storage/tokudb/PerconaFT/portability/tests/test-xid.cc
@@ -51,11 +51,18 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
 #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);
diff --git a/storage/tokudb/PerconaFT/portability/toku_config.h.in b/storage/tokudb/PerconaFT/portability/toku_config.h.in
index 9033f27..79172c5 100644
--- a/storage/tokudb/PerconaFT/portability/toku_config.h.in
+++ b/storage/tokudb/PerconaFT/portability/toku_config.h.in
@@ -92,6 +92,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
 #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


More information about the commits mailing list