mirror of
https://github.com/isar/libmdbx.git
synced 2025-08-19 19:39:26 +08:00
mdbx: fix minor warnings from modern Apple's CLANG.
This commit is contained in:
@@ -184,7 +184,8 @@ void osal_setup(const std::vector<actor_config> &actors) {
|
||||
if (err)
|
||||
failure_perror("pthread_barrierattr_setpshared()", err);
|
||||
|
||||
err = pthread_barrier_init(&shared->barrier, &barrierattr, shared->count);
|
||||
err = pthread_barrier_init(&shared->barrier, &barrierattr,
|
||||
unsigned(shared->count));
|
||||
if (err)
|
||||
failure_perror("pthread_barrier_init(shared)", err);
|
||||
pthread_barrierattr_destroy(&barrierattr);
|
||||
@@ -589,12 +590,12 @@ void osal_yield(void) {
|
||||
failure_perror("sched_yield()", errno);
|
||||
}
|
||||
|
||||
void osal_udelay(unsigned us) {
|
||||
void osal_udelay(size_t us) {
|
||||
chrono::time until, now = chrono::now_monotonic();
|
||||
until.fixedpoint = now.fixedpoint + chrono::from_us(us).fixedpoint;
|
||||
struct timespec ts;
|
||||
|
||||
static unsigned threshold_us;
|
||||
static size_t threshold_us;
|
||||
if (threshold_us == 0) {
|
||||
#if defined(_POSIX_CPUTIME) && _POSIX_CPUTIME > -1 && \
|
||||
defined(CLOCK_PROCESS_CPUTIME_ID)
|
||||
|
@@ -418,11 +418,11 @@ int osal_actor_poll(mdbx_pid_t &pid, unsigned timeout) {
|
||||
|
||||
void osal_yield(void) { SwitchToThread(); }
|
||||
|
||||
void osal_udelay(unsigned us) {
|
||||
void osal_udelay(size_t us) {
|
||||
chrono::time until, now = chrono::now_monotonic();
|
||||
until.fixedpoint = now.fixedpoint + chrono::from_us(us).fixedpoint;
|
||||
|
||||
static unsigned threshold_us;
|
||||
static size_t threshold_us;
|
||||
if (threshold_us == 0) {
|
||||
unsigned timeslice_ms = 1;
|
||||
while (timeBeginPeriod(timeslice_ms) == TIMERR_NOCANDO)
|
||||
@@ -433,7 +433,7 @@ void osal_udelay(unsigned us) {
|
||||
|
||||
do {
|
||||
if (us > threshold_us && us > 1000) {
|
||||
DWORD rc = SleepEx(us / 1000, TRUE);
|
||||
DWORD rc = SleepEx(unsigned(us / 1000), TRUE);
|
||||
if (rc)
|
||||
failure_perror("SleepEx()", waitstatus2errcode(rc));
|
||||
us = 0;
|
||||
|
@@ -30,7 +30,7 @@ bool osal_progress_push(bool active);
|
||||
|
||||
mdbx_pid_t osal_getpid(void);
|
||||
int osal_delay(unsigned seconds);
|
||||
void osal_udelay(unsigned us);
|
||||
void osal_udelay(size_t us);
|
||||
void osal_yield(void);
|
||||
bool osal_istty(int fd);
|
||||
std::string osal_tempdir(void);
|
||||
|
12
test/ttl.cc
12
test/ttl.cc
@@ -35,15 +35,17 @@ REGISTER_TESTCASE(ttl);
|
||||
|
||||
unsigned testcase_ttl::edge2count(uint64_t edge) {
|
||||
const double rnd = u64_to_double1(prng64_map1_white(edge));
|
||||
const unsigned count = std::lrint(std::pow(sliding.max_step_size, rnd));
|
||||
const unsigned count =
|
||||
unsigned(std::lrint(std::pow(sliding.max_step_size, rnd)));
|
||||
// average value: (X - 1) / ln(X), where X = sliding.max_step_size
|
||||
return count;
|
||||
}
|
||||
|
||||
unsigned testcase_ttl::edge2window(uint64_t edge) {
|
||||
const double rnd = u64_to_double1(bleach64(edge));
|
||||
const unsigned size = sliding.max_window_size -
|
||||
std::lrint(std::pow(sliding.max_window_size, rnd));
|
||||
const unsigned size =
|
||||
sliding.max_window_size -
|
||||
unsigned(std::lrint(std::pow(sliding.max_window_size, rnd)));
|
||||
// average value: Y - (Y - 1) / ln(Y), where Y = sliding.max_window_size
|
||||
return size;
|
||||
}
|
||||
@@ -84,10 +86,10 @@ bool testcase_ttl::setup() {
|
||||
x = (hi + lo) / 2;
|
||||
}
|
||||
|
||||
sliding.max_step_size = std::lrint(x);
|
||||
sliding.max_step_size = unsigned(std::lrint(x));
|
||||
if (sliding.max_step_size < count_top_lower)
|
||||
sliding.max_step_size = count_top_lower;
|
||||
sliding.max_window_size = std::lrint(x * ratio);
|
||||
sliding.max_window_size = unsigned(std::lrint(x * ratio));
|
||||
if (sliding.max_window_size < window_top_lower)
|
||||
sliding.max_window_size = window_top_lower;
|
||||
|
||||
|
@@ -207,7 +207,7 @@ void jitter_delay(bool extra) {
|
||||
osal_yield();
|
||||
cpu_relax();
|
||||
if (dice > 2) {
|
||||
unsigned us =
|
||||
size_t us =
|
||||
prng32() & (extra ? 0xffff /* 656 ms */ : 0x3ff /* 1 ms */);
|
||||
log_trace("== jitter.delay: %0.6f", us / 1000000.0);
|
||||
osal_udelay(us);
|
||||
|
Reference in New Issue
Block a user