diff --git a/test/base.h b/test/base.h index 0b4d26e5..5ca134a8 100644 --- a/test/base.h +++ b/test/base.h @@ -39,6 +39,10 @@ #include #endif /* WINDOWS */ +#ifdef __APPLE__ +#define _DARWIN_C_SOURCE +#endif + #include #include #include diff --git a/test/config.h b/test/config.h index decd9612..89889d8e 100644 --- a/test/config.h +++ b/test/config.h @@ -102,6 +102,22 @@ bool parse_option(int argc, char *const argv[], int &narg, const char *option, bool parse_option(int argc, char *const argv[], int &narg, const char *option, int32_t &value, const int32_t minval, const int32_t maxval, const int32_t default_value = -1); + +inline bool parse_option_intptr(int argc, char *const argv[], int &narg, + const char *option, intptr_t &value, + const intptr_t minval, const intptr_t maxval, + const intptr_t default_value = -1) { + static_assert(sizeof(intptr_t) == 4 || sizeof(intptr_t) == 8, "WTF?"); + if (sizeof(intptr_t) == 8) + return parse_option(argc, argv, narg, option, + *reinterpret_cast(&value), int64_t(minval), + int64_t(maxval), int64_t(default_value)); + else + return parse_option(argc, argv, narg, option, + *reinterpret_cast(&value), int32_t(minval), + int32_t(maxval), int32_t(default_value)); +} + //----------------------------------------------------------------------------- #pragma pack(push, 1) diff --git a/test/main.cc b/test/main.cc index 69ce6973..959359a5 100644 --- a/test/main.cc +++ b/test/main.cc @@ -182,17 +182,19 @@ int main(int argc, char *const argv[]) { params.datalen_max = datalen_max; continue; } - if (config::parse_option(argc, argv, narg, "size-lower", params.size_lower, - mdbx_limits_dbsize_min(params.pagesize), - mdbx_limits_dbsize_max(params.pagesize))) + if (config::parse_option_intptr(argc, argv, narg, "size-lower", + params.size_lower, + mdbx_limits_dbsize_min(params.pagesize), + mdbx_limits_dbsize_max(params.pagesize))) continue; - if (config::parse_option(argc, argv, narg, "size-upper", params.size_upper, - mdbx_limits_dbsize_min(params.pagesize), - mdbx_limits_dbsize_max(params.pagesize))) + if (config::parse_option_intptr(argc, argv, narg, "size-upper", + params.size_upper, + mdbx_limits_dbsize_min(params.pagesize), + mdbx_limits_dbsize_max(params.pagesize))) continue; - if (config::parse_option(argc, argv, narg, "size", params.size_now, - mdbx_limits_dbsize_min(params.pagesize), - mdbx_limits_dbsize_max(params.pagesize))) + if (config::parse_option_intptr(argc, argv, narg, "size", params.size_now, + mdbx_limits_dbsize_min(params.pagesize), + mdbx_limits_dbsize_max(params.pagesize))) continue; if (config::parse_option( argc, argv, narg, "shrink-threshold", params.shrink_threshold, 0, diff --git a/test/osal-unix.cc b/test/osal-unix.cc index 95e2ab3e..0157bace 100644 --- a/test/osal-unix.cc +++ b/test/osal-unix.cc @@ -21,6 +21,10 @@ #include #include +#ifdef __APPLE__ +#include "darwin/pthread_barrier.c" +#endif + struct shared_t { pthread_barrier_t barrier; pthread_mutex_t mutex; diff --git a/test/utils.cc b/test/utils.cc index 18f6c6ab..d9b3538b 100644 --- a/test/utils.cc +++ b/test/utils.cc @@ -17,6 +17,9 @@ #if defined(HAVE_IEEE754_H) || __has_include() #include #endif +#if defined(__APPLE__) || defined(__MACH__) +#include +#endif /* defined(__APPLE__) || defined(__MACH__) */ std::string format(const char *fmt, ...) { va_list ap, ones; diff --git a/test/utils.h b/test/utils.h index 520506ea..d1b859ac 100644 --- a/test/utils.h +++ b/test/utils.h @@ -247,18 +247,20 @@ struct simple_checksum { simple_checksum() : value(0) {} - void push(uint32_t data) { + void push(const uint32_t &data) { value += data * UINT64_C(9386433910765580089) + 1; value ^= value >> 41; value *= UINT64_C(0xBD9CACC22C6E9571); } - void push(uint64_t data) { + void push(const uint64_t &data) { push((uint32_t)data); push((uint32_t)(data >> 32)); } - void push(bool data) { push(data ? UINT32_C(0x780E) : UINT32_C(0xFA18E)); } + void push(const bool data) { + push(data ? UINT32_C(0x780E) : UINT32_C(0xFA18E)); + } void push(const void *ptr, size_t bytes) { const uint8_t *data = (const uint8_t *)ptr; @@ -271,7 +273,7 @@ struct simple_checksum { void push(const std::string &str) { push(str.data(), str.size()); } void push(unsigned salt, const MDBX_val &val) { - push(val.iov_len); + push(unsigned(val.iov_len)); push(salt); push(val.iov_base, val.iov_len); }