Blame jemalloc/include/jemalloc/internal/assert.h
|
Packit |
345191 |
#include "jemalloc/internal/malloc_io.h"
|
|
Packit |
345191 |
#include "jemalloc/internal/util.h"
|
|
Packit |
345191 |
|
|
Packit |
345191 |
/*
|
|
Packit |
345191 |
* Define a custom assert() in order to reduce the chances of deadlock during
|
|
Packit |
345191 |
* assertion failure.
|
|
Packit |
345191 |
*/
|
|
Packit |
345191 |
#ifndef assert
|
|
Packit |
345191 |
#define assert(e) do { \
|
|
Packit |
345191 |
if (unlikely(config_debug && !(e))) { \
|
|
Packit |
345191 |
malloc_printf( \
|
|
Packit |
345191 |
"<jemalloc>: %s:%d: Failed assertion: \"%s\"\n", \
|
|
Packit |
345191 |
__FILE__, __LINE__, #e); \
|
|
Packit |
345191 |
abort(); \
|
|
Packit |
345191 |
} \
|
|
Packit |
345191 |
} while (0)
|
|
Packit |
345191 |
#endif
|
|
Packit |
345191 |
|
|
Packit |
345191 |
#ifndef not_reached
|
|
Packit |
345191 |
#define not_reached() do { \
|
|
Packit |
345191 |
if (config_debug) { \
|
|
Packit |
345191 |
malloc_printf( \
|
|
Packit |
345191 |
"<jemalloc>: %s:%d: Unreachable code reached\n", \
|
|
Packit |
345191 |
__FILE__, __LINE__); \
|
|
Packit |
345191 |
abort(); \
|
|
Packit |
345191 |
} \
|
|
Packit |
345191 |
unreachable(); \
|
|
Packit |
345191 |
} while (0)
|
|
Packit |
345191 |
#endif
|
|
Packit |
345191 |
|
|
Packit |
345191 |
#ifndef not_implemented
|
|
Packit |
345191 |
#define not_implemented() do { \
|
|
Packit |
345191 |
if (config_debug) { \
|
|
Packit |
345191 |
malloc_printf("<jemalloc>: %s:%d: Not implemented\n", \
|
|
Packit |
345191 |
__FILE__, __LINE__); \
|
|
Packit |
345191 |
abort(); \
|
|
Packit |
345191 |
} \
|
|
Packit |
345191 |
} while (0)
|
|
Packit |
345191 |
#endif
|
|
Packit |
345191 |
|
|
Packit |
345191 |
#ifndef assert_not_implemented
|
|
Packit |
345191 |
#define assert_not_implemented(e) do { \
|
|
Packit |
345191 |
if (unlikely(config_debug && !(e))) { \
|
|
Packit |
345191 |
not_implemented(); \
|
|
Packit |
345191 |
} \
|
|
Packit |
345191 |
} while (0)
|
|
Packit |
345191 |
#endif
|
|
Packit |
345191 |
|
|
Packit |
345191 |
/* Use to assert a particular configuration, e.g., cassert(config_debug). */
|
|
Packit |
345191 |
#ifndef cassert
|
|
Packit |
345191 |
#define cassert(c) do { \
|
|
Packit |
345191 |
if (unlikely(!(c))) { \
|
|
Packit |
345191 |
not_reached(); \
|
|
Packit |
345191 |
} \
|
|
Packit |
345191 |
} while (0)
|
|
Packit |
345191 |
#endif
|