Tweak code to allow compilation of concatenated src/*.c sources.
This resolves #294.
This commit is contained in:
parent
a6ec1c869e
commit
f9e3459f75
45
include/jemalloc/internal/assert.h
Normal file
45
include/jemalloc/internal/assert.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Define a custom assert() in order to reduce the chances of deadlock during
|
||||||
|
* assertion failure.
|
||||||
|
*/
|
||||||
|
#ifndef assert
|
||||||
|
#define assert(e) do { \
|
||||||
|
if (unlikely(config_debug && !(e))) { \
|
||||||
|
malloc_printf( \
|
||||||
|
"<jemalloc>: %s:%d: Failed assertion: \"%s\"\n", \
|
||||||
|
__FILE__, __LINE__, #e); \
|
||||||
|
abort(); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef not_reached
|
||||||
|
#define not_reached() do { \
|
||||||
|
if (config_debug) { \
|
||||||
|
malloc_printf( \
|
||||||
|
"<jemalloc>: %s:%d: Unreachable code reached\n", \
|
||||||
|
__FILE__, __LINE__); \
|
||||||
|
abort(); \
|
||||||
|
} \
|
||||||
|
unreachable(); \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef not_implemented
|
||||||
|
#define not_implemented() do { \
|
||||||
|
if (config_debug) { \
|
||||||
|
malloc_printf("<jemalloc>: %s:%d: Not implemented\n", \
|
||||||
|
__FILE__, __LINE__); \
|
||||||
|
abort(); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef assert_not_implemented
|
||||||
|
#define assert_not_implemented(e) do { \
|
||||||
|
if (unlikely(config_debug && !(e))) \
|
||||||
|
not_implemented(); \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -81,49 +81,7 @@
|
|||||||
# define unreachable()
|
# define unreachable()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
#include "jemalloc/internal/assert.h"
|
||||||
* Define a custom assert() in order to reduce the chances of deadlock during
|
|
||||||
* assertion failure.
|
|
||||||
*/
|
|
||||||
#ifndef assert
|
|
||||||
#define assert(e) do { \
|
|
||||||
if (unlikely(config_debug && !(e))) { \
|
|
||||||
malloc_printf( \
|
|
||||||
"<jemalloc>: %s:%d: Failed assertion: \"%s\"\n", \
|
|
||||||
__FILE__, __LINE__, #e); \
|
|
||||||
abort(); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef not_reached
|
|
||||||
#define not_reached() do { \
|
|
||||||
if (config_debug) { \
|
|
||||||
malloc_printf( \
|
|
||||||
"<jemalloc>: %s:%d: Unreachable code reached\n", \
|
|
||||||
__FILE__, __LINE__); \
|
|
||||||
abort(); \
|
|
||||||
} \
|
|
||||||
unreachable(); \
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef not_implemented
|
|
||||||
#define not_implemented() do { \
|
|
||||||
if (config_debug) { \
|
|
||||||
malloc_printf("<jemalloc>: %s:%d: Not implemented\n", \
|
|
||||||
__FILE__, __LINE__); \
|
|
||||||
abort(); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef assert_not_implemented
|
|
||||||
#define assert_not_implemented(e) do { \
|
|
||||||
if (unlikely(config_debug && !(e))) \
|
|
||||||
not_implemented(); \
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Use to assert a particular configuration, e.g., cassert(config_debug). */
|
/* Use to assert a particular configuration, e.g., cassert(config_debug). */
|
||||||
#define cassert(c) do { \
|
#define cassert(c) do { \
|
||||||
|
@ -115,7 +115,7 @@ CTL_PROTO(tcache_create)
|
|||||||
CTL_PROTO(tcache_flush)
|
CTL_PROTO(tcache_flush)
|
||||||
CTL_PROTO(tcache_destroy)
|
CTL_PROTO(tcache_destroy)
|
||||||
CTL_PROTO(arena_i_purge)
|
CTL_PROTO(arena_i_purge)
|
||||||
static void arena_purge(unsigned arena_ind);
|
static void arena_i_purge(unsigned arena_ind);
|
||||||
CTL_PROTO(arena_i_dss)
|
CTL_PROTO(arena_i_dss)
|
||||||
CTL_PROTO(arena_i_lg_dirty_mult)
|
CTL_PROTO(arena_i_lg_dirty_mult)
|
||||||
CTL_PROTO(arena_i_chunk_hooks)
|
CTL_PROTO(arena_i_chunk_hooks)
|
||||||
@ -1538,7 +1538,7 @@ label_return:
|
|||||||
|
|
||||||
/* ctl_mutex must be held during execution of this function. */
|
/* ctl_mutex must be held during execution of this function. */
|
||||||
static void
|
static void
|
||||||
arena_purge(unsigned arena_ind)
|
arena_i_purge(unsigned arena_ind)
|
||||||
{
|
{
|
||||||
tsd_t *tsd;
|
tsd_t *tsd;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@ -1576,7 +1576,7 @@ arena_i_purge_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
|
|||||||
READONLY();
|
READONLY();
|
||||||
WRITEONLY();
|
WRITEONLY();
|
||||||
malloc_mutex_lock(&ctl_mtx);
|
malloc_mutex_lock(&ctl_mtx);
|
||||||
arena_purge(mib[1]);
|
arena_i_purge(mib[1]);
|
||||||
malloc_mutex_unlock(&ctl_mtx);
|
malloc_mutex_unlock(&ctl_mtx);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
13
src/util.c
13
src/util.c
@ -1,3 +1,7 @@
|
|||||||
|
/*
|
||||||
|
* Define simple versions of assertion macros that won't recurse in case
|
||||||
|
* of assertion failures in malloc_*printf().
|
||||||
|
*/
|
||||||
#define assert(e) do { \
|
#define assert(e) do { \
|
||||||
if (config_debug && !(e)) { \
|
if (config_debug && !(e)) { \
|
||||||
malloc_write("<jemalloc>: Failed assertion\n"); \
|
malloc_write("<jemalloc>: Failed assertion\n"); \
|
||||||
@ -648,3 +652,12 @@ malloc_printf(const char *format, ...)
|
|||||||
malloc_vcprintf(NULL, NULL, format, ap);
|
malloc_vcprintf(NULL, NULL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Restore normal assertion macros, in order to make it possible to compile all
|
||||||
|
* C files as a single concatenation.
|
||||||
|
*/
|
||||||
|
#undef assert
|
||||||
|
#undef not_reached
|
||||||
|
#undef not_implemented
|
||||||
|
#include "jemalloc/internal/assert.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user