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.
This commit is contained in:
Rich Felker
2020-11-11 13:31:50 -05:00
parent 8d37958d58
commit 34952fe5de
8 changed files with 41 additions and 0 deletions
+5
View File
@@ -23,6 +23,11 @@
#include "libc.h"
#include "dynlink.h"
#define malloc __libc_malloc
#define calloc __libc_calloc
#define realloc __libc_realloc
#define free __libc_free
static void error(const char *, ...);
#define MAXP2(a,b) (-(-(a)&-(b)))