Move threading calls into a basic user space library.

This commit is contained in:
Drew Galbraith 2023-06-06 16:56:19 -07:00
parent b0c2a6732b
commit 174d4b10fb
9 changed files with 67 additions and 21 deletions

View file

@ -0,0 +1,5 @@
#include "include/mammoth/debug.h"
#include "zcall.h"
void dbgln(const char* str) { ZDebug(str); }

View file

@ -0,0 +1,19 @@
#include "include/mammoth/thread.h"
#include "zcall.h"
namespace {
extern "C" void thread_entry(Thread::Entry entry, void* arg1) {
entry(arg1);
ZThreadExit();
}
} // namespace
Thread::Thread(Entry e, const void* arg1) {
ZThreadCreate(Z_INIT_PROC_SELF, &thread_cap_);
ZThreadStart(thread_cap_, reinterpret_cast<uint64_t>(thread_entry),
reinterpret_cast<uint64_t>(e), reinterpret_cast<uint64_t>(arg1));
}