]>
git.saurik.com Git - redis.git/blob - deps/jemalloc/include/jemalloc/internal/util.h
1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
4 /* Size of stack-allocated buffer passed to buferror(). */
5 #define BUFERROR_BUF 64
8 * Size of stack-allocated buffer used by malloc_{,v,vc}printf(). This must be
9 * large enough for all possible uses within jemalloc.
11 #define MALLOC_PRINTF_BUFSIZE 4096
14 * Wrap a cpp argument that contains commas such that it isn't broken up into
17 #define JEMALLOC_CONCAT(...) __VA_ARGS__
20 * Silence compiler warnings due to uninitialized values. This is used
21 * wherever the compiler fails to recognize that the variable is never used
24 #ifdef JEMALLOC_CC_SILENCE
25 # define JEMALLOC_CC_SILENCE_INIT(v) = v
27 # define JEMALLOC_CC_SILENCE_INIT(v)
31 * Define a custom assert() in order to reduce the chances of deadlock during
35 #define assert(e) do { \
36 if (config_debug && !(e)) { \
38 "<jemalloc>: %s:%d: Failed assertion: \"%s\"\n", \
39 __FILE__, __LINE__, #e); \
45 /* Use to assert a particular configuration, e.g., cassert(config_debug). */
46 #define cassert(c) do { \
52 #define not_reached() do { \
55 "<jemalloc>: %s:%d: Unreachable code reached\n", \
56 __FILE__, __LINE__); \
62 #ifndef not_implemented
63 #define not_implemented() do { \
65 malloc_printf("<jemalloc>: %s:%d: Not implemented\n", \
66 __FILE__, __LINE__); \
72 #define assert_not_implemented(e) do { \
73 if (config_debug && !(e)) \
77 #endif /* JEMALLOC_H_TYPES */
78 /******************************************************************************/
79 #ifdef JEMALLOC_H_STRUCTS
81 #endif /* JEMALLOC_H_STRUCTS */
82 /******************************************************************************/
83 #ifdef JEMALLOC_H_EXTERNS
85 int buferror(char *buf
, size_t buflen
);
86 uintmax_t malloc_strtoumax(const char *nptr
, char **endptr
, int base
);
87 void malloc_write(const char *s
);
90 * malloc_vsnprintf() supports a subset of snprintf(3) that avoids floating
93 int malloc_vsnprintf(char *str
, size_t size
, const char *format
,
95 int malloc_snprintf(char *str
, size_t size
, const char *format
, ...)
96 JEMALLOC_ATTR(format(printf
, 3, 4));
97 void malloc_vcprintf(void (*write_cb
)(void *, const char *), void *cbopaque
,
98 const char *format
, va_list ap
);
99 void malloc_cprintf(void (*write
)(void *, const char *), void *cbopaque
,
100 const char *format
, ...) JEMALLOC_ATTR(format(printf
, 3, 4));
101 void malloc_printf(const char *format
, ...)
102 JEMALLOC_ATTR(format(printf
, 1, 2));
104 #endif /* JEMALLOC_H_EXTERNS */
105 /******************************************************************************/
106 #ifdef JEMALLOC_H_INLINES
108 #ifndef JEMALLOC_ENABLE_INLINE
109 size_t pow2_ceil(size_t x
);
110 void malloc_write(const char *s
);
111 void set_errno(int errnum
);
115 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_UTIL_C_))
116 /* Compute the smallest power of 2 that is >= x. */
117 JEMALLOC_INLINE
size_t
127 #if (LG_SIZEOF_PTR == 3)
134 /* Sets error code */
136 set_errno(int errnum
)
140 SetLastError(errnum
);
146 /* Get last error code */
152 return (GetLastError());
159 #endif /* JEMALLOC_H_INLINES */
160 /******************************************************************************/