1 #ifndef JEMALLOC_INTERNAL_UTIL_TYPES_H 2 #define JEMALLOC_INTERNAL_UTIL_TYPES_H 3 4 #ifdef _WIN32 5 # ifdef _WIN64 6 # define FMT64_PREFIX "ll" 7 # define FMTPTR_PREFIX "ll" 8 # else 9 # define FMT64_PREFIX "ll" 10 # define FMTPTR_PREFIX "" 11 # endif 12 # define FMTd32 "d" 13 # define FMTu32 "u" 14 # define FMTx32 "x" 15 # define FMTd64 FMT64_PREFIX "d" 16 # define FMTu64 FMT64_PREFIX "u" 17 # define FMTx64 FMT64_PREFIX "x" 18 # define FMTdPTR FMTPTR_PREFIX "d" 19 # define FMTuPTR FMTPTR_PREFIX "u" 20 # define FMTxPTR FMTPTR_PREFIX "x" 21 #else 22 # include <inttypes.h> 23 # define FMTd32 PRId32 24 # define FMTu32 PRIu32 25 # define FMTx32 PRIx32 26 # define FMTd64 PRId64 27 # define FMTu64 PRIu64 28 # define FMTx64 PRIx64 29 # define FMTdPTR PRIdPTR 30 # define FMTuPTR PRIuPTR 31 # define FMTxPTR PRIxPTR 32 #endif 33 34 /* Size of stack-allocated buffer passed to buferror(). */ 35 #define BUFERROR_BUF 64 36 37 /* 38 * Size of stack-allocated buffer used by malloc_{,v,vc}printf(). This must be 39 * large enough for all possible uses within jemalloc. 40 */ 41 #define MALLOC_PRINTF_BUFSIZE 4096 42 43 /* Junk fill patterns. */ 44 #ifndef JEMALLOC_ALLOC_JUNK 45 # define JEMALLOC_ALLOC_JUNK ((uint8_t)0xa5) 46 #endif 47 #ifndef JEMALLOC_FREE_JUNK 48 # define JEMALLOC_FREE_JUNK ((uint8_t)0x5a) 49 #endif 50 51 /* 52 * Wrap a cpp argument that contains commas such that it isn't broken up into 53 * multiple arguments. 54 */ 55 #define JEMALLOC_ARG_CONCAT(...) __VA_ARGS__ 56 57 /* cpp macro definition stringification. */ 58 #define STRINGIFY_HELPER(x) #x 59 #define STRINGIFY(x) STRINGIFY_HELPER(x) 60 61 /* 62 * Silence compiler warnings due to uninitialized values. This is used 63 * wherever the compiler fails to recognize that the variable is never used 64 * uninitialized. 65 */ 66 #ifdef JEMALLOC_CC_SILENCE 67 # define JEMALLOC_CC_SILENCE_INIT(v) = v 68 #else 69 # define JEMALLOC_CC_SILENCE_INIT(v) 70 #endif 71 72 #ifdef __GNUC__ 73 # define likely(x) __builtin_expect(!!(x), 1) 74 # define unlikely(x) __builtin_expect(!!(x), 0) 75 #else 76 # define likely(x) !!(x) 77 # define unlikely(x) !!(x) 78 #endif 79 80 #if !defined(JEMALLOC_INTERNAL_UNREACHABLE) 81 # error JEMALLOC_INTERNAL_UNREACHABLE should have been defined by configure 82 #endif 83 84 #define unreachable() JEMALLOC_INTERNAL_UNREACHABLE() 85 86 #include "jemalloc/internal/assert.h" 87 88 /* Use to assert a particular configuration, e.g., cassert(config_debug). */ 89 #define cassert(c) do { \ 90 if (unlikely(!(c))) \ 91 not_reached(); \ 92 } while (0) 93 94 #endif /* JEMALLOC_INTERNAL_UTIL_TYPES_H */ 95