add stubs for Android extensions

This commit is contained in:
Daniel Micay 2018-09-02 05:08:45 -04:00
parent 2dd2471b4a
commit 7e088dc870
3 changed files with 46 additions and 2 deletions

View File

@ -1,5 +1,5 @@
CPPFLAGS := -D_GNU_SOURCE
CFLAGS := -std=c11 -Wall -Wextra -O2 -flto -fPIC -fvisibility=hidden -fno-plt
CFLAGS := -std=c11 -Wall -Wextra -Wmissing-prototypes -O2 -flto -fPIC -fvisibility=hidden -fno-plt
LDFLAGS := -Wl,-z,defs,-z,relro,-z,now,-z,nodlopen,-z,text
OBJECTS := chacha.o malloc.o memory.o pages.o random.o util.o

View File

@ -978,7 +978,7 @@ EXPORT int h_malloc_trim(UNUSED size_t pad) {
EXPORT void h_malloc_stats(void) {}
EXPORT struct mallinfo h_mallinfo(void) {
return (struct mallinfo){0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
return (struct mallinfo){0};
}
EXPORT int h_malloc_info(UNUSED int options, UNUSED FILE *fp) {
@ -993,3 +993,35 @@ COLD EXPORT void *h_malloc_get_state(void) {
COLD EXPORT int h_malloc_set_state(UNUSED void *state) {
return -2;
}
#ifdef __ANDROID__
EXPORT size_t __mallinfo_narenas(void) {
return 0;
}
EXPORT size_t __mallinfo_nbins(void) {
return 0;
}
EXPORT struct mallinfo __mallinfo_arena_info(UNUSED size_t arena) {
return (struct mallinfo){0};
}
EXPORT struct mallinfo __mallinfo_bin_info(UNUSED size_t arena, UNUSED size_t bin) {
return (struct mallinfo){0};
}
COLD EXPORT int h_iterate(UNUSED uintptr_t base, UNUSED size_t size,
UNUSED void (*callback)(uintptr_t ptr, size_t size, void *arg),
UNUSED void *arg) {
fatal_error("not implemented");
}
COLD EXPORT void h_malloc_disable(void) {
fatal_error("not implemented");
}
COLD EXPORT void h_malloc_enable(void) {
fatal_error("not implemented");
}
#endif

View File

@ -52,6 +52,18 @@ void *h_valloc(size_t size);
void *h_pvalloc(size_t size);
void h_cfree(void *ptr);
// Android extensions
#ifdef __ANDROID__
size_t __mallinfo_narenas(void);
size_t __mallinfo_nbins(void);
struct mallinfo __mallinfo_arena_info(size_t arena);
struct mallinfo __mallinfo_bin_info(size_t arena, size_t bin);
int h_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t ptr, size_t size, void *arg),
void *arg);
void h_malloc_disable(void);
void h_malloc_enable(void);
#endif
// custom extensions
// return an upper bound on object size for any pointer based on malloc metadata