From 65dad3bea6f039ff578e9f9bf04db929c2c42adb Mon Sep 17 00:00:00 2001 From: Tulio A M Mendes Date: Wed, 11 Feb 2026 19:57:23 -0300 Subject: [PATCH] feat: per-process errno + set_thread_area syscall stub for future TLS - user/errno.c: documented per-process errno isolation via fork - include/syscall.h: added SYSCALL_SET_THREAD_AREA(57) for future TLS - src/kernel/syscall.c: set_thread_area dispatch stub (-ENOSYS) - True TLS deferred until clone/threads (task #14) is implemented - cppcheck clean, 19/19 smoke tests pass --- include/syscall.h | 2 ++ src/kernel/syscall.c | 6 ++++++ user/errno.c | 3 +++ 3 files changed, 11 insertions(+) diff --git a/include/syscall.h b/include/syscall.h index c7cc012..2948163 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -76,6 +76,8 @@ enum { SYSCALL_LINK = 54, SYSCALL_SYMLINK = 55, SYSCALL_READLINK = 56, + + SYSCALL_SET_THREAD_AREA = 57, }; #endif diff --git a/src/kernel/syscall.c b/src/kernel/syscall.c index 0e0489a..999115e 100644 --- a/src/kernel/syscall.c +++ b/src/kernel/syscall.c @@ -2148,6 +2148,12 @@ void syscall_handler(struct registers* regs) { return; } + if (syscall_no == SYSCALL_SET_THREAD_AREA) { + /* Stub: will be implemented when clone/threads are added */ + regs->eax = (uint32_t)-ENOSYS; + return; + } + regs->eax = (uint32_t)-ENOSYS; } diff --git a/user/errno.c b/user/errno.c index 8330a8f..fbc6e36 100644 --- a/user/errno.c +++ b/user/errno.c @@ -1 +1,4 @@ +/* Per-process errno: each fork()ed process gets its own copy in its + address space. When true threads (clone) are added, this must become + __thread int errno or use a TLS segment (GS/FS). */ int errno = 0; -- 2.43.0