chiark / gitweb /
[PATCH] sync up with the 0.84 version of klibc
[elogind.git] / klibc / klibc / malloc.h
1 /*
2  * malloc.h
3  *
4  * Internals for the memory allocator
5  */
6
7 #include <stdint.h>
8 #include <stddef.h>
9
10 /*
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.
13  */
14 #define MALLOC_CHUNK_SIZE       65536
15 #define MALLOC_CHUNK_MASK       (MALLOC_CHUNK_SIZE-1)
16
17 /*
18  * This structure should be a power of two.  This becomes the
19  * alignment unit.
20  */
21 struct free_arena_header;
22
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;
27 };
28
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
39
40 #define ARENA_SIZE_MASK (~(sizeof(struct arena_header)-1))
41
42 /*
43  * This structure should be no more than twice the size of the
44  * previous structure.
45  */
46 struct free_arena_header {
47   struct arena_header a;
48   struct free_arena_header *next_free, *prev_free;
49 };
50
51 extern struct free_arena_header __malloc_head;