mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-13 04:38:20 +00:00
committed by
Christian Helmuth
parent
6552d47e60
commit
b856bfdfcd
@ -25,8 +25,17 @@ class Genode::Bit_allocator
|
||||
{
|
||||
protected:
|
||||
|
||||
addr_t _next;
|
||||
Bit_array<BITS> _array;
|
||||
enum {
|
||||
BITS_PER_BYTE = 8UL,
|
||||
BITS_PER_WORD = sizeof(addr_t) * BITS_PER_BYTE,
|
||||
BITS_ALIGNED = (BITS + BITS_PER_WORD - 1UL)
|
||||
& ~(BITS_PER_WORD - 1UL),
|
||||
};
|
||||
|
||||
using Array = Bit_array<BITS_ALIGNED>;
|
||||
|
||||
addr_t _next;
|
||||
Array _array;
|
||||
|
||||
/**
|
||||
* Reserve consecutive number of bits
|
||||
@ -44,7 +53,8 @@ class Genode::Bit_allocator
|
||||
|
||||
class Out_of_indices : Exception {};
|
||||
|
||||
Bit_allocator() : _next(0) { }
|
||||
Bit_allocator() : _next(0) {
|
||||
_reserve(BITS, BITS_ALIGNED - BITS); }
|
||||
|
||||
addr_t alloc(size_t const num_log2 = 0)
|
||||
{
|
||||
@ -62,7 +72,7 @@ class Genode::Bit_allocator
|
||||
_next = i + step;
|
||||
return i;
|
||||
}
|
||||
} catch (typename Bit_array<BITS>::Invalid_index_access) { }
|
||||
} catch (typename Array::Invalid_index_access) { }
|
||||
|
||||
max = _next;
|
||||
_next = 0;
|
||||
|
Reference in New Issue
Block a user