mdbx: fix minor warnings from modern Apple's CLANG.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2022-05-15 23:42:57 +03:00
parent cb14ea9e67
commit 21e1dc3248
7 changed files with 23 additions and 17 deletions

View File

@ -6005,7 +6005,10 @@ __cold static int mdbx_set_readahead(MDBX_env *env, const pgno_t edge,
#if defined(F_RDADVISE)
struct radvisory hint;
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(
env->me_lazy_fd, F_RDADVISE, &hint);
#elif defined(MADV_WILLNEED)
@ -16911,7 +16914,7 @@ static int mdbx_update_key(MDBX_cursor *mc, const MDBX_val *key) {
MDBX_node *node;
char *base;
size_t len;
int delta, ksize, oksize;
ptrdiff_t delta, ksize, oksize;
int ptr, i, nkeys, indx;
DKBUF_DEBUG;
@ -16937,7 +16940,7 @@ static int mdbx_update_key(MDBX_cursor *mc, const MDBX_val *key) {
if (delta) {
if (delta > (int)page_room(mp)) {
/* 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);
mdbx_node_del(mc, 0);
int rc = mdbx_page_split(mc, key, NULL, pgno, MDBX_SPLIT_REPLACE);

View File

@ -1417,7 +1417,7 @@ MDBX_INTERNAL_FUNC void mdbx_rthc_thread_dtor(void *ptr);
#define F_ISSET(w, f) (((w) & (f)) == (f))
/* 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.
* This is certainly too small for any actual applications. Apps should

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);