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

MDEV-15778: Fix TokuDB build issues on macOS 10.13.4

Several issues were encountered and fixed as explained bellow:

* missing link to dbug lib;
* user proper fprintf format specifier;
* ZERO_COND_INITIALIZER was using wrong toku_cond_t struct
  initializer for first member of type pthread_cond_t and
  not considering the TOKU_PTHREAD_DEBUG case which has
  one extra struct member of type pfs_key_t;
* Remove likely(!opt_debug_sync_timeout), argument is
  declared extern and not available to Toku;
* pthread_mutex_timedlock() is not available in pthreads
  for Mac, as it's not part of the POSIX pthreads spec.
  The encompassing event_t::wait(ms) methods are unused,
  thus have been removed;
parent 8f82c484
......@@ -821,7 +821,7 @@ int toku_ftnode_fetch_callback(CACHEFILE UU(cachefile),
fprintf(
stderr,
"%s:%d:toku_ftnode_fetch_callback - "
"file[%s], blocknum[%ld], toku_deserialize_ftnode_from "
"file[%s], blocknum[%lld], toku_deserialize_ftnode_from "
"failed with a checksum error.\n",
__FILE__,
__LINE__,
......@@ -831,7 +831,7 @@ int toku_ftnode_fetch_callback(CACHEFILE UU(cachefile),
fprintf(
stderr,
"%s:%d:toku_ftnode_fetch_callback - "
"file[%s], blocknum[%ld], toku_deserialize_ftnode_from "
"file[%s], blocknum[%lld], toku_deserialize_ftnode_from "
"failed with %d.\n",
__FILE__,
__LINE__,
......
......@@ -656,9 +656,9 @@ int deserialize_ft_from_fd_into_rbuf(int fd,
fprintf(stderr, \
"%s:%d toku_deserialize_ft_from: " \
"filename[%s] " \
"r[%d] max_acceptable_lsn[%lu]" \
"r0[%d] checkpoint_lsn_0[%lu] checkpoint_count_0[%lu] " \
"r1[%d] checkpoint_lsn_1[%lu] checkpoint_count_1[%lu]\n", \
"r[%d] max_acceptable_lsn[%llu]" \
"r0[%d] checkpoint_lsn_0[%llu] checkpoint_count_0[%llu] " \
"r1[%d] checkpoint_lsn_1[%llu] checkpoint_count_1[%llu]\n", \
__FILE__, \
__LINE__, \
fn, \
......
......@@ -62,9 +62,6 @@ inline void toku_debug_sync(struct tokutxn *txn, const char *sync_point_name) {
void *client_extra;
THD *thd;
if (likely(!opt_debug_sync_timeout))
return;
toku_txn_get_client_id(txn, &client_id, &client_extra);
thd = reinterpret_cast<THD *>(client_extra);
DEBUG_SYNC(thd, sync_point_name);
......
......@@ -162,10 +162,20 @@ typedef struct toku_mutex_aligned {
#define ZERO_COND_INITIALIZER \
{ 0 }
#elif defined(__APPLE__)
#if TOKU_PTHREAD_DEBUG
#define ZERO_COND_INITIALIZER \
{ \
{ 0 , { 0 } }, \
nullptr, \
0 \
}
#else
#define ZERO_COND_INITIALIZER \
{ \
{ 0 } \
{ 0 , { 0 } }, \
nullptr \
}
#endif
#else // __linux__, at least
#define ZERO_COND_INITIALIZER \
{}
......
......@@ -18,7 +18,7 @@ set(tokudb_srcs
## make the shared library
add_library(${LIBTOKUDB} SHARED ${tokudb_srcs})
add_dependencies(${LIBTOKUDB} install_tdb_h generate_log_code)
target_link_libraries(${LIBTOKUDB} LINK_PRIVATE locktree_static ft_static util_static lzma snappy ${LIBTOKUPORTABILITY})
target_link_libraries(${LIBTOKUDB} LINK_PRIVATE locktree_static ft_static util_static lzma snappy dbug ${LIBTOKUPORTABILITY})
target_link_libraries(${LIBTOKUDB} LINK_PUBLIC ${ZLIB_LIBRARY} )
## make the static library
......
......@@ -111,7 +111,6 @@ class event_t {
// wait for the event to become signalled
void wait(void);
int wait(ulonglong microseconds);
// signal the event
void signal(void);
......@@ -152,7 +151,6 @@ class semaphore_t {
// wait for the semaphore to become signalled
E_WAIT wait(void);
E_WAIT wait(ulonglong microseconds);
// signal the semaphore to increase the count
// return true if signalled, false if ignored due to count
......@@ -372,28 +370,6 @@ inline void event_t::wait(void) {
assert_debug(r == 0);
return;
}
inline int event_t::wait(ulonglong microseconds) {
timespec waittime = time::offset_timespec(microseconds);
int r = pthread_mutex_timedlock(&_mutex, &waittime);
if (r == ETIMEDOUT) return ETIMEDOUT;
assert_debug(r == 0);
while (_signalled == false && _pulsed == false) {
r = pthread_cond_timedwait(&_cond, &_mutex, &waittime);
if (r == ETIMEDOUT) {
r = pthread_mutex_unlock(&_mutex);
assert_debug(r == 0);
return ETIMEDOUT;
}
assert_debug(r == 0);
}
if (_manual_reset == false)
_signalled = false;
if (_pulsed)
_pulsed = false;
r = pthread_mutex_unlock(&_mutex);
assert_debug(r == 0);
return 0;
}
inline void event_t::signal(void) {
int r MY_ATTRIBUTE((unused)) = pthread_mutex_lock(&_mutex);
assert_debug(r == 0);
......@@ -479,31 +455,6 @@ inline semaphore_t::E_WAIT semaphore_t::wait(void) {
assert_debug(r == 0);
return ret;
}
inline semaphore_t::E_WAIT semaphore_t::wait(ulonglong microseconds) {
E_WAIT ret;
timespec waittime = time::offset_timespec(microseconds);
int r = pthread_mutex_timedlock(&_mutex, &waittime);
if (r == ETIMEDOUT) return E_TIMEDOUT;
assert_debug(r == 0);
while (_signalled == 0 && _interrupted == false) {
r = pthread_cond_timedwait(&_cond, &_mutex, &waittime);
if (r == ETIMEDOUT) {
r = pthread_mutex_unlock(&_mutex);
assert_debug(r == 0);
return E_TIMEDOUT;
}
assert_debug(r == 0);
}
if (_interrupted) {
ret = E_INTERRUPTED;
} else {
_signalled--;
ret = E_SIGNALLED;
}
r = pthread_mutex_unlock(&_mutex);
assert_debug(r == 0);
return ret;
}
inline bool semaphore_t::signal(void) {
bool ret = false;
int r MY_ATTRIBUTE((unused)) = pthread_mutex_lock(&_mutex);
......
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