Skip to content

Commit

Permalink
MDEV-10983: TokuDB does not compile on OS X 10.12
Browse files Browse the repository at this point in the history
Make use of a different function to get the current tid.

Additionally, librt doesn't exist on OS X. Use System library instead.
  • Loading branch information
cvicentiu committed Oct 25, 2016
1 parent ba11dd6 commit 39dceaa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion storage/tokudb/PerconaFT/portability/portability.cc
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion storage/tokudb/PerconaFT/portability/tests/test-xid.cc
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions storage/tokudb/PerconaFT/portability/toku_config.h.in
Expand Up @@ -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_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
Expand Down

0 comments on commit 39dceaa

Please sign in to comment.