jemalloc_internal_macros.h revision 8d8f9aeeaa77514d5732db5bd0111232af21fcfd
1/*
2 * JEMALLOC_ALWAYS_INLINE and JEMALLOC_INLINE are used within header files for
3 * functions that are static inline functions if inlining is enabled, and
4 * single-definition library-private functions if inlining is disabled.
5 *
6 * JEMALLOC_ALWAYS_INLINE_C and JEMALLOC_INLINE_C are for use in .c files, in
7 * which case the denoted functions are always static, regardless of whether
8 * inlining is enabled.
9 */
10#if defined(JEMALLOC_DEBUG) || defined(JEMALLOC_CODE_COVERAGE)
11   /* Disable inlining to make debugging/profiling easier. */
12#  define JEMALLOC_ALWAYS_INLINE
13#  define JEMALLOC_ALWAYS_INLINE_C static
14#  define JEMALLOC_INLINE
15#  define JEMALLOC_INLINE_C static
16#  define inline
17#else
18#  define JEMALLOC_ENABLE_INLINE
19#  ifdef JEMALLOC_HAVE_ATTR
20#    define JEMALLOC_ALWAYS_INLINE \
21	 static inline JEMALLOC_ATTR(unused) JEMALLOC_ATTR(always_inline)
22#    define JEMALLOC_ALWAYS_INLINE_C \
23	 static inline JEMALLOC_ATTR(always_inline)
24#  else
25#    define JEMALLOC_ALWAYS_INLINE static inline
26#    define JEMALLOC_ALWAYS_INLINE_C static inline
27#  endif
28#  define JEMALLOC_INLINE static inline
29#  define JEMALLOC_INLINE_C static inline
30#  ifdef _MSC_VER
31#    define inline _inline
32#  endif
33#endif
34
35#ifdef JEMALLOC_CC_SILENCE
36#  define UNUSED JEMALLOC_ATTR(unused)
37#else
38#  define UNUSED
39#endif
40
41#define	ZU(z)	((size_t)z)
42#define	ZI(z)	((ssize_t)z)
43#define	QU(q)	((uint64_t)q)
44#define	QI(q)	((int64_t)q)
45
46#define	KZU(z)	ZU(z##ULL)
47#define	KZI(z)	ZI(z##ULL)
48#define	KQU(q)	QU(q##ULL)
49#define	KQI(q)	QI(q##ULL)
50
51#ifndef __DECONST
52#  define	__DECONST(type, var)	((type)(uintptr_t)(const void *)(var))
53#endif
54
55#ifndef JEMALLOC_HAS_RESTRICT
56#  define restrict
57#endif
58