hdt: Removing debugging message
[hdt-cyring.git] / memdump / malloc.h
blob67bf217c58c14b8e32d3097f9d7f0faebda171b8
1 /*
2 * malloc.h
4 * Internals for the memory allocator
5 */
7 #include <stdint.h>
8 #include <stddef.h>
11 * This is the minimum chunk size we will ask the kernel for; this should
12 * be a multiple of the page size on all architectures.
14 #define MALLOC_CHUNK_SIZE 65536
15 #define MALLOC_CHUNK_MASK (MALLOC_CHUNK_SIZE-1)
18 * This structure should be a power of two. This becomes the
19 * alignment unit.
21 struct free_arena_header;
23 struct arena_header {
24 size_t type;
25 size_t size; /* Also gives the location of the next entry */
26 struct free_arena_header *next, *prev;
29 #ifdef DEBUG_MALLOC
30 #define ARENA_TYPE_USED 0x64e69c70
31 #define ARENA_TYPE_FREE 0x012d610a
32 #define ARENA_TYPE_HEAD 0x971676b5
33 #define ARENA_TYPE_DEAD 0xeeeeeeee
34 #else
35 #define ARENA_TYPE_USED 0
36 #define ARENA_TYPE_FREE 1
37 #define ARENA_TYPE_HEAD 2
38 #endif
40 #define ARENA_SIZE_MASK (sizeof(struct arena_header)-1)
42 #define ARENA_ALIGN_UP(p) ((char *)(((uintptr_t)(p) + ARENA_SIZE_MASK) & ~ARENA_SIZE_MASK))
43 #define ARENA_ALIGN_DOWN(p) ((char *)((uintptr_t)(p) & ~ARENA_SIZE_MASK))
46 * This structure should be no more than twice the size of the
47 * previous structure.
49 struct free_arena_header {
50 struct arena_header a;
51 struct free_arena_header *next_free, *prev_free;
54 extern struct free_arena_header __malloc_head;