liblinux++

A hosted C++ runtime without any libc.
git clone git://henryandlizzy.uk/liblinux++
Log | Files | Refs

commit 44c8140fe7d217d01ad78509175d90d3248610c0
parent 46abafe5da58b323497c5f060300aeb225e9600e
Author: Henry Wilson <henry@henryandlizzy.uk>
Date:   Tue, 23 Dec 2025 14:51:06 +0000

Make openat/mmap take a file

Diffstat:
Mlinux.hpp | 9++++-----
Mx86_64.s | 2+-
2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/linux.hpp b/linux.hpp @@ -18,8 +18,6 @@ using off64_t = int64_t; using time_t = int64_t; enum { - AT_FDCWD = -100, - O_RDONLY = 0, O_WRONLY = 1, O_RDWR = 2, @@ -67,6 +65,7 @@ struct file inline operator bool() const { return num >= 0; } }; +file const AT_FDCWD{-100}; file const stdin{0}; file const stdout{1}; file const stderr{2}; @@ -128,7 +127,7 @@ extern syscall_result<size_t> write(file fd, char const data[], size_t count); extern syscall_result<size_t> write(file fd, span<char const> data); extern syscall_result<size_t> write(file fd, span<span<char const> const> data); -extern syscall_result<file> openat(int fd, c_str name, int flags, int mode); +extern syscall_result<file> openat(file fd, c_str name, int flags, int mode); extern syscall_result<void> close(file fd); @@ -139,9 +138,9 @@ struct linux_dirent64 { unsigned char d_type; /* File type */ char d_name[]; /* Filename (null-terminated) */ }; -extern syscall_result<ssize_t> getdents64(int fd, linux_dirent64 dirp[], size_t count); +extern syscall_result<ssize_t> getdents64(file dir, linux_dirent64 dirp[], size_t count); -extern syscall_result<void*> mmap(void* addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long off); +extern syscall_result<void*> mmap(void* addr, unsigned long len, unsigned long prot, unsigned long flags, file fd, unsigned long off); struct timespec { time_t tv_sec; /* Seconds */ diff --git a/x86_64.s b/x86_64.s @@ -76,5 +76,5 @@ extern getdents64 _syscall 217 syscall3 extern openat -extern_alias _Z6openati5c_strii +extern_alias _Z6openat4file5c_strii _syscall 257 syscall6