Silence miscellaneous 64-to-32-bit data loss warnings.

This resolves #341.
This commit is contained in:
Jason Evans 2016-02-25 20:51:00 -08:00
parent 8282a2ad97
commit 42ce80e15a
4 changed files with 14 additions and 15 deletions

View File

@ -634,7 +634,7 @@ bool arena_prof_accum_locked(arena_t *arena, uint64_t accumbytes);
bool arena_prof_accum(arena_t *arena, uint64_t accumbytes); bool arena_prof_accum(arena_t *arena, uint64_t accumbytes);
szind_t arena_ptr_small_binind_get(const void *ptr, size_t mapbits); szind_t arena_ptr_small_binind_get(const void *ptr, size_t mapbits);
szind_t arena_bin_index(arena_t *arena, arena_bin_t *bin); szind_t arena_bin_index(arena_t *arena, arena_bin_t *bin);
unsigned arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, size_t arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info,
const void *ptr); const void *ptr);
prof_tctx_t *arena_prof_tctx_get(const void *ptr); prof_tctx_t *arena_prof_tctx_get(const void *ptr);
void arena_prof_tctx_set(const void *ptr, size_t usize, prof_tctx_t *tctx); void arena_prof_tctx_set(const void *ptr, size_t usize, prof_tctx_t *tctx);
@ -1076,11 +1076,10 @@ arena_bin_index(arena_t *arena, arena_bin_t *bin)
return (binind); return (binind);
} }
JEMALLOC_INLINE unsigned JEMALLOC_INLINE size_t
arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr) arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr)
{ {
unsigned shift, diff, regind; size_t diff, interval, shift, regind;
size_t interval;
arena_chunk_map_misc_t *miscelm = arena_run_to_miscelm(run); arena_chunk_map_misc_t *miscelm = arena_run_to_miscelm(run);
void *rpages = arena_miscelm_to_rpages(miscelm); void *rpages = arena_miscelm_to_rpages(miscelm);
@ -1095,7 +1094,7 @@ arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr)
* Avoid doing division with a variable divisor if possible. Using * Avoid doing division with a variable divisor if possible. Using
* actual division here can reduce allocator throughput by over 20%! * actual division here can reduce allocator throughput by over 20%!
*/ */
diff = (unsigned)((uintptr_t)ptr - (uintptr_t)rpages - diff = (size_t)((uintptr_t)ptr - (uintptr_t)rpages -
bin_info->reg0_offset); bin_info->reg0_offset);
/* Rescale (factor powers of 2 out of the numerator and denominator). */ /* Rescale (factor powers of 2 out of the numerator and denominator). */
@ -1122,9 +1121,9 @@ arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr)
* divide by 0, and 1 and 2 are both powers of two, which are * divide by 0, and 1 and 2 are both powers of two, which are
* handled above. * handled above.
*/ */
#define SIZE_INV_SHIFT ((sizeof(unsigned) << 3) - LG_RUN_MAXREGS) #define SIZE_INV_SHIFT ((sizeof(size_t) << 3) - LG_RUN_MAXREGS)
#define SIZE_INV(s) (((1U << SIZE_INV_SHIFT) / (s)) + 1) #define SIZE_INV(s) (((ZU(1) << SIZE_INV_SHIFT) / (s)) + 1)
static const unsigned interval_invs[] = { static const size_t interval_invs[] = {
SIZE_INV(3), SIZE_INV(3),
SIZE_INV(4), SIZE_INV(5), SIZE_INV(6), SIZE_INV(7), SIZE_INV(4), SIZE_INV(5), SIZE_INV(6), SIZE_INV(7),
SIZE_INV(8), SIZE_INV(9), SIZE_INV(10), SIZE_INV(11), SIZE_INV(8), SIZE_INV(9), SIZE_INV(10), SIZE_INV(11),
@ -1135,8 +1134,8 @@ arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr)
SIZE_INV(28), SIZE_INV(29), SIZE_INV(30), SIZE_INV(31) SIZE_INV(28), SIZE_INV(29), SIZE_INV(30), SIZE_INV(31)
}; };
if (likely(interval <= ((sizeof(interval_invs) / if (likely(interval <= ((sizeof(interval_invs) / sizeof(size_t))
sizeof(unsigned)) + 2))) { + 2))) {
regind = (diff * interval_invs[interval - 3]) >> regind = (diff * interval_invs[interval - 3]) >>
SIZE_INV_SHIFT; SIZE_INV_SHIFT;
} else } else

View File

@ -301,7 +301,7 @@ JEMALLOC_INLINE_C void *
arena_run_reg_alloc(arena_run_t *run, arena_bin_info_t *bin_info) arena_run_reg_alloc(arena_run_t *run, arena_bin_info_t *bin_info)
{ {
void *ret; void *ret;
unsigned regind; size_t regind;
arena_chunk_map_misc_t *miscelm; arena_chunk_map_misc_t *miscelm;
void *rpages; void *rpages;
@ -325,7 +325,7 @@ arena_run_reg_dalloc(arena_run_t *run, void *ptr)
size_t mapbits = arena_mapbits_get(chunk, pageind); size_t mapbits = arena_mapbits_get(chunk, pageind);
szind_t binind = arena_ptr_small_binind_get(ptr, mapbits); szind_t binind = arena_ptr_small_binind_get(ptr, mapbits);
arena_bin_info_t *bin_info = &arena_bin_info[binind]; arena_bin_info_t *bin_info = &arena_bin_info[binind];
unsigned regind = arena_run_regind(run, bin_info, ptr); size_t regind = arena_run_regind(run, bin_info, ptr);
assert(run->nfree < bin_info->nregs); assert(run->nfree < bin_info->nregs);
/* Freeing an interior pointer can cause assertion failure. */ /* Freeing an interior pointer can cause assertion failure. */

View File

@ -109,7 +109,7 @@ static char prof_dump_buf[
1 1
#endif #endif
]; ];
static unsigned prof_dump_buf_end; static size_t prof_dump_buf_end;
static int prof_dump_fd; static int prof_dump_fd;
/* Do not dump any profiles until bootstrapping is complete. */ /* Do not dump any profiles until bootstrapping is complete. */

View File

@ -60,7 +60,7 @@ wrtmessage(void *cbopaque, const char *s)
*/ */
UNUSED long result = syscall(SYS_write, STDERR_FILENO, s, strlen(s)); UNUSED long result = syscall(SYS_write, STDERR_FILENO, s, strlen(s));
#else #else
UNUSED int result = write(STDERR_FILENO, s, strlen(s)); UNUSED ssize_t result = write(STDERR_FILENO, s, strlen(s));
#endif #endif
} }
@ -90,7 +90,7 @@ buferror(int err, char *buf, size_t buflen)
#ifdef _WIN32 #ifdef _WIN32
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0,
(LPSTR)buf, buflen, NULL); (LPSTR)buf, (DWORD)buflen, NULL);
return (0); return (0);
#elif defined(__GLIBC__) && defined(_GNU_SOURCE) #elif defined(__GLIBC__) && defined(_GNU_SOURCE)
char *b = strerror_r(err, buf, buflen); char *b = strerror_r(err, buf, buflen);