19 thread_local std::array<uintptr_t, Aarch64::kMainStackSize> Aarch64::gMainStack;
41 buf = Aarch64::AllocStack(allocSize);
44 this->
stack = {
reinterpret_cast<uintptr_t *
>(buf), allocSize /
sizeof(uintptr_t)};
45 this->ownsStack =
true;
47 Aarch64::Prepare(
this, entry);
59 Aarch64::ValidateStackSize(_stack.size() *
sizeof(uintptr_t));
60 Aarch64::Prepare(
this, entry);
76 DeallocStack(this->
stack.data());
86 Switch(
static_cast<Aarch64 *
>(from),
this);
96 void Aarch64::ValidateStackSize(
const size_t size) {
97 if(!size)
throw std::runtime_error(
"Size may not be nil");
98 if(size %
kStackAlignment)
throw std::runtime_error(
"Stack is misaligned");
105 void Aarch64::CothreadReturned() {
115 void Aarch64::DereferenceCallInfo(CallInfo *info) {
135 return new Aarch64(Aarch64::gMainStack);
static Cothread * Current()
Architecture specific methods for working with cothreads on 64 bit ARM machines.
static constexpr const size_t kDefaultStackSize
static constexpr const size_t kStackAlignment
static constexpr const size_t kContextSaveAreaSize
Aarch64(const Entry &entry, const size_t stackSize=0)
void switchTo(CothreadImpl *from) override
Implementation details (including architecture/platform specific code) for the library.
std::function< void(libcommunism::Cothread *)> gReturnHandler
Main namespace for the libcommunism library.
CothreadImpl * AllocKernelThreadWrapper()
Abstract interface for a platform implementation of cothreads.
std::span< uintptr_t > stack
Stack used by this cothread, if any.