this cleans up what had become widespread direct inline use of "GNU C"
style attributes directly in the source, and lowers the barrier to
increased use of hidden visibility, which will be useful to recovering
some of the efficiency lost when the protected visibility hack was
dropped in commit dc2f368e56, especially
on archs where the PLT ABI is costly.
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
#ifndef MALLOC_IMPL_H
|
|
#define MALLOC_IMPL_H
|
|
|
|
#include "libc.h"
|
|
|
|
void *__mmap(void *, size_t, int, int, int, off_t);
|
|
int __munmap(void *, size_t);
|
|
void *__mremap(void *, size_t, size_t, int, ...);
|
|
int __madvise(void *, size_t, int);
|
|
|
|
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
|