Add sdallocx for jemalloc
authorQinfan Wu <wqfish@fb.com>
Tue, 24 Nov 2015 18:02:25 +0000 (10:02 -0800)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Tue, 24 Nov 2015 18:20:22 +0000 (10:20 -0800)
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

folly/Malloc.h
folly/detail/Malloc.h
folly/detail/MallocImpl.cpp

index d779a063d532c966c0dc445158b763f38df5bd3d..7ab007a91f3e8518e89c895146af675a672c639b 100644 (file)
@@ -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;
     }
 
index e6d1e4997eedcccc5ae2950b4bd7470a866759bf..2a04ff284777a8e38c99df59866afc6ea00c3eb5 100644 (file)
@@ -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*);
index 8a835629391af330def935e2c40dae9c5ff96ed2..726d3e3d010d6b5138f6695c12cfbf62719b0f19 100644 (file)
@@ -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;