liblinux++

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

commit 09504ff0b7b080108faeda3c94982aaa429b6885
parent 8532467e15086a625e148204eb8c42ab9ce22a32
Author: Henry Wilson <henry@henryandlizzy.uk>
Date:   Sun, 28 Dec 2025 21:25:19 +0000

[[nodiscard]] on syscall_result

Diffstat:
MTupfile | 2+-
Mcat.cpp | 2+-
Mlinux.hpp | 2+-
Mls.cpp | 2+-
Mpaste.cpp | 4++--
Msleep.cpp | 2+-
Mtest.cpp | 6+++---
7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/Tupfile b/Tupfile @@ -1,4 +1,4 @@ -CXXFLAGS = -g -Os -fno-exceptions -fno-rtti -fno-asynchronous-unwind-tables -fno-builtin -fno-pic -fno-pie -fno-stack-protector -fdiagnostics-color=always +CXXFLAGS = -Werror -g -Os -fno-exceptions -fno-rtti -fno-asynchronous-unwind-tables -fno-builtin -fno-pic -fno-pie -fno-stack-protector -fdiagnostics-color=always LDFLAGS = --gc-sections : foreach *.cpp |> clang++ --target=aarch64 $(CXXFLAGS) -c -o %o %f |> obj/%B.aarch64.o {objs-aarch64} diff --git a/cat.cpp b/cat.cpp @@ -27,6 +27,6 @@ int main(int argc, char* argv[]) return 1; auto fd = *res; cat(fd); - close(fd); + *close(fd); } } diff --git a/linux.hpp b/linux.hpp @@ -103,7 +103,7 @@ enum class errno_t : int16_t }; template <typename T> -struct syscall_result +struct [[nodiscard]] syscall_result { explicit operator bool() const { return val >= 0; } T operator*() const diff --git a/ls.cpp b/ls.cpp @@ -35,6 +35,6 @@ int main() ios[n_io++] = span<char const>{e->d_name, len}; i += e->d_reclen; } - write(stdout, ios); + *write(stdout, ios); } } diff --git a/paste.cpp b/paste.cpp @@ -52,9 +52,9 @@ int main(int argc, char* argv[]) return 0; if (c == '\n') break; - write(stdout, &c, 1); + *write(stdout, &c, 1); } - write(stdout, i + 1 == n_inputs ? "\n" : "\t", 1); + *write(stdout, i + 1 == n_inputs ? "\n" : "\t", 1); } } } diff --git a/sleep.cpp b/sleep.cpp @@ -34,5 +34,5 @@ int main(int argc, char* argv[]) return 1; timespec duration{(time_t)n, 0}; - nanosleep(duration, nullptr); + *nanosleep(duration, nullptr); } diff --git a/test.cpp b/test.cpp @@ -6,14 +6,14 @@ char bss[4]; void text() { - write(stdout, {rodata, sizeof(rodata) - 1}); - write(stdout, {data, sizeof(data) - 1}); + *write(stdout, {rodata, sizeof(rodata) - 1}); + *write(stdout, {data, sizeof(data) - 1}); bss[0] = 'b'; bss[1] = 's'; bss[2] = 's'; bss[3] = '\n'; - write(stdout, bss); + *write(stdout, bss); } int main()