/* POSIX userspace implementation of libluna hooks. */ #include #include #include #include #include #include #include _weak [[noreturn]] bool __check_failed(SourceLocation location, const char* expr) { fprintf(stderr, "Check failed at %s:%d in %s: %s\n", location.file(), location.line(), location.function(), expr); abort(); } void debug_log_impl(const char* format, va_list ap) { vfprintf(stderr, format, ap); fputc('\n', stderr); } Result allocate_pages_impl(usize count) { void* rc = mmap(nullptr, count * PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (rc == MAP_FAILED) { return err(errno); } return rc; } Result release_pages_impl(void* address, usize count) { int rc = munmap(address, count * PAGE_SIZE); if (rc < 0) { return err(errno); } return {}; }