2013-12-06 13:43:46 +08:00
|
|
|
/*
|
2013-12-11 06:23:10 +08:00
|
|
|
* JEMALLOC_ALWAYS_INLINE and JEMALLOC_INLINE are used within header files for
|
|
|
|
* functions that are static inline functions if inlining is enabled, and
|
|
|
|
* single-definition library-private functions if inlining is disabled.
|
2013-12-06 13:43:46 +08:00
|
|
|
*
|
2013-12-11 06:23:10 +08:00
|
|
|
* JEMALLOC_ALWAYS_INLINE_C and JEMALLOC_INLINE_C are for use in .c files, in
|
|
|
|
* which case the denoted functions are always static, regardless of whether
|
|
|
|
* inlining is enabled.
|
2013-12-06 13:43:46 +08:00
|
|
|
*/
|
2013-12-07 10:27:33 +08:00
|
|
|
#if defined(JEMALLOC_DEBUG) || defined(JEMALLOC_CODE_COVERAGE)
|
|
|
|
/* Disable inlining to make debugging/profiling easier. */
|
2013-12-06 13:43:46 +08:00
|
|
|
# define JEMALLOC_ALWAYS_INLINE
|
|
|
|
# define JEMALLOC_ALWAYS_INLINE_C static
|
|
|
|
# define JEMALLOC_INLINE
|
2013-12-11 06:23:10 +08:00
|
|
|
# define JEMALLOC_INLINE_C static
|
2013-12-06 13:43:46 +08:00
|
|
|
# define inline
|
|
|
|
#else
|
|
|
|
# define JEMALLOC_ENABLE_INLINE
|
|
|
|
# ifdef JEMALLOC_HAVE_ATTR
|
|
|
|
# define JEMALLOC_ALWAYS_INLINE \
|
|
|
|
static inline JEMALLOC_ATTR(unused) JEMALLOC_ATTR(always_inline)
|
|
|
|
# define JEMALLOC_ALWAYS_INLINE_C \
|
|
|
|
static inline JEMALLOC_ATTR(always_inline)
|
|
|
|
# else
|
|
|
|
# define JEMALLOC_ALWAYS_INLINE static inline
|
|
|
|
# define JEMALLOC_ALWAYS_INLINE_C static inline
|
|
|
|
# endif
|
|
|
|
# define JEMALLOC_INLINE static inline
|
2013-12-11 06:23:10 +08:00
|
|
|
# define JEMALLOC_INLINE_C static inline
|
2013-12-06 13:43:46 +08:00
|
|
|
# ifdef _MSC_VER
|
|
|
|
# define inline _inline
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef JEMALLOC_CC_SILENCE
|
2013-12-11 06:23:10 +08:00
|
|
|
# define UNUSED JEMALLOC_ATTR(unused)
|
2013-12-06 13:43:46 +08:00
|
|
|
#else
|
2013-12-11 06:23:10 +08:00
|
|
|
# define UNUSED
|
2013-12-06 13:43:46 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ZU(z) ((size_t)z)
|
2014-05-29 07:11:55 +08:00
|
|
|
#define ZI(z) ((ssize_t)z)
|
2013-12-06 13:43:46 +08:00
|
|
|
#define QU(q) ((uint64_t)q)
|
2013-12-10 15:36:37 +08:00
|
|
|
#define QI(q) ((int64_t)q)
|
2013-12-06 13:43:46 +08:00
|
|
|
|
2014-05-29 07:11:55 +08:00
|
|
|
#define KZU(z) ZU(z##ULL)
|
2014-05-29 12:14:16 +08:00
|
|
|
#define KZI(z) ZI(z##LL)
|
2014-05-29 07:11:55 +08:00
|
|
|
#define KQU(q) QU(q##ULL)
|
2014-05-29 12:14:16 +08:00
|
|
|
#define KQI(q) QI(q##LL)
|
2014-05-29 07:11:55 +08:00
|
|
|
|
2013-12-06 13:43:46 +08:00
|
|
|
#ifndef __DECONST
|
|
|
|
# define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
|
|
|
|
#endif
|
2014-02-25 08:08:38 +08:00
|
|
|
|
jemalloc cpp new/delete bindings
Adds cpp bindings for jemalloc, along with necessary autoconf settings.
This is mostly to add sized deallocation support, which can't be added
from C directly. Sized deallocation is ~10% microbench improvement.
* Import ax_cxx_compile_stdcxx.m4 from the autoconf repo, seems like the
easiest way to get c++14 detection.
* Adds various other changes, like CXXFLAGS, to configure.ac.
* Adds new rules to Makefile.in for src/jemalloc-cpp.cpp, and a basic
unittest.
* Both new and delete are overridden, to ensure jemalloc is used for
both.
* TODO future enhancement of avoiding extra PLT thunks for new and
delete - sdallocx and malloc are publicly exported jemalloc symbols,
using an alias would link them directly. Unfortunately, was having
trouble getting it to play nice with jemalloc's namespace support.
Testing:
Tested gcc 4.8, gcc 5, gcc 5.2, clang 4.0. Only gcc >= 5 has sized
deallocation support, verified that the rest build correctly.
Tested mac osx and Centos.
Tested --with-jemalloc-prefix and --without-export.
This resolves #202.
2016-10-24 06:56:30 +08:00
|
|
|
#if !defined(JEMALLOC_HAS_RESTRICT) || defined(__cplusplus)
|
2014-02-25 08:08:38 +08:00
|
|
|
# define restrict
|
|
|
|
#endif
|