• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "jemalloc/internal/malloc_io.h"
2 #include "jemalloc/internal/util.h"
3 
4 /*
5  * Define a custom assert() in order to reduce the chances of deadlock during
6  * assertion failure.
7  */
8 #ifndef assert
9 #define assert(e) do {							\
10 	if (unlikely(config_debug && !(e))) {				\
11 		malloc_printf(						\
12 		    "<jemalloc>: %s:%d: Failed assertion: \"%s\"\n",	\
13 		    __FILE__, __LINE__, #e);				\
14 		abort();						\
15 	}								\
16 } while (0)
17 #endif
18 
19 #ifndef not_reached
20 #define not_reached() do {						\
21 	if (config_debug) {						\
22 		malloc_printf(						\
23 		    "<jemalloc>: %s:%d: Unreachable code reached\n",	\
24 		    __FILE__, __LINE__);				\
25 		abort();						\
26 	}								\
27 	unreachable();							\
28 } while (0)
29 #endif
30 
31 #ifndef not_implemented
32 #define not_implemented() do {						\
33 	if (config_debug) {						\
34 		malloc_printf("<jemalloc>: %s:%d: Not implemented\n",	\
35 		    __FILE__, __LINE__);				\
36 		abort();						\
37 	}								\
38 } while (0)
39 #endif
40 
41 #ifndef assert_not_implemented
42 #define assert_not_implemented(e) do {					\
43 	if (unlikely(config_debug && !(e))) {				\
44 		not_implemented();					\
45 	}								\
46 } while (0)
47 #endif
48 
49 /* Use to assert a particular configuration, e.g., cassert(config_debug). */
50 #ifndef cassert
51 #define cassert(c) do {							\
52 	if (unlikely(!(c))) {						\
53 		not_reached();						\
54 	}								\
55 } while (0)
56 #endif
57