libc.h was intended to be a header for access to global libc state and related interfaces, but ended up included all over the place because it was the way to get the weak_alias macro. most of the inclusions removed here are places where weak_alias was needed. a few were recently introduced for hidden. some go all the way back to when libc.h defined CANCELPT_BEGIN and _END, and all (wrongly implemented) cancellation points had to include it. remaining spurious users are mostly callers of the LOCK/UNLOCK macros and files that use the LFS64 macro to define the awful *64 aliases. in a few places, new inclusion of libc.h is added because several internal headers no longer implicitly include libc.h. declarations for __lockfile and __unlockfile are moved from libc.h to stdio_impl.h so that the latter does not need libc.h. putting them in libc.h made no sense at all, since the macros in stdio_impl.h are needed to use them correctly anyway.
47 lines
1.1 KiB
C
47 lines
1.1 KiB
C
#ifndef MALLOC_IMPL_H
|
|
#define MALLOC_IMPL_H
|
|
|
|
#include <sys/mman.h>
|
|
|
|
hidden void *__expand_heap(size_t *);
|
|
|
|
hidden void __malloc_donate(char *, char *);
|
|
|
|
hidden void *__memalign(size_t, size_t);
|
|
|
|
struct chunk {
|
|
size_t psize, csize;
|
|
struct chunk *next, *prev;
|
|
};
|
|
|
|
struct bin {
|
|
volatile int lock[2];
|
|
struct chunk *head;
|
|
struct chunk *tail;
|
|
};
|
|
|
|
#define SIZE_ALIGN (4*sizeof(size_t))
|
|
#define SIZE_MASK (-SIZE_ALIGN)
|
|
#define OVERHEAD (2*sizeof(size_t))
|
|
#define MMAP_THRESHOLD (0x1c00*SIZE_ALIGN)
|
|
#define DONTCARE 16
|
|
#define RECLAIM 163840
|
|
|
|
#define CHUNK_SIZE(c) ((c)->csize & -2)
|
|
#define CHUNK_PSIZE(c) ((c)->psize & -2)
|
|
#define PREV_CHUNK(c) ((struct chunk *)((char *)(c) - CHUNK_PSIZE(c)))
|
|
#define NEXT_CHUNK(c) ((struct chunk *)((char *)(c) + CHUNK_SIZE(c)))
|
|
#define MEM_TO_CHUNK(p) (struct chunk *)((char *)(p) - OVERHEAD)
|
|
#define CHUNK_TO_MEM(c) (void *)((char *)(c) + OVERHEAD)
|
|
#define BIN_TO_CHUNK(i) (MEM_TO_CHUNK(&mal.bins[i].head))
|
|
|
|
#define C_INUSE ((size_t)1)
|
|
|
|
#define IS_MMAPPED(c) !((c)->csize & (C_INUSE))
|
|
|
|
hidden void __bin_chunk(struct chunk *);
|
|
|
|
hidden extern int __malloc_replaced;
|
|
|
|
#endif
|