From: Qinfan Wu Date: Tue, 24 Nov 2015 18:02:25 +0000 (-0800) Subject: Add sdallocx for jemalloc X-Git-Tag: deprecate-dynamic-initializer~235 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e9df6f7912089f65e85bb1dc160cae431992f8e5;p=folly.git Add sdallocx for jemalloc Summary: Make jemalloc's sdallocx function available in folly and allow future code to use sized deallocation. Reviewed By: elsteveogrande, ot Differential Revision: D2687746 fb-gh-sync-id: 9ef8a16d2c63c4eb8cecab7639add423ef093c2d --- diff --git a/folly/Malloc.h b/folly/Malloc.h index d779a063..7ab007a9 100644 --- a/folly/Malloc.h +++ b/folly/Malloc.h @@ -73,6 +73,8 @@ extern "C" size_t sallocx(const void*, int) __attribute__((__weak__)); extern "C" void dallocx(void*, int) __attribute__((__weak__)); +extern "C" void sdallocx(void*, size_t, int) +__attribute__((__weak__)); extern "C" size_t nallocx(size_t, int) __attribute__((__weak__)); extern "C" int mallctl(const char*, void*, size_t*, void*, size_t) @@ -137,9 +139,9 @@ inline bool usingJEMalloc() noexcept { // in the form if (mallctl != nullptr). Not if (mallctl) or if (!mallctl) // (!!). http://goo.gl/xpmctm if (mallocx == nullptr || rallocx == nullptr || xallocx == nullptr - || sallocx == nullptr || dallocx == nullptr || nallocx == nullptr - || mallctl == nullptr || mallctlnametomib == nullptr - || mallctlbymib == nullptr) { + || sallocx == nullptr || dallocx == nullptr || sdallocx == nullptr + || nallocx == nullptr || mallctl == nullptr + || mallctlnametomib == nullptr || mallctlbymib == nullptr) { return false; } diff --git a/folly/detail/Malloc.h b/folly/detail/Malloc.h index e6d1e499..2a04ff28 100644 --- a/folly/detail/Malloc.h +++ b/folly/detail/Malloc.h @@ -29,6 +29,7 @@ void* rallocx(void*, size_t, int) __attribute__((__weak__)); size_t xallocx(void*, size_t, size_t, int) __attribute__((__weak__)); size_t sallocx(const void*, int) __attribute__((__weak__)); void dallocx(void*, int) __attribute__((__weak__)); +void sdallocx(void*, size_t, int) __attribute__((__weak__)); size_t nallocx(size_t, int) __attribute__((__weak__)); int mallctl(const char*, void*, size_t*, void*, size_t) __attribute__((__weak__)); @@ -41,6 +42,7 @@ extern void* (*rallocx)(void*, size_t, int); extern size_t (*xallocx)(void*, size_t, size_t, int); extern size_t (*sallocx)(const void*, int); extern void (*dallocx)(void*, int); +extern void (*sdallocx)(void*, size_t, int); extern size_t (*nallocx)(size_t, int); extern int (*mallctl)(const char*, void*, size_t*, void*, size_t); extern int (*mallctlnametomib)(const char*, size_t*, size_t*); diff --git a/folly/detail/MallocImpl.cpp b/folly/detail/MallocImpl.cpp index 8a835629..726d3e3d 100644 --- a/folly/detail/MallocImpl.cpp +++ b/folly/detail/MallocImpl.cpp @@ -24,6 +24,7 @@ void* (*rallocx)(void*, size_t, int) = nullptr; size_t (*xallocx)(void*, size_t, size_t, int) = nullptr; size_t (*sallocx)(const void*, int) = nullptr; void (*dallocx)(void*, int) = nullptr; +void (*sdallocx)(void*, size_t, int) = nullptr; size_t (*nallocx)(size_t, int) = nullptr; int (*mallctl)(const char*, void*, size_t*, void*, size_t) = nullptr; int (*mallctlnametomib)(const char*, size_t*, size_t*) = nullptr;