Commit 39dceaae authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

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.
parent ba11dd69
...@@ -97,7 +97,7 @@ if (NOT HAVE_BACKTRACE_WITHOUT_EXECINFO) ...@@ -97,7 +97,7 @@ if (NOT HAVE_BACKTRACE_WITHOUT_EXECINFO)
endif () endif ()
endif () endif ()
if(HAVE_CLOCK_REALTIME) if(HAVE_CLOCK_REALTIME AND (NOT APPLE))
list(APPEND EXTRA_SYSTEM_LIBS rt) list(APPEND EXTRA_SYSTEM_LIBS rt)
else() else()
list(APPEND EXTRA_SYSTEM_LIBS System) list(APPEND EXTRA_SYSTEM_LIBS System)
...@@ -109,6 +109,8 @@ check_function_exists(pthread_rwlockattr_setkind_np HAVE_PTHREAD_RWLOCKATTR_SETK ...@@ -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 for the right way to yield using pthreads
check_function_exists(pthread_yield HAVE_PTHREAD_YIELD) check_function_exists(pthread_yield HAVE_PTHREAD_YIELD)
check_function_exists(pthread_yield_np HAVE_PTHREAD_YIELD_NP) 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 if we have pthread_getthreadid_np() (i.e. freebsd)
check_function_exists(pthread_getthreadid_np HAVE_PTHREAD_GETTHREADID_NP) check_function_exists(pthread_getthreadid_np HAVE_PTHREAD_GETTHREADID_NP)
check_function_exists(sched_getcpu HAVE_SCHED_GETCPU) check_function_exists(sched_getcpu HAVE_SCHED_GETCPU)
......
...@@ -63,6 +63,9 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. ...@@ -63,6 +63,9 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#if defined(HAVE_SYS_SYSCTL_H) #if defined(HAVE_SYS_SYSCTL_H)
# include <sys/sysctl.h> # include <sys/sysctl.h>
#endif #endif
#if defined(HAVE_PTHREAD_H)
# include <pthread.h>
#endif
#if defined(HAVE_PTHREAD_NP_H) #if defined(HAVE_PTHREAD_NP_H)
# include <pthread_np.h> # include <pthread_np.h>
#endif #endif
...@@ -102,7 +105,11 @@ toku_os_getpid(void) { ...@@ -102,7 +105,11 @@ toku_os_getpid(void) {
int int
toku_os_gettid(void) { 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); return syscall(__NR_gettid);
#elif defined(SYS_gettid) #elif defined(SYS_gettid)
return syscall(SYS_gettid); return syscall(SYS_gettid);
......
...@@ -51,11 +51,18 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. ...@@ -51,11 +51,18 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#if defined(HAVE_PTHREAD_NP_H) #if defined(HAVE_PTHREAD_NP_H)
# include <pthread_np.h> # include <pthread_np.h>
#endif #endif
#if defined(HAVE_PTHREAD_H)
# include <pthread.h>
#endif
// since we implement the same thing here as in toku_os_gettid, this test // since we implement the same thing here as in toku_os_gettid, this test
// is pretty pointless // is pretty pointless
static int gettid(void) { 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); return syscall(__NR_gettid);
#elif defined(SYS_gettid) #elif defined(SYS_gettid)
return syscall(SYS_gettid); return syscall(SYS_gettid);
......
...@@ -87,6 +87,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. ...@@ -87,6 +87,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#cmakedefine HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP 1 #cmakedefine HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP 1
#cmakedefine HAVE_PTHREAD_YIELD 1 #cmakedefine HAVE_PTHREAD_YIELD 1
#cmakedefine HAVE_PTHREAD_YIELD_NP 1 #cmakedefine HAVE_PTHREAD_YIELD_NP 1
#cmakedefine HAVE_PTHREAD_THREADID_NP 1
#cmakedefine HAVE_PTHREAD_GETTHREADID_NP 1 #cmakedefine HAVE_PTHREAD_GETTHREADID_NP 1
#cmakedefine PTHREAD_YIELD_RETURNS_INT 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