implement Android malloc_disable/malloc_enable API

pull/50/head
Daniel Micay 2018-09-06 14:17:06 -04:00
parent 3a532b17dc
commit e891b40588
1 changed files with 5 additions and 5 deletions

View File

@ -557,14 +557,14 @@ static void regions_delete(struct region_info *region) {
} }
} }
static void pre_fork(void) { static void full_lock(void) {
pthread_mutex_lock(&regions_lock); pthread_mutex_lock(&regions_lock);
for (unsigned class = 0; class < N_SIZE_CLASSES; class++) { for (unsigned class = 0; class < N_SIZE_CLASSES; class++) {
pthread_mutex_lock(&size_class_metadata[class].mutex); pthread_mutex_lock(&size_class_metadata[class].mutex);
} }
} }
static void post_fork_parent(void) { static void full_unlock(void) {
pthread_mutex_unlock(&regions_lock); pthread_mutex_unlock(&regions_lock);
for (unsigned class = 0; class < N_SIZE_CLASSES; class++) { for (unsigned class = 0; class < N_SIZE_CLASSES; class++) {
pthread_mutex_unlock(&size_class_metadata[class].mutex); pthread_mutex_unlock(&size_class_metadata[class].mutex);
@ -605,7 +605,7 @@ COLD static void init_slow_path(void) {
return; return;
} }
if (pthread_atfork(pre_fork, post_fork_parent, post_fork_child)) { if (pthread_atfork(full_lock, full_unlock, post_fork_child)) {
fatal_error("pthread_atfork failed"); fatal_error("pthread_atfork failed");
} }
@ -1090,10 +1090,10 @@ COLD EXPORT int h_iterate(UNUSED uintptr_t base, UNUSED size_t size,
} }
COLD EXPORT void h_malloc_disable(void) { COLD EXPORT void h_malloc_disable(void) {
fatal_error("not implemented"); full_lock();
} }
COLD EXPORT void h_malloc_enable(void) { COLD EXPORT void h_malloc_enable(void) {
fatal_error("not implemented"); full_unlock();
} }
#endif #endif