From 958386d7402b8992b2834bd6d6e5287832d059f0 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 14233ff8..77a5a88d 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -85,6 +85,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 6617c10b..44a733ec 100644 --- a/src/kernel/syscall.c +++ b/src/kernel/syscall.c @@ -2157,6 +2157,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 74d9f803..dd029b74 100644 --- a/user/errno.c +++ b/user/errno.c @@ -7,4 +7,7 @@ * Source: https://github.com/tadryanom/AdrOS */ +/* 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