30 namespace L4Re {
namespace Util {
35 template<
typename COUNTER =
unsigned char >
41 static Type nil() {
return 0; }
43 void free() { _cnt = 0; }
44 bool is_free()
const {
return _cnt == 0; }
45 void inc() { ++_cnt; }
46 Type dec() {
return --_cnt; }
47 void alloc() { _cnt = 1; }
74 template <
typename COUNTERTYPE = L4Re::Util::Counter<
unsigned char> >
79 typedef COUNTERTYPE Counter;
89 template <
unsigned COUNT>
90 struct Counter_storage
92 COUNTERTYPE _buf[COUNT];
93 typedef COUNTERTYPE Buf_type[COUNT];
94 enum { Size = COUNT };
105 : _items(0), _free_hint(0), _bias(0), _capacity(0)
121 void setup(
void *m,
long capacity,
long bias)
throw()
123 _items = (Counter*)m;
124 _capacity = capacity;
137 if (_free_hint >= _capacity)
140 for (
long i = _free_hint; i < _capacity; ++i)
142 if (_items[i].is_free())
155 template <
typename T>
255 if (_items[c].dec() == Counter::nil())
274 return _capacity + _bias - 1;
long last()
Return highest capability id managed by this allocator.
Low-level assert implementation.
Invalid capability selector.
l4_msgtag_t l4_task_unmap(l4_cap_idx_t task, l4_fpage_t fpage, l4_umword_t map_mask) L4_NOTHROW
Revoke rights from the task.
unsigned l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is a valid selector.
unsigned long l4_cap_idx_t
L4 Capability selector Type.
void take(L4::Cap< void > cap)
Increase the reference counter for the capability.
Common task related definitions.
L4::Cap< T > alloc()
Allocate a new capability slot.
void setup(void *m, long capacity, long bias)
Set up the backing memory for the allocator and the area of managed capability slots.
Flag to tell the unmap operation to unmap all child mappings including the mapping in the invoked tas...
bool free(L4::Cap< void > cap, l4_cap_idx_t task=L4_INVALID_CAP, unsigned unmap_flags=L4_FP_ALL_SPACES)
Free the capability.
bool release(L4::Cap< void > cap, l4_cap_idx_t task=L4_INVALID_CAP, unsigned unmap_flags=L4_FP_ALL_SPACES)
Decrease the reference counter for a capability.
#define l4_assert(expr)
Low-level assert.
Counting_cap_alloc()
Create a new, empty allocator.
L4::Cap< void > alloc()
Allocate a new capability slot.
Internal reference-counting cap allocator.
Invalid capability selector.
Cap< T > cap_cast(Cap< F > const &c)
static_cast for capabilities.
Counter for Counting_cap_alloc with variable data width.
C++ interface for capabilities.