base: Align heap/slab allocation to machine word size

required by riscv

related to #1880
This commit is contained in:
Sebastian Sumpf 2015-08-30 10:32:05 +02:00 committed by Josef Söntgen
parent 6d1d8afa57
commit bfe5208e0e
3 changed files with 4 additions and 4 deletions

View File

@ -40,7 +40,7 @@ class Genode::Slab_block
enum { FREE, USED };
Slab *_slab; /* back reference to slab allocator */
unsigned _avail; /* free entries of this block */
size_t _avail; /* free entries of this block */
/*
* Each slab block consists of three areas, a fixed-size header

View File

@ -45,7 +45,7 @@ Slab_entry *Slab_block::slab_entry(int idx)
* of 'num_elem' bytes. We align the first slot to a four-aligned
* address.
*/
return (Slab_entry *)&_data[align_addr(_slab->num_elem(), 2)
return (Slab_entry *)&_data[align_addr(_slab->num_elem(), log2(sizeof(addr_t)))
+ _slab->entry_size()*idx];
}

View File

@ -87,7 +87,7 @@ Heap::Dataspace *Heap::_allocate_dataspace(size_t size, bool enforce_separate_me
_alloc.add_range((addr_t)ds_addr, size);
/* allocate the Dataspace structure */
if (_alloc.alloc_aligned(sizeof(Heap::Dataspace), &ds_meta_data_addr, 2).is_error()) {
if (_alloc.alloc_aligned(sizeof(Heap::Dataspace), &ds_meta_data_addr, log2(sizeof(addr_t))).is_error()) {
PWRN("could not allocate dataspace meta data - this should never happen");
return 0;
}
@ -104,7 +104,7 @@ Heap::Dataspace *Heap::_allocate_dataspace(size_t size, bool enforce_separate_me
bool Heap::_try_local_alloc(size_t size, void **out_addr)
{
if (_alloc.alloc_aligned(size, out_addr, 2).is_error())
if (_alloc.alloc_aligned(size, out_addr, log2(sizeof(addr_t))).is_error())
return false;
_quota_used += size;