bionic/linker: make the buddy allocator compute max_order on its own
Signed-off-by: Iliyan Malchev <malchev@google.com>
This commit is contained in:
@@ -41,9 +41,16 @@
|
|||||||
#define BA_START_ADDR(index) (BA_OFFSET(index) + ba->base)
|
#define BA_START_ADDR(index) (BA_OFFSET(index) + ba->base)
|
||||||
#define BA_LEN(index) ((1 << BA_ORDER(index)) * ba->min_alloc)
|
#define BA_LEN(index) ((1 << BA_ORDER(index)) * ba->min_alloc)
|
||||||
|
|
||||||
|
static unsigned long ba_order(struct ba *ba, unsigned long len);
|
||||||
|
|
||||||
void ba_init(struct ba *ba)
|
void ba_init(struct ba *ba)
|
||||||
{
|
{
|
||||||
int i, index = 0;
|
int i, index = 0;
|
||||||
|
|
||||||
|
unsigned long max_order = ba_order(ba, ba->size);
|
||||||
|
if (ba->max_order == 0 || ba->max_order > max_order)
|
||||||
|
ba->max_order = max_order;
|
||||||
|
|
||||||
for (i = sizeof(ba->num_entries) * 8 - 1; i >= 0; i--) {
|
for (i = sizeof(ba->num_entries) * 8 - 1; i >= 0; i--) {
|
||||||
if (ba->num_entries & 1<<i) {
|
if (ba->num_entries & 1<<i) {
|
||||||
BA_ORDER(index) = i;
|
BA_ORDER(index) = i;
|
||||||
|
@@ -98,7 +98,7 @@ static struct ba ba_prelink = {
|
|||||||
.base = LIBBASE,
|
.base = LIBBASE,
|
||||||
.size = LIBLAST - LIBBASE,
|
.size = LIBLAST - LIBBASE,
|
||||||
.min_alloc = LIBINC,
|
.min_alloc = LIBINC,
|
||||||
.max_order = 128,
|
/* max_order will be determined automatically */
|
||||||
.bitmap = ba_prelink_bitmap,
|
.bitmap = ba_prelink_bitmap,
|
||||||
.num_entries = sizeof(ba_prelink_bitmap)/sizeof(ba_prelink_bitmap[0]),
|
.num_entries = sizeof(ba_prelink_bitmap)/sizeof(ba_prelink_bitmap[0]),
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user