mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
nic_router: alloc specific bits at bit allocator
Method to allocate specific bits at a Bit_allocator_dynamic Ref #2670
This commit is contained in:
parent
03062b83b6
commit
119b9f9c2c
@ -179,6 +179,7 @@ class Genode::Bit_allocator_dynamic
|
||||
public:
|
||||
|
||||
struct Out_of_indices : Exception { };
|
||||
struct Range_conflict : Exception { };
|
||||
|
||||
addr_t alloc(size_t const num_log2 = 0)
|
||||
{
|
||||
@ -206,6 +207,17 @@ class Genode::Bit_allocator_dynamic
|
||||
throw Out_of_indices();
|
||||
}
|
||||
|
||||
void alloc_addr(addr_t const bit_start, size_t const num_log2 = 0)
|
||||
{
|
||||
addr_t const step = 1UL << num_log2;
|
||||
if (_array.get(bit_start, step))
|
||||
throw Range_conflict();
|
||||
|
||||
_array.set(bit_start, step);
|
||||
_next = bit_start + step;
|
||||
return;
|
||||
}
|
||||
|
||||
void free(addr_t const bit_start, size_t const num_log2 = 0)
|
||||
{
|
||||
_array.clear(bit_start, 1UL << num_log2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user