2017-01-11 10:06:31 +08:00
|
|
|
#ifndef JEMALLOC_INTERNAL_MACROS_H
|
|
|
|
#define JEMALLOC_INTERNAL_MACROS_H
|
|
|
|
|
2017-04-25 06:22:03 +08:00
|
|
|
#ifdef JEMALLOC_DEBUG
|
2017-04-22 00:37:34 +08:00
|
|
|
# define JEMALLOC_ALWAYS_INLINE static inline
|
2013-12-06 13:43:46 +08:00
|
|
|
#else
|
2019-10-23 21:00:49 +08:00
|
|
|
# ifdef _MSC_VER
|
|
|
|
# define JEMALLOC_ALWAYS_INLINE static __forceinline
|
|
|
|
# else
|
|
|
|
# define JEMALLOC_ALWAYS_INLINE JEMALLOC_ATTR(always_inline) static inline
|
|
|
|
# endif
|
2017-04-22 00:37:34 +08:00
|
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
# define inline _inline
|
2013-12-06 13:43:46 +08:00
|
|
|
#endif
|
|
|
|
|
2017-04-25 02:47:10 +08:00
|
|
|
#define UNUSED JEMALLOC_ATTR(unused)
|
2013-12-06 13:43:46 +08:00
|
|
|
|
2017-01-20 13:41:41 +08:00
|
|
|
#define ZU(z) ((size_t)z)
|
2017-03-07 03:40:29 +08:00
|
|
|
#define ZD(z) ((ssize_t)z)
|
2017-01-20 13:41:41 +08:00
|
|
|
#define QU(q) ((uint64_t)q)
|
2017-03-07 03:40:29 +08:00
|
|
|
#define QD(q) ((int64_t)q)
|
2013-12-06 13:43:46 +08:00
|
|
|
|
2017-01-20 13:41:41 +08:00
|
|
|
#define KZU(z) ZU(z##ULL)
|
2017-03-07 03:40:29 +08:00
|
|
|
#define KZD(z) ZD(z##LL)
|
2017-01-20 13:41:41 +08:00
|
|
|
#define KQU(q) QU(q##ULL)
|
2017-03-07 03:40:29 +08:00
|
|
|
#define KQD(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
|
2017-01-11 10:06:31 +08:00
|
|
|
|
2019-03-10 02:51:03 +08:00
|
|
|
/* Various function pointers are static and immutable except during testing. */
|
2017-05-02 14:10:42 +08:00
|
|
|
#ifdef JEMALLOC_JET
|
|
|
|
# define JET_MUTABLE
|
|
|
|
#else
|
|
|
|
# define JET_MUTABLE const
|
|
|
|
#endif
|
|
|
|
|
2017-07-22 04:34:45 +08:00
|
|
|
#define JEMALLOC_VA_ARGS_HEAD(head, ...) head
|
|
|
|
#define JEMALLOC_VA_ARGS_TAIL(head, ...) __VA_ARGS__
|
|
|
|
|
2018-05-03 17:40:53 +08:00
|
|
|
/* Diagnostic suppression macros */
|
|
|
|
#if defined(_MSC_VER) && !defined(__clang__)
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_PUSH __pragma(warning(push))
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_POP __pragma(warning(pop))
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE(W) __pragma(warning(disable:W))
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS
|
2023-07-21 02:30:59 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_FRAME_ADDRESS
|
2018-05-03 17:40:53 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_TYPE_LIMITS
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_ALLOC_SIZE_LARGER_THAN
|
2023-08-04 06:05:10 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_DEPRECATED
|
2018-05-03 17:40:53 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS
|
2019-03-10 02:51:03 +08:00
|
|
|
/* #pragma GCC diagnostic first appeared in gcc 4.6. */
|
|
|
|
#elif (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && \
|
|
|
|
(__GNUC_MINOR__ > 5)))) || defined(__clang__)
|
2018-05-03 17:40:53 +08:00
|
|
|
/*
|
|
|
|
* The JEMALLOC_PRAGMA__ macro is an implementation detail of the GCC and Clang
|
|
|
|
* diagnostic suppression macros and should not be used anywhere else.
|
|
|
|
*/
|
|
|
|
# define JEMALLOC_PRAGMA__(X) _Pragma(#X)
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_PUSH JEMALLOC_PRAGMA__(GCC diagnostic push)
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_POP JEMALLOC_PRAGMA__(GCC diagnostic pop)
|
2019-03-10 02:51:03 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE(W) \
|
|
|
|
JEMALLOC_PRAGMA__(GCC diagnostic ignored W)
|
2018-07-10 20:48:18 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The -Wmissing-field-initializers warning is buggy in GCC versions < 5.1 and
|
2019-03-10 02:51:03 +08:00
|
|
|
* all clang versions up to version 7 (currently trunk, unreleased). This macro
|
|
|
|
* suppresses the warning for the affected compiler versions only.
|
2018-07-10 20:48:18 +08:00
|
|
|
*/
|
2019-03-10 02:51:03 +08:00
|
|
|
# if ((defined(__GNUC__) && !defined(__clang__)) && (__GNUC__ < 5)) || \
|
|
|
|
defined(__clang__)
|
2018-07-10 20:48:18 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS \
|
|
|
|
JEMALLOC_DIAGNOSTIC_IGNORE("-Wmissing-field-initializers")
|
|
|
|
# else
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS
|
|
|
|
# endif
|
|
|
|
|
2023-07-21 02:30:59 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_FRAME_ADDRESS \
|
|
|
|
JEMALLOC_DIAGNOSTIC_IGNORE("-Wframe-address")
|
2018-05-03 17:40:53 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_TYPE_LIMITS \
|
|
|
|
JEMALLOC_DIAGNOSTIC_IGNORE("-Wtype-limits")
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_UNUSED_PARAMETER \
|
|
|
|
JEMALLOC_DIAGNOSTIC_IGNORE("-Wunused-parameter")
|
|
|
|
# if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ >= 7)
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_ALLOC_SIZE_LARGER_THAN \
|
|
|
|
JEMALLOC_DIAGNOSTIC_IGNORE("-Walloc-size-larger-than=")
|
|
|
|
# else
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_ALLOC_SIZE_LARGER_THAN
|
|
|
|
# endif
|
2023-08-04 06:05:10 +08:00
|
|
|
# ifdef JEMALLOC_HAVE_ATTR_DEPRECATED
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_DEPRECATED \
|
|
|
|
JEMALLOC_DIAGNOSTIC_IGNORE("-Wdeprecated-declarations")
|
|
|
|
# else
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_DEPRECATED
|
|
|
|
# endif
|
2018-05-03 17:40:53 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS \
|
|
|
|
JEMALLOC_DIAGNOSTIC_PUSH \
|
|
|
|
JEMALLOC_DIAGNOSTIC_IGNORE_UNUSED_PARAMETER
|
|
|
|
#else
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_PUSH
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_POP
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE(W)
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS
|
2023-07-21 02:30:59 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_FRAME_ADDRESS
|
2018-05-03 17:40:53 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_TYPE_LIMITS
|
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_ALLOC_SIZE_LARGER_THAN
|
2023-08-04 06:05:10 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_IGNORE_DEPRECATED
|
2018-05-03 17:40:53 +08:00
|
|
|
# define JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS
|
|
|
|
#endif
|
|
|
|
|
2023-08-04 06:05:10 +08:00
|
|
|
#define JEMALLOC_SUPPRESS_WARN_ON_USAGE(...) \
|
|
|
|
JEMALLOC_DIAGNOSTIC_PUSH \
|
|
|
|
JEMALLOC_DIAGNOSTIC_IGNORE_DEPRECATED \
|
|
|
|
__VA_ARGS__ \
|
|
|
|
JEMALLOC_DIAGNOSTIC_POP
|
|
|
|
|
2018-05-03 17:40:53 +08:00
|
|
|
/*
|
2019-03-10 02:51:03 +08:00
|
|
|
* Disables spurious diagnostics for all headers. Since these headers are not
|
|
|
|
* included by users directly, it does not affect their diagnostic settings.
|
2018-05-03 17:40:53 +08:00
|
|
|
*/
|
|
|
|
JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS
|
|
|
|
|
2017-01-11 10:06:31 +08:00
|
|
|
#endif /* JEMALLOC_INTERNAL_MACROS_H */
|