runtime/lib/src/lib.cpp
2025-02-14 23:10:29 -05:00

22 lines
783 B
C++

#include "lib.h"
// Call
static Trampoline::Error trampoline(const uint32_t id, uint32_t *ret, const uint32_t length, const unsigned char *args) {
// Check Arguments Length
if (length > MAX_TRAMPOLINE_ARGS_SIZE) {
return Trampoline::Error::COMMAND_TOO_BIG;
}
// Configure Method
static bool use_syscall = SyscallTrampoline::should_use();
// Use Correct Method
if (use_syscall) {
static SyscallTrampoline syscall;
return syscall.call(id, ret, length, args);
} else {
static PipeTrampoline pipe;
return pipe.call(id, ret, length, args);
}
}
uint32_t raw_trampoline(const uint32_t id, uint32_t *ret, const uint32_t length, const unsigned char *args) {
return uint32_t(trampoline(id, ret, length, args));
}