summaryrefslogtreecommitdiff
path: root/deps/jemalloc/include/jemalloc/internal/assert.h
diff options
context:
space:
mode:
authorYoav Steinberg <yoav@monfort.co.il>2021-10-10 18:26:48 +0300
committerYoav Steinberg <yoav@monfort.co.il>2021-10-10 18:26:48 +0300
commit4d5911b4e47e1ac45fa53c1e80a735127bf8860e (patch)
tree459fc082ecfd0ff2bfeb4bbf843cf6f93fed9459 /deps/jemalloc/include/jemalloc/internal/assert.h
parent4a884343f5935f7d470ab0ce013a421f119cfb3a (diff)
parent220a0f0880419450c9409202aac1fab4b8be0719 (diff)
downloadredis-4d5911b4e47e1ac45fa53c1e80a735127bf8860e.tar.gz
Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc'
Diffstat (limited to 'deps/jemalloc/include/jemalloc/internal/assert.h')
-rw-r--r--deps/jemalloc/include/jemalloc/internal/assert.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/deps/jemalloc/include/jemalloc/internal/assert.h b/deps/jemalloc/include/jemalloc/internal/assert.h
new file mode 100644
index 000000000..be4d45b32
--- /dev/null
+++ b/deps/jemalloc/include/jemalloc/internal/assert.h
@@ -0,0 +1,56 @@
+#include "jemalloc/internal/malloc_io.h"
+#include "jemalloc/internal/util.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). */
+#ifndef cassert
+#define cassert(c) do { \
+ if (unlikely(!(c))) { \
+ not_reached(); \
+ } \
+} while (0)
+#endif