mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx-test: initial OSX support.
This commit is contained in:
parent
054a88c502
commit
3f64d45819
@ -39,6 +39,10 @@
|
|||||||
#include <SDKDDKVer.h>
|
#include <SDKDDKVer.h>
|
||||||
#endif /* WINDOWS */
|
#endif /* WINDOWS */
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define _DARWIN_C_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.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,
|
bool parse_option(int argc, char *const argv[], int &narg, const char *option,
|
||||||
int32_t &value, const int32_t minval, const int32_t maxval,
|
int32_t &value, const int32_t minval, const int32_t maxval,
|
||||||
const int32_t default_value = -1);
|
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<int64_t *>(&value), int64_t(minval),
|
||||||
|
int64_t(maxval), int64_t(default_value));
|
||||||
|
else
|
||||||
|
return parse_option(argc, argv, narg, option,
|
||||||
|
*reinterpret_cast<int32_t *>(&value), int32_t(minval),
|
||||||
|
int32_t(maxval), int32_t(default_value));
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
@ -182,15 +182,17 @@ int main(int argc, char *const argv[]) {
|
|||||||
params.datalen_max = datalen_max;
|
params.datalen_max = datalen_max;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (config::parse_option(argc, argv, narg, "size-lower", params.size_lower,
|
if (config::parse_option_intptr(argc, argv, narg, "size-lower",
|
||||||
|
params.size_lower,
|
||||||
mdbx_limits_dbsize_min(params.pagesize),
|
mdbx_limits_dbsize_min(params.pagesize),
|
||||||
mdbx_limits_dbsize_max(params.pagesize)))
|
mdbx_limits_dbsize_max(params.pagesize)))
|
||||||
continue;
|
continue;
|
||||||
if (config::parse_option(argc, argv, narg, "size-upper", params.size_upper,
|
if (config::parse_option_intptr(argc, argv, narg, "size-upper",
|
||||||
|
params.size_upper,
|
||||||
mdbx_limits_dbsize_min(params.pagesize),
|
mdbx_limits_dbsize_min(params.pagesize),
|
||||||
mdbx_limits_dbsize_max(params.pagesize)))
|
mdbx_limits_dbsize_max(params.pagesize)))
|
||||||
continue;
|
continue;
|
||||||
if (config::parse_option(argc, argv, narg, "size", params.size_now,
|
if (config::parse_option_intptr(argc, argv, narg, "size", params.size_now,
|
||||||
mdbx_limits_dbsize_min(params.pagesize),
|
mdbx_limits_dbsize_min(params.pagesize),
|
||||||
mdbx_limits_dbsize_max(params.pagesize)))
|
mdbx_limits_dbsize_max(params.pagesize)))
|
||||||
continue;
|
continue;
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include "darwin/pthread_barrier.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
struct shared_t {
|
struct shared_t {
|
||||||
pthread_barrier_t barrier;
|
pthread_barrier_t barrier;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
#if defined(HAVE_IEEE754_H) || __has_include(<ieee754.h>)
|
#if defined(HAVE_IEEE754_H) || __has_include(<ieee754.h>)
|
||||||
#include <ieee754.h>
|
#include <ieee754.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__APPLE__) || defined(__MACH__)
|
||||||
|
#include <mach/mach_time.h>
|
||||||
|
#endif /* defined(__APPLE__) || defined(__MACH__) */
|
||||||
|
|
||||||
std::string format(const char *fmt, ...) {
|
std::string format(const char *fmt, ...) {
|
||||||
va_list ap, ones;
|
va_list ap, ones;
|
||||||
|
10
test/utils.h
10
test/utils.h
@ -247,18 +247,20 @@ struct simple_checksum {
|
|||||||
|
|
||||||
simple_checksum() : value(0) {}
|
simple_checksum() : value(0) {}
|
||||||
|
|
||||||
void push(uint32_t data) {
|
void push(const uint32_t &data) {
|
||||||
value += data * UINT64_C(9386433910765580089) + 1;
|
value += data * UINT64_C(9386433910765580089) + 1;
|
||||||
value ^= value >> 41;
|
value ^= value >> 41;
|
||||||
value *= UINT64_C(0xBD9CACC22C6E9571);
|
value *= UINT64_C(0xBD9CACC22C6E9571);
|
||||||
}
|
}
|
||||||
|
|
||||||
void push(uint64_t data) {
|
void push(const uint64_t &data) {
|
||||||
push((uint32_t)data);
|
push((uint32_t)data);
|
||||||
push((uint32_t)(data >> 32));
|
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) {
|
void push(const void *ptr, size_t bytes) {
|
||||||
const uint8_t *data = (const uint8_t *)ptr;
|
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(const std::string &str) { push(str.data(), str.size()); }
|
||||||
|
|
||||||
void push(unsigned salt, const MDBX_val &val) {
|
void push(unsigned salt, const MDBX_val &val) {
|
||||||
push(val.iov_len);
|
push(unsigned(val.iov_len));
|
||||||
push(salt);
|
push(salt);
|
||||||
push(val.iov_base, val.iov_len);
|
push(val.iov_base, val.iov_len);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user