Backing this one out since the counterpart needs to be sent upstream.
This reverts commit 5ee320dd35fafc11eaf90c62198e08c6670e35b4.
Change-Id: I1a9c6b06c3aca595f01c629f7649be743dc48e77
diff --git a/libc/bionic/malloc_debug_common.cpp b/libc/bionic/malloc_debug_common.cpp
index cbca160..6677c22 100644
--- a/libc/bionic/malloc_debug_common.cpp
+++ b/libc/bionic/malloc_debug_common.cpp
@@ -61,13 +61,9 @@
Malloc(malloc_usable_size),
Malloc(memalign),
Malloc(posix_memalign),
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
Malloc(pvalloc),
-#endif
Malloc(realloc),
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
Malloc(valloc),
-#endif
};
// Selector of dispatch table to use for dispatching malloc calls.
@@ -262,21 +258,17 @@
return __libc_malloc_dispatch->posix_memalign(memptr, alignment, size);
}
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
extern "C" void* pvalloc(size_t bytes) {
return __libc_malloc_dispatch->pvalloc(bytes);
}
-#endif
extern "C" void* realloc(void* oldMem, size_t bytes) {
return __libc_malloc_dispatch->realloc(oldMem, bytes);
}
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
extern "C" void* valloc(size_t bytes) {
return __libc_malloc_dispatch->valloc(bytes);
}
-#endif
// We implement malloc debugging only in libc.so, so the code below
// must be excluded if we compile this file for static libc.a
@@ -307,13 +299,9 @@
InitMallocFunction<MallocDebugMallocUsableSize>(malloc_impl_handler, &table->malloc_usable_size, prefix, "malloc_usable_size");
InitMallocFunction<MallocDebugMemalign>(malloc_impl_handler, &table->memalign, prefix, "memalign");
InitMallocFunction<MallocDebugPosixMemalign>(malloc_impl_handler, &table->posix_memalign, prefix, "posix_memalign");
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
InitMallocFunction<MallocDebugPvalloc>(malloc_impl_handler, &table->pvalloc, prefix, "pvalloc");
-#endif
InitMallocFunction<MallocDebugRealloc>(malloc_impl_handler, &table->realloc, prefix, "realloc");
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
InitMallocFunction<MallocDebugValloc>(malloc_impl_handler, &table->valloc, prefix, "valloc");
-#endif
}
// Initializes memory allocation framework once per process.
@@ -459,14 +447,9 @@
(malloc_dispatch_table.malloc_usable_size == NULL) ||
(malloc_dispatch_table.memalign == NULL) ||
(malloc_dispatch_table.posix_memalign == NULL) ||
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
(malloc_dispatch_table.pvalloc == NULL) ||
-#endif
- (malloc_dispatch_table.realloc == NULL)
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
- || (malloc_dispatch_table.valloc == NULL)
-#endif
- ) {
+ (malloc_dispatch_table.realloc == NULL) ||
+ (malloc_dispatch_table.valloc == NULL)) {
error_log("%s: some symbols for libc.debug.malloc level %d were not found (see above)",
getprogname(), g_malloc_debug_level);
dlclose(malloc_impl_handle);
diff --git a/libc/bionic/malloc_debug_common.h b/libc/bionic/malloc_debug_common.h
index a0f9972..8052a17 100644
--- a/libc/bionic/malloc_debug_common.h
+++ b/libc/bionic/malloc_debug_common.h
@@ -61,12 +61,6 @@
#define Malloc(function) dl ## function
#endif
-// valloc(3) and pvalloc(3) were removed from POSIX 2004. We do not include them
-// for LP64, but the symbols remain in LP32 for binary compatibility.
-#ifndef __LP64__
-#define HAVE_DEPRECATED_MALLOC_FUNCS 1
-#endif
-
// =============================================================================
// Structures
// =============================================================================
@@ -96,14 +90,9 @@
typedef size_t (*MallocDebugMallocUsableSize)(const void*);
typedef void* (*MallocDebugMemalign)(size_t, size_t);
typedef int (*MallocDebugPosixMemalign)(void**, size_t, size_t);
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
typedef void* (*MallocDebugPvalloc)(size_t);
-#endif
typedef void* (*MallocDebugRealloc)(void*, size_t);
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
typedef void* (*MallocDebugValloc)(size_t);
-#endif
-
struct MallocDebug {
MallocDebugCalloc calloc;
MallocDebugFree free;
@@ -112,13 +101,9 @@
MallocDebugMallocUsableSize malloc_usable_size;
MallocDebugMemalign memalign;
MallocDebugPosixMemalign posix_memalign;
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
MallocDebugPvalloc pvalloc;
-#endif
MallocDebugRealloc realloc;
-#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
MallocDebugValloc valloc;
-#endif
};
typedef bool (*MallocDebugInit)(HashTable*);
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index e6ea276..9a4e324 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -35,6 +35,9 @@
extern void* memalign(size_t alignment, size_t byte_count) __mallocfunc __wur __attribute__((alloc_size(2)));
extern size_t malloc_usable_size(const void* p);
+extern void* valloc(size_t byte_count) __mallocfunc __wur __attribute__((alloc_size(1)));
+extern void* pvalloc(size_t byte_count) __mallocfunc __wur __attribute__((alloc_size(1)));
+
#ifndef STRUCT_MALLINFO_DECLARED
#define STRUCT_MALLINFO_DECLARED 1
struct mallinfo {