hl-engine 0.1.0

Safe Rust lifecycle API for the standalone HL Linux guest engine
#include <stdint.h>

#ifndef HL_GUEST_EXIT_STATUS
#define HL_GUEST_EXIT_STATUS 42
#endif

__attribute__((noreturn)) void _start(void) {
#if defined(__aarch64__)
    register uint64_t status __asm__("x0") = HL_GUEST_EXIT_STATUS;
    register uint64_t syscall_number __asm__("x8") = 93;
    __asm__ volatile("svc #0" : : "r"(status), "r"(syscall_number) : "memory");
#elif defined(__x86_64__)
    register uint64_t status __asm__("rdi") = HL_GUEST_EXIT_STATUS;
    register uint64_t syscall_number __asm__("rax") = 60;
    __asm__ volatile("syscall" : : "r"(status), "r"(syscall_number) : "rcx", "r11", "memory");
#else
#error unsupported guest architecture
#endif
    __builtin_unreachable();
}