summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2015-06-05 17:12:17 -0700
committerChristopher Ferris <cferris@google.com>2015-06-06 13:25:56 -0700
commite49af9bca5706ecbc9c4f3cf15be990294106952 (patch)
treef9f78b1bbf8a944362f23d2bc881f8389d133ea3 /libc
parent7a799f2b02ee453a46ee368cd8c41477e0567852 (diff)
downloadbionic-e49af9bca5706ecbc9c4f3cf15be990294106952.tar.gz
bionic-e49af9bca5706ecbc9c4f3cf15be990294106952.tar.bz2
bionic-e49af9bca5706ecbc9c4f3cf15be990294106952.zip
Export two dlmalloc functions everywhere.
The functions dlmalloc_inspect_all and dlmalloc_trim get exported on devices that use dlmalloc, so be consistent and export them everywhere. Bug: 21640784 (cherry picked from commit f9554a17765fd91d97d1f74913a626f01e880cee) Change-Id: I1000221423c16c356bb6301e55f726db01c3f209
Diffstat (limited to 'libc')
-rw-r--r--libc/bionic/dlmalloc.h12
-rw-r--r--libc/bionic/ndk_cruft.cpp25
2 files changed, 31 insertions, 6 deletions
diff --git a/libc/bionic/dlmalloc.h b/libc/bionic/dlmalloc.h
index 2f53c1bc4..054bd4f2f 100644
--- a/libc/bionic/dlmalloc.h
+++ b/libc/bionic/dlmalloc.h
@@ -44,11 +44,13 @@
#define dlmalloc dlmalloc_real
#endif
-/* Export two symbols used by the VM. */
-__BEGIN_DECLS
-int dlmalloc_trim(size_t) __LIBC_ABI_PUBLIC__;
-void dlmalloc_inspect_all(void (*handler)(void*, void*, size_t, void*), void*) __LIBC_ABI_PUBLIC__;
-__END_DECLS
+/* These two symbols are exported on devices that use dlmalloc.
+ * In order to be consistent across all devices, they will
+ * be exported everywhere. Move the real symbols out of the way
+ * so that ndk_cruft.cpp can export these symbols.
+ */
+#define dlmalloc_inspect_all dlmalloc_inspect_all_real
+#define dlmalloc_trim dlmalloc_trim_real
/* Include the proper definitions. */
#include "../upstream-dlmalloc/malloc.h"
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index 8b34495f8..b29968480 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -340,7 +340,7 @@ extern "C" pid_t __pthread_gettid(pthread_t t) {
return pthread_gettid_np(t);
}
-// Older versions of appportable used dlmalloc directly instead of malloc,
+// Older versions of apportable used dlmalloc directly instead of malloc,
// so export this compatibility shim that simply calls malloc.
extern "C" void* dlmalloc(size_t size) {
return malloc(size);
@@ -369,3 +369,26 @@ extern "C" void endusershell() { }
// This is never implemented in bionic, only needed for ABI compatibility with the NDK.
extern "C" void endpwent() { }
+
+// Since dlmalloc_inspect_all and dlmalloc_trim are exported for systems
+// that use dlmalloc, be consistent and export them everywhere.
+#if defined(USE_JEMALLOC)
+extern "C" void dlmalloc_inspect_all(void (*)(void*, void*, size_t, void*), void*) {
+}
+#else
+extern "C" void dlmalloc_inspect_all_real(void (*)(void*, void*, size_t, void*), void*);
+extern "C" void dlmalloc_inspect_all(void (*handler)(void*, void*, size_t, void*), void* arg) {
+ dlmalloc_inspect_all_real(handler, arg);
+}
+#endif
+
+#if defined(USE_JEMALLOC)
+extern "C" int dlmalloc_trim(size_t) {
+ return 0;
+}
+#else
+extern "C" int dlmalloc_trim_real(size_t);
+extern "C" int dlmalloc_trim(size_t pad) {
+ return dlmalloc_trim_real(pad);
+}
+#endif