30 #if (defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)) && !FOLLY_SANITIZE 32 #include <jemalloc/jemalloc.h> 34 #ifndef MALLOCX_LG_ALIGN 35 #define MALLOCX_LG_ALIGN(la) (la) 38 #define MALLOCX_ZERO (static_cast<int>(0x40)) 47 #if defined(_GLIBCXX_USE_FB) && !defined(_LIBSTDCXX_FBSTRING) 64 #else // !defined(_GLIBCXX_USE_FB) || defined(_LIBSTDCXX_FBSTRING) 66 #ifdef _LIBSTDCXX_FBSTRING 67 #pragma GCC system_header 81 extern "C" int mallctl(
const char*,
void*,
size_t*,
void*,
size_t)
86 mallctlbymib(
const size_t*,
size_t,
void*,
size_t*,
void*,
size_t)
89 #else // !defined(_LIBSTDCXX_FBSTRING) 99 #if __has_include(<malloc.h>) 116 #ifdef _LIBSTDCXX_FBSTRING 118 _GLIBCXX_BEGIN_NAMESPACE_VERSION
124 #if defined(__GNUC__) 125 #define FOLLY_MALLOC_NOINLINE __attribute__((__noinline__)) 126 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL) >= 40900 129 #define FOLLY_MALLOC_CHECKED_MALLOC \ 130 __attribute__((__returns_nonnull__, __malloc__)) 132 #define FOLLY_MALLOC_CHECKED_MALLOC __attribute__((__malloc__)) 135 #define FOLLY_MALLOC_NOINLINE 136 #define FOLLY_MALLOC_CHECKED_MALLOC 142 #if defined(USE_JEMALLOC) && !FOLLY_SANITIZE 156 static const bool result = []()
noexcept {
170 size_t counterLen =
sizeof(
uint64_t*);
174 static_cast<void*>(&counter),
181 if (counterLen !=
sizeof(
uint64_t*)) {
187 static const void*
volatile ptr = malloc(1);
193 return (origAllocated != *counter);
214 return rv ? rv : minSize;
228 void* p = malloc(size);
230 throw_exception<std::bad_alloc>();
236 void* p = calloc(n, size);
238 throw_exception<std::bad_alloc>();
244 void* p = realloc(ptr, size);
246 throw_exception<std::bad_alloc>();
263 const size_t currentSize,
264 const size_t currentCapacity,
265 const size_t newCapacity) {
267 assert(currentSize <= currentCapacity &&
268 currentCapacity < newCapacity);
270 auto const slack = currentCapacity - currentSize;
271 if (slack * 2 > currentSize) {
274 std::memcpy(result, p, currentSize);
282 #ifdef _LIBSTDCXX_FBSTRING 283 _GLIBCXX_END_NAMESPACE_VERSION
290 #endif // !defined(_GLIBCXX_USE_FB) || defined(_LIBSTDCXX_FBSTRING)
void(* dallocx)(void *, int)
void * checkedMalloc(size_t size)
#define FOLLY_MALLOC_NOINLINE
bool usingJEMalloc() noexcept
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
int(* mallctlbymib)(const size_t *, size_t, void *, size_t *, void *, size_t)
static const size_t jemallocMinInPlaceExpandable
size_t(* xallocx)(void *, size_t, size_t, int)
constexpr auto size(C const &c) -> decltype(c.size())
size_t(* nallocx)(size_t, int)
int(* mallctl)(const char *, void *, size_t *, void *, size_t)
#define FOLLY_MALLOC_CHECKED_MALLOC
void(* sdallocx)(void *, size_t, int)
void *(* mallocx)(size_t, int)
size_t(* sallocx)(const void *, int)
std::atomic< int > counter
void * checkedCalloc(size_t n, size_t size)
__attribute__((noinline, noclone)) VirtualBase *makeVirtual()
int(* mallctlnametomib)(const char *, size_t *, size_t *)
void * smartRealloc(void *p, const size_t currentSize, const size_t currentCapacity, const size_t newCapacity)
void *(* rallocx)(void *, size_t, int)
void * checkedRealloc(void *ptr, size_t size)
size_t goodMallocSize(size_t minSize) noexcept