mirror of
https://git.musl-libc.org/git/musl
synced 2025-01-21 21:52:04 +03:00
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:
parent
8d37958d58
commit
34952fe5de
@ -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)))
|
||||
|
@ -11,6 +11,11 @@
|
||||
#include "pthread_impl.h"
|
||||
#include "aio_impl.h"
|
||||
|
||||
#define malloc __libc_malloc
|
||||
#define calloc __libc_calloc
|
||||
#define realloc __libc_realloc
|
||||
#define free __libc_free
|
||||
|
||||
/* The following is a threads-based implementation of AIO with minimal
|
||||
* dependence on implementation details. Most synchronization is
|
||||
* performed with pthread primitives, but atomics and futex operations
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include "libc.h"
|
||||
#include "lock.h"
|
||||
|
||||
#define malloc __libc_malloc
|
||||
#define calloc __libc_calloc
|
||||
#define realloc undef
|
||||
#define free undef
|
||||
|
||||
/* Ensure that at least 32 atexit handlers can be registered without malloc */
|
||||
#define COUNT 32
|
||||
|
||||
|
@ -5,6 +5,11 @@
|
||||
#include "dynlink.h"
|
||||
#include "lock.h"
|
||||
|
||||
#define malloc __libc_malloc
|
||||
#define calloc __libc_calloc
|
||||
#define realloc __libc_realloc
|
||||
#define free __libc_free
|
||||
|
||||
char *dlerror()
|
||||
{
|
||||
pthread_t self = __pthread_self();
|
||||
|
@ -11,6 +11,11 @@
|
||||
#include "pleval.h"
|
||||
#include "lock.h"
|
||||
|
||||
#define malloc __libc_malloc
|
||||
#define calloc __libc_calloc
|
||||
#define realloc undef
|
||||
#define free undef
|
||||
|
||||
struct binding {
|
||||
struct binding *next;
|
||||
int dirlen;
|
||||
|
@ -1,10 +1,16 @@
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <stdlib.h>
|
||||
#include "locale_impl.h"
|
||||
#include "libc.h"
|
||||
#include "lock.h"
|
||||
|
||||
#define malloc __libc_malloc
|
||||
#define calloc undef
|
||||
#define realloc undef
|
||||
#define free undef
|
||||
|
||||
const char *__lctrans_impl(const char *msg, const struct __locale_map *lm)
|
||||
{
|
||||
const char *trans = 0;
|
||||
|
@ -13,6 +13,11 @@
|
||||
#include <pthread.h>
|
||||
#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;
|
||||
|
@ -7,6 +7,11 @@
|
||||
#include "libc.h"
|
||||
#include "lock.h"
|
||||
|
||||
#define malloc __libc_malloc
|
||||
#define calloc undef
|
||||
#define realloc undef
|
||||
#define free undef
|
||||
|
||||
long __timezone = 0;
|
||||
int __daylight = 0;
|
||||
char *__tzname[2] = { 0, 0 };
|
||||
|
Loading…
Reference in New Issue
Block a user