Add JEMALLOC_CC_SILENCE_INIT().

Add JEMALLOC_CC_SILENCE_INIT(), which provides succinct syntax for
initializing a variable to avoid a spurious compiler warning.
This commit is contained in:
Jason Evans
2012-03-23 15:39:07 -07:00
parent cd9a1346e9
commit 9225a1991a
4 changed files with 23 additions and 44 deletions

View File

@@ -611,11 +611,7 @@ ipalloc(size_t usize, size_t alignment, bool zero)
if (usize <= arena_maxclass && alignment <= PAGE_SIZE)
ret = arena_malloc(usize, zero);
else {
size_t run_size
#ifdef JEMALLOC_CC_SILENCE
= 0
#endif
;
size_t run_size JEMALLOC_CC_SILENCE_INIT(0);
/*
* Ideally we would only ever call sa2u() once per aligned

View File

@@ -16,6 +16,17 @@
*/
#define JEMALLOC_CONCAT(...) __VA_ARGS__
/*
* Silence compiler warnings due to uninitialized values. This is used
* wherever the compiler fails to recognize that the variable is never used
* uninitialized.
*/
#ifdef JEMALLOC_CC_SILENCE
# define JEMALLOC_CC_SILENCE_INIT(v) = v
#else
# define JEMALLOC_CC_SILENCE_INIT(v)
#endif
/*
* Define a custom assert() in order to reduce the chances of deadlock during
* assertion failure.