Changed the makefile system to autoconf/automake.
[cacao.git] / mm / allocator.h
1 /*
2  * cacao/mm/allocator.h
3  * $Id: allocator.h 115 1999-01-20 01:52:45Z phil $
4  */
5
6 #ifndef __allocator_h_
7 #define __allocator_h_
8
9 #include "bitmap2.h"
10
11 #ifndef YES
12 #       define YES              1
13 #endif
14 #ifndef NO
15 #       define NO           0
16 #endif
17
18 #define COUNT_ALLOCATIONS       NO
19
20 #define FASTER_FAIL     NO
21
22 #define PRINTF                          NO
23 #define SMALL_TABLES            YES
24 #define MSB_TO_LSB_SEARCH       NO
25
26 #define ADDRESS 64
27 //#define ADDRESS 32
28
29 #if ADDRESS == 64
30 #  define SIZE  unsigned long long
31 #else
32 #  define SIZE  unsigned long
33 #endif
34
35 #undef ALIGN
36 #define ALIGN   3       /* 64bit alignment */
37 //#define ALIGN 2       /* 32bit allignment */
38
39 #define EXACT_TOP_BIT  8    /* usually somewhere in the range [8..10]
40                                                            the largest exact chunk is 1 << EXACT_TOP_BIT bytes large &
41                                                            there'll be 1 << (EXACT_TOP_BIT - ALIGN) exact bins 
42                                                            
43                                                            Supported values are between 0 and 16...
44                                                            ...any value less than ALIGN mean "no exact bins"...
45                                                            ...actually, there'll be a very small first bin containing
46                                                            chunks exactly allocationblock sized.
47                                    
48                                                            Setting EXACT_TOP_BIT to anything less than (SUBBIT + ALIGN)
49                                                            doesn't really make sense either, but is possible...
50                                                         */
51
52 /* check EXACT_TOP_BIT early ... */
53
54 #if (EXACT_TOP_BIT > 16)
55 #       warning "EXACT_TOP_BIT > 16: bad idea & unsupported value; using 16"
56 #   undef EXACT_TOP_BIT
57 #       define EXACT_TOP_BIT 16
58 #endif
59
60
61 #if EXACT_TOP_BIT >= ALIGN
62 # define EXACT  (EXACT_TOP_BIT - ALIGN)
63 #else
64 # define EXACT  0
65 #endif
66 #define LARGE   (ADDRESS - EXACT - ALIGN)
67
68 #define SUBBIT  0       /* set this to 0 to disable the additional hashing for the large bins;
69                                            otherwise, good values are in the range [3..5]; the best setting for
70                                            a particular application is highly dependent on the VM's heap-size 
71                                            and the cache sizes. Remember, the allocator will create 
72                                            (LARGE << SUBBIT) sorted bins. In the case of a 64bit machine with
73                                            256 exact bins (EXACT_TOP_BIT == 9), a SUBBIT setting of 3 will
74                                            create 64-9=55 bins consisting of 2^3=8 subbins; thus, a pointer
75                                            array with 55*8 fields will be allocated, eating up 3520 bytes. */
76
77 /* check config */
78
79 #if (SUBBIT < 0)
80 #       warning "SUBBIT < 0: using 0."
81 #       undef SUBBIT
82 #       define SUBBIT   0
83 #endif
84
85 #if (SUBBIT > (EXACT_TOP_BIT - ALIGN))
86 #  warning "SUBBIT > (EXACT_TOP_BIT - ALIGN): wasting subbins!"
87 #endif
88
89 #if (((LARGE << SUBBIT) << ALIGN) > (1 << 16))
90 #  warning "((LARGE << SUBBIT) << ALIGN) > 64K: are you sure you want it this big??" 
91 #endif
92
93 typedef struct freeblock_exact {
94         struct freeblock_exact* next;
95 } FREE_EXACT;
96
97 typedef struct freeblock_large {
98         SIZE                                    size;
99         struct freeblock_large* next;
100 } FREE_LARGE;
101
102
103 void allocator_free(void* chunk, SIZE size);
104 void* allocator_alloc(SIZE size);
105 void allocator_init(void);
106 void allocator_reset(void);
107
108 void allocator_mark_free_kludge(BITBLOCK* bitmap);
109
110 /* unsigned char find_highest(SIZE bits); */
111
112 #endif /* !defined(__allocator_h_) */
113
114
115 /*
116  * These are local overrides for various environment variables in Emacs.
117  * Please do not remove this and leave it at the end of the file, where
118  * Emacs will automagically detect them.
119  * ---------------------------------------------------------------------
120  * Local variables:
121  * mode: c
122  * indent-tabs-mode: t
123  * c-basic-offset: 4
124  * tab-width: 4
125  * End:
126  */
127