2023-06-07 00:25:04 -07:00
|
|
|
#include "mammoth/thread.h"
|
2023-06-06 16:56:19 -07:00
|
|
|
|
2023-06-06 17:12:08 -07:00
|
|
|
#include <zcall.h>
|
2023-06-06 16:56:19 -07:00
|
|
|
|
2023-06-07 00:25:04 -07:00
|
|
|
#include "mammoth/debug.h"
|
|
|
|
|
2023-06-06 16:56:19 -07:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
extern "C" void thread_entry(Thread::Entry entry, void* arg1) {
|
|
|
|
entry(arg1);
|
|
|
|
|
|
|
|
ZThreadExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
Thread::Thread(Entry e, const void* arg1) {
|
2023-06-07 00:25:04 -07:00
|
|
|
check(ZThreadCreate(Z_INIT_PROC_SELF, &thread_cap_));
|
|
|
|
check(ZThreadStart(thread_cap_, reinterpret_cast<uint64_t>(thread_entry),
|
|
|
|
reinterpret_cast<uint64_t>(e),
|
|
|
|
reinterpret_cast<uint64_t>(arg1)));
|
2023-06-06 16:56:19 -07:00
|
|
|
}
|