From 34952fe5de44a833370cbe87b63fb8eec61466d7 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 11 Nov 2020 13:08:42 -0500 Subject: convert malloc use under libc-internal locks to use internal allocator this change lifts undocumented restrictions on calls by replacement mallocs to libc functions that might take these locks, and sets the stage for lifting restrictions on the child execution environment after multithreaded fork. care is taken to #define macros to replace all four functions (malloc, calloc, realloc, free) even if not all of them will be used, using an undefined symbol name for the ones intended not to be used so that any inadvertent future use will be caught at compile time rather than directed to the wrong implementation. --- src/thread/sem_open.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/thread') diff --git a/src/thread/sem_open.c b/src/thread/sem_open.c index 6fb0c5b2..dad8f177 100644 --- a/src/thread/sem_open.c +++ b/src/thread/sem_open.c @@ -13,6 +13,11 @@ #include #include "lock.h" +#define malloc __libc_malloc +#define calloc __libc_calloc +#define realloc undef +#define free undef + static struct { ino_t ino; sem_t *sem; -- cgit v1.2.1