mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 19:34:15 +08:00
mdbx: fix minor warnings from modern Apple's CLANG.
This commit is contained in:
parent
cb14ea9e67
commit
21e1dc3248
@ -6005,7 +6005,10 @@ __cold static int mdbx_set_readahead(MDBX_env *env, const pgno_t edge,
|
|||||||
#if defined(F_RDADVISE)
|
#if defined(F_RDADVISE)
|
||||||
struct radvisory hint;
|
struct radvisory hint;
|
||||||
hint.ra_offset = offset;
|
hint.ra_offset = offset;
|
||||||
hint.ra_count = length;
|
hint.ra_count =
|
||||||
|
unlikely(length > INT_MAX && sizeof(length) > sizeof(hint.ra_count))
|
||||||
|
? INT_MAX
|
||||||
|
: (int)length;
|
||||||
(void)/* Ignore ENOTTY for DB on the ram-disk and so on */ fcntl(
|
(void)/* Ignore ENOTTY for DB on the ram-disk and so on */ fcntl(
|
||||||
env->me_lazy_fd, F_RDADVISE, &hint);
|
env->me_lazy_fd, F_RDADVISE, &hint);
|
||||||
#elif defined(MADV_WILLNEED)
|
#elif defined(MADV_WILLNEED)
|
||||||
@ -16911,7 +16914,7 @@ static int mdbx_update_key(MDBX_cursor *mc, const MDBX_val *key) {
|
|||||||
MDBX_node *node;
|
MDBX_node *node;
|
||||||
char *base;
|
char *base;
|
||||||
size_t len;
|
size_t len;
|
||||||
int delta, ksize, oksize;
|
ptrdiff_t delta, ksize, oksize;
|
||||||
int ptr, i, nkeys, indx;
|
int ptr, i, nkeys, indx;
|
||||||
DKBUF_DEBUG;
|
DKBUF_DEBUG;
|
||||||
|
|
||||||
@ -16937,7 +16940,7 @@ static int mdbx_update_key(MDBX_cursor *mc, const MDBX_val *key) {
|
|||||||
if (delta) {
|
if (delta) {
|
||||||
if (delta > (int)page_room(mp)) {
|
if (delta > (int)page_room(mp)) {
|
||||||
/* not enough space left, do a delete and split */
|
/* not enough space left, do a delete and split */
|
||||||
mdbx_debug("Not enough room, delta = %d, splitting...", delta);
|
mdbx_debug("Not enough room, delta = %zd, splitting...", delta);
|
||||||
pgno_t pgno = node_pgno(node);
|
pgno_t pgno = node_pgno(node);
|
||||||
mdbx_node_del(mc, 0);
|
mdbx_node_del(mc, 0);
|
||||||
int rc = mdbx_page_split(mc, key, NULL, pgno, MDBX_SPLIT_REPLACE);
|
int rc = mdbx_page_split(mc, key, NULL, pgno, MDBX_SPLIT_REPLACE);
|
||||||
|
@ -1417,7 +1417,7 @@ MDBX_INTERNAL_FUNC void mdbx_rthc_thread_dtor(void *ptr);
|
|||||||
#define F_ISSET(w, f) (((w) & (f)) == (f))
|
#define F_ISSET(w, f) (((w) & (f)) == (f))
|
||||||
|
|
||||||
/* Round n up to an even number. */
|
/* Round n up to an even number. */
|
||||||
#define EVEN(n) (((n) + 1U) & -2) /* sign-extending -2 to match n+1U */
|
#define EVEN(n) (((n) + 1UL) & -2L) /* sign-extending -2 to match n+1U */
|
||||||
|
|
||||||
/* Default size of memory map.
|
/* Default size of memory map.
|
||||||
* This is certainly too small for any actual applications. Apps should
|
* This is certainly too small for any actual applications. Apps should
|
||||||
|
@ -184,7 +184,8 @@ void osal_setup(const std::vector<actor_config> &actors) {
|
|||||||
if (err)
|
if (err)
|
||||||
failure_perror("pthread_barrierattr_setpshared()", 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)
|
if (err)
|
||||||
failure_perror("pthread_barrier_init(shared)", err);
|
failure_perror("pthread_barrier_init(shared)", err);
|
||||||
pthread_barrierattr_destroy(&barrierattr);
|
pthread_barrierattr_destroy(&barrierattr);
|
||||||
@ -589,12 +590,12 @@ void osal_yield(void) {
|
|||||||
failure_perror("sched_yield()", errno);
|
failure_perror("sched_yield()", errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
void osal_udelay(unsigned us) {
|
void osal_udelay(size_t us) {
|
||||||
chrono::time until, now = chrono::now_monotonic();
|
chrono::time until, now = chrono::now_monotonic();
|
||||||
until.fixedpoint = now.fixedpoint + chrono::from_us(us).fixedpoint;
|
until.fixedpoint = now.fixedpoint + chrono::from_us(us).fixedpoint;
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
static unsigned threshold_us;
|
static size_t threshold_us;
|
||||||
if (threshold_us == 0) {
|
if (threshold_us == 0) {
|
||||||
#if defined(_POSIX_CPUTIME) && _POSIX_CPUTIME > -1 && \
|
#if defined(_POSIX_CPUTIME) && _POSIX_CPUTIME > -1 && \
|
||||||
defined(CLOCK_PROCESS_CPUTIME_ID)
|
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_yield(void) { SwitchToThread(); }
|
||||||
|
|
||||||
void osal_udelay(unsigned us) {
|
void osal_udelay(size_t us) {
|
||||||
chrono::time until, now = chrono::now_monotonic();
|
chrono::time until, now = chrono::now_monotonic();
|
||||||
until.fixedpoint = now.fixedpoint + chrono::from_us(us).fixedpoint;
|
until.fixedpoint = now.fixedpoint + chrono::from_us(us).fixedpoint;
|
||||||
|
|
||||||
static unsigned threshold_us;
|
static size_t threshold_us;
|
||||||
if (threshold_us == 0) {
|
if (threshold_us == 0) {
|
||||||
unsigned timeslice_ms = 1;
|
unsigned timeslice_ms = 1;
|
||||||
while (timeBeginPeriod(timeslice_ms) == TIMERR_NOCANDO)
|
while (timeBeginPeriod(timeslice_ms) == TIMERR_NOCANDO)
|
||||||
@ -433,7 +433,7 @@ void osal_udelay(unsigned us) {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
if (us > threshold_us && us > 1000) {
|
if (us > threshold_us && us > 1000) {
|
||||||
DWORD rc = SleepEx(us / 1000, TRUE);
|
DWORD rc = SleepEx(unsigned(us / 1000), TRUE);
|
||||||
if (rc)
|
if (rc)
|
||||||
failure_perror("SleepEx()", waitstatus2errcode(rc));
|
failure_perror("SleepEx()", waitstatus2errcode(rc));
|
||||||
us = 0;
|
us = 0;
|
||||||
|
@ -30,7 +30,7 @@ bool osal_progress_push(bool active);
|
|||||||
|
|
||||||
mdbx_pid_t osal_getpid(void);
|
mdbx_pid_t osal_getpid(void);
|
||||||
int osal_delay(unsigned seconds);
|
int osal_delay(unsigned seconds);
|
||||||
void osal_udelay(unsigned us);
|
void osal_udelay(size_t us);
|
||||||
void osal_yield(void);
|
void osal_yield(void);
|
||||||
bool osal_istty(int fd);
|
bool osal_istty(int fd);
|
||||||
std::string osal_tempdir(void);
|
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) {
|
unsigned testcase_ttl::edge2count(uint64_t edge) {
|
||||||
const double rnd = u64_to_double1(prng64_map1_white(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
|
// average value: (X - 1) / ln(X), where X = sliding.max_step_size
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned testcase_ttl::edge2window(uint64_t edge) {
|
unsigned testcase_ttl::edge2window(uint64_t edge) {
|
||||||
const double rnd = u64_to_double1(bleach64(edge));
|
const double rnd = u64_to_double1(bleach64(edge));
|
||||||
const unsigned size = sliding.max_window_size -
|
const unsigned size =
|
||||||
std::lrint(std::pow(sliding.max_window_size, rnd));
|
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
|
// average value: Y - (Y - 1) / ln(Y), where Y = sliding.max_window_size
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@ -84,10 +86,10 @@ bool testcase_ttl::setup() {
|
|||||||
x = (hi + lo) / 2;
|
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)
|
if (sliding.max_step_size < count_top_lower)
|
||||||
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)
|
if (sliding.max_window_size < window_top_lower)
|
||||||
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();
|
osal_yield();
|
||||||
cpu_relax();
|
cpu_relax();
|
||||||
if (dice > 2) {
|
if (dice > 2) {
|
||||||
unsigned us =
|
size_t us =
|
||||||
prng32() & (extra ? 0xffff /* 656 ms */ : 0x3ff /* 1 ms */);
|
prng32() & (extra ? 0xffff /* 656 ms */ : 0x3ff /* 1 ms */);
|
||||||
log_trace("== jitter.delay: %0.6f", us / 1000000.0);
|
log_trace("== jitter.delay: %0.6f", us / 1000000.0);
|
||||||
osal_udelay(us);
|
osal_udelay(us);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user