libc: Use own AllocatorLock, not frigg:TicketLock
This commit is contained in:
parent
9fa2f03670
commit
988a5c6f75
|
@ -2,10 +2,29 @@
|
|||
#ifndef MLIBC_FRIGG_ALLOC
|
||||
#define MLIBC_FRIGG_ALLOC
|
||||
|
||||
#include <frigg/atomic.hpp>
|
||||
#include <frigg/memory.hpp>
|
||||
#include <frg/slab.hpp>
|
||||
|
||||
struct AllocatorLock {
|
||||
AllocatorLock()
|
||||
: _futex{0} { }
|
||||
|
||||
AllocatorLock(const AllocatorLock &) = delete;
|
||||
|
||||
AllocatorLock &operator= (const AllocatorLock &) = delete;
|
||||
|
||||
void lock() {
|
||||
if(__atomic_exchange_n(&_futex, 1, __ATOMIC_ACQUIRE))
|
||||
__ensure(!"Implement AllocatorLock slow path");
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
__atomic_store_n(&_futex, 0, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
private:
|
||||
int _futex;
|
||||
};
|
||||
|
||||
struct VirtualAllocator {
|
||||
public:
|
||||
uintptr_t map(size_t length);
|
||||
|
@ -13,7 +32,7 @@ public:
|
|||
void unmap(uintptr_t address, size_t length);
|
||||
};
|
||||
|
||||
typedef frg::slab_allocator<VirtualAllocator, frigg::TicketLock> MemoryAllocator;
|
||||
typedef frg::slab_allocator<VirtualAllocator, AllocatorLock> MemoryAllocator;
|
||||
|
||||
MemoryAllocator &getAllocator();
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ int unsetenv(const char *name) {
|
|||
update_env_copy();
|
||||
|
||||
auto k = find_env_index(name);
|
||||
assert(k != size_t(-1));
|
||||
FRG_ASSERT(k != size_t(-1));
|
||||
|
||||
// Last pointer is always null.
|
||||
__ensure(global_env_vector.size() >= 2 && !global_env_vector.back());
|
||||
|
|
Loading…
Reference in a new issue