liblinux++

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

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

Use static cast to extract syscall result

Diffstat:
Mlinux.hpp | 23++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/linux.hpp b/linux.hpp @@ -32,15 +32,15 @@ enum { MAP_SHARED = 0x1, MAP_PRIVATE = 0x2, - DT_UNKNOWN = 0, - DT_FIFO = 1, - DT_CHR = 2, - DT_DIR = 4, - DT_BLK = 6, - DT_REG = 8, - DT_LNK = 10, - DT_SOCK = 12, - DT_WHT = 14, + DT_UNKNOWN = 0, + DT_FIFO = 1, + DT_CHR = 2, + DT_DIR = 4, + DT_BLK = 6, + DT_REG = 8, + DT_LNK = 10, + DT_SOCK = 12, + DT_WHT = 14, }; template <typename T> @@ -62,6 +62,7 @@ struct span struct file { + explicit file(int n) : num{n} {} int num = -1; inline operator bool() const { return num >= 0; } }; @@ -88,13 +89,13 @@ struct syscall_result { if (!*this) __builtin_trap(); - return *reinterpret_cast<T const*>(&val); + return static_cast<T>(val); } errno_t err() const { if (*this) __builtin_trap(); - return reinterpret_cast<errno_t>(static_cast<int16_t>(val)); + return static_cast<errno_t>(val); } private: int64_t val;