* [PATCH] tools/nolibc: rename sys_foo() functions to _sys_foo()
@ 2026-03-19 16:20 Thomas Weißschuh
2026-03-22 9:06 ` Willy Tarreau
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Weißschuh @ 2026-03-19 16:20 UTC (permalink / raw)
To: Willy Tarreau; +Cc: linux-kernel, Thomas Weißschuh
The sys_foo() naming scheme used by the syscall wrappers may collide
with application symbols. Especially as 'sys_' is an obvious naming
scheme an application may choose for its own custom systemcall wrappers.
Avoid these conflicts by using an leading underscore which moves the
names into the implementation's namespace. This naming scheme was chosen
over a '__nolibc_' prefix, as these functions are not an implementation
detail but a documented interface meant to be used by applications.
While this may break some existing users, adapting them should be
straightforward. Given that nolibc is most-likely vendored, no
unexpected breakage should happen. No in-tree users are affected.
These conflicts happen when compiling some of the kernel selftests
with nolibc.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
I am not really thrilled about breaking these names.
But every other option seems to be horribly to maintain
or will break sooner or later anyways.
Any ideas?
---
tools/include/nolibc/arch-s390.h | 14 +--
tools/include/nolibc/arch-sparc.h | 8 +-
tools/include/nolibc/dirent.h | 4 +-
tools/include/nolibc/fcntl.h | 8 +-
tools/include/nolibc/nolibc.h | 6 +-
tools/include/nolibc/poll.h | 4 +-
tools/include/nolibc/sched.h | 8 +-
tools/include/nolibc/signal.h | 2 +-
tools/include/nolibc/stdlib.h | 2 +-
tools/include/nolibc/sys.h | 178 ++++++++++++++++++------------------
tools/include/nolibc/sys/ioctl.h | 4 +-
tools/include/nolibc/sys/mman.h | 16 ++--
tools/include/nolibc/sys/mount.h | 6 +-
tools/include/nolibc/sys/prctl.h | 6 +-
tools/include/nolibc/sys/ptrace.h | 4 +-
tools/include/nolibc/sys/random.h | 4 +-
tools/include/nolibc/sys/reboot.h | 4 +-
tools/include/nolibc/sys/resource.h | 8 +-
tools/include/nolibc/sys/select.h | 4 +-
tools/include/nolibc/sys/stat.h | 6 +-
tools/include/nolibc/sys/time.h | 8 +-
tools/include/nolibc/sys/timerfd.h | 14 +--
tools/include/nolibc/sys/uio.h | 8 +-
tools/include/nolibc/sys/utsname.h | 4 +-
tools/include/nolibc/sys/wait.h | 4 +-
tools/include/nolibc/time.h | 40 ++++----
tools/include/nolibc/unistd.h | 10 +-
27 files changed, 192 insertions(+), 192 deletions(-)
diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h
index d301b636e083..4e69123ae484 100644
--- a/tools/include/nolibc/arch-s390.h
+++ b/tools/include/nolibc/arch-s390.h
@@ -167,8 +167,8 @@ struct s390_mmap_arg_struct {
};
static __attribute__((unused))
-void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
- off_t offset)
+void *_sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
+ off_t offset)
{
struct s390_mmap_arg_struct args = {
.addr = (unsigned long)addr,
@@ -181,20 +181,20 @@ void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
return (void *)__nolibc_syscall1(__NR_mmap, &args);
}
-#define sys_mmap sys_mmap
+#define _sys_mmap _sys_mmap
static __attribute__((unused))
-pid_t sys_fork(void)
+pid_t _sys_fork(void)
{
return __nolibc_syscall5(__NR_clone, 0, SIGCHLD, 0, 0, 0);
}
-#define sys_fork sys_fork
+#define _sys_fork _sys_fork
static __attribute__((unused))
-pid_t sys_vfork(void)
+pid_t _sys_vfork(void)
{
return __nolibc_syscall5(__NR_clone, 0, CLONE_VM | CLONE_VFORK | SIGCHLD, 0, 0, 0);
}
-#define sys_vfork sys_vfork
+#define _sys_vfork _sys_vfork
#endif /* _NOLIBC_ARCH_S390_H */
diff --git a/tools/include/nolibc/arch-sparc.h b/tools/include/nolibc/arch-sparc.h
index 02aca6579cb2..240539d069a8 100644
--- a/tools/include/nolibc/arch-sparc.h
+++ b/tools/include/nolibc/arch-sparc.h
@@ -175,7 +175,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
static pid_t getpid(void);
static __attribute__((unused))
-pid_t sys_fork(void)
+pid_t _sys_fork(void)
{
pid_t parent, ret;
@@ -188,10 +188,10 @@ pid_t sys_fork(void)
else
return ret;
}
-#define sys_fork sys_fork
+#define _sys_fork _sys_fork
static __attribute__((unused))
-pid_t sys_vfork(void)
+pid_t _sys_vfork(void)
{
pid_t parent, ret;
@@ -204,6 +204,6 @@ pid_t sys_vfork(void)
else
return ret;
}
-#define sys_vfork sys_vfork
+#define _sys_vfork _sys_vfork
#endif /* _NOLIBC_ARCH_SPARC_H */
diff --git a/tools/include/nolibc/dirent.h b/tools/include/nolibc/dirent.h
index 61a122a60327..4e02ef25e72d 100644
--- a/tools/include/nolibc/dirent.h
+++ b/tools/include/nolibc/dirent.h
@@ -73,7 +73,7 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
fd = ~i;
- ret = sys_getdents64(fd, ldir, sizeof(buf));
+ ret = _sys_getdents64(fd, ldir, sizeof(buf));
if (ret < 0)
return -ret;
if (ret == 0) {
@@ -86,7 +86,7 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
* readdir() can only return one entry at a time.
* Make sure the non-returned ones are not skipped.
*/
- ret = sys_lseek(fd, ldir->d_off, SEEK_SET);
+ ret = _sys_lseek(fd, ldir->d_off, SEEK_SET);
if (ret < 0)
return -ret;
diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h
index 8d82768dea9d..ed2f5553c65a 100644
--- a/tools/include/nolibc/fcntl.h
+++ b/tools/include/nolibc/fcntl.h
@@ -19,7 +19,7 @@
*/
static __attribute__((unused))
-int sys_openat(int dirfd, const char *path, int flags, mode_t mode)
+int _sys_openat(int dirfd, const char *path, int flags, mode_t mode)
{
return __nolibc_syscall4(__NR_openat, dirfd, path, flags, mode);
}
@@ -37,7 +37,7 @@ int openat(int dirfd, const char *path, int flags, ...)
va_end(args);
}
- return __sysret(sys_openat(dirfd, path, flags, mode));
+ return __sysret(_sys_openat(dirfd, path, flags, mode));
}
/*
@@ -45,7 +45,7 @@ int openat(int dirfd, const char *path, int flags, ...)
*/
static __attribute__((unused))
-int sys_open(const char *path, int flags, mode_t mode)
+int _sys_open(const char *path, int flags, mode_t mode)
{
return __nolibc_syscall4(__NR_openat, AT_FDCWD, path, flags, mode);
}
@@ -63,7 +63,7 @@ int open(const char *path, int flags, ...)
va_end(args);
}
- return __sysret(sys_open(path, flags, mode));
+ return __sysret(_sys_open(path, flags, mode));
}
#endif /* _NOLIBC_FCNTL_H */
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index d1d08b7f8599..9427156b774b 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -19,17 +19,17 @@
* a pointer or the negated errno value.
*
* - The second level is mostly architecture-independent. It is made of
- * static functions called sys_<name>() which rely on __nolibc_syscallN()
+ * static functions called _sys_<name>() which rely on __nolibc_syscallN()
* depending on the syscall definition. These functions are responsible
* for exposing the appropriate types for the syscall arguments (int,
* pointers, etc) and for setting the appropriate return type (often int).
* A few of them are architecture-specific because the syscalls are not all
* mapped exactly the same among architectures. For example, some archs do
- * not implement select() and need pselect6() instead, so the sys_select()
+ * not implement select() and need pselect6() instead, so the _sys_select()
* function will have to abstract this.
*
* - The third level is the libc call definition. It exposes the lower raw
- * sys_<name>() calls in a way that looks like what a libc usually does,
+ * _sys_<name>() calls in a way that looks like what a libc usually does,
* takes care of specific input values, and of setting errno upon error.
* There can be minor variations compared to standard libc calls.
*
diff --git a/tools/include/nolibc/poll.h b/tools/include/nolibc/poll.h
index ea5a6d08c43c..dbcf883da237 100644
--- a/tools/include/nolibc/poll.h
+++ b/tools/include/nolibc/poll.h
@@ -21,7 +21,7 @@
*/
static __attribute__((unused))
-int sys_poll(struct pollfd *fds, int nfds, int timeout)
+int _sys_poll(struct pollfd *fds, int nfds, int timeout)
{
#if defined(__NR_ppoll_time64)
struct __kernel_timespec t;
@@ -45,7 +45,7 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout)
static __attribute__((unused))
int poll(struct pollfd *fds, int nfds, int timeout)
{
- return __sysret(sys_poll(fds, nfds, timeout));
+ return __sysret(_sys_poll(fds, nfds, timeout));
}
#endif /* _NOLIBC_POLL_H */
diff --git a/tools/include/nolibc/sched.h b/tools/include/nolibc/sched.h
index b1af7fa6672d..7a5f6d9484c8 100644
--- a/tools/include/nolibc/sched.h
+++ b/tools/include/nolibc/sched.h
@@ -19,7 +19,7 @@
*/
static __attribute__((unused))
-int sys_setns(int fd, int nstype)
+int _sys_setns(int fd, int nstype)
{
return __nolibc_syscall2(__NR_setns, fd, nstype);
}
@@ -27,7 +27,7 @@ int sys_setns(int fd, int nstype)
static __attribute__((unused))
int setns(int fd, int nstype)
{
- return __sysret(sys_setns(fd, nstype));
+ return __sysret(_sys_setns(fd, nstype));
}
@@ -36,7 +36,7 @@ int setns(int fd, int nstype)
*/
static __attribute__((unused))
-int sys_unshare(int flags)
+int _sys_unshare(int flags)
{
return __nolibc_syscall1(__NR_unshare, flags);
}
@@ -44,7 +44,7 @@ int sys_unshare(int flags)
static __attribute__((unused))
int unshare(int flags)
{
- return __sysret(sys_unshare(flags));
+ return __sysret(_sys_unshare(flags));
}
#endif /* _NOLIBC_SCHED_H */
diff --git a/tools/include/nolibc/signal.h b/tools/include/nolibc/signal.h
index ac13e53ac31d..99a0489fe3e8 100644
--- a/tools/include/nolibc/signal.h
+++ b/tools/include/nolibc/signal.h
@@ -20,7 +20,7 @@ int raise(int signal);
__attribute__((weak,unused,section(".text.nolibc_raise")))
int raise(int signal)
{
- return sys_kill(sys_getpid(), signal);
+ return _sys_kill(_sys_getpid(), signal);
}
#endif /* _NOLIBC_SIGNAL_H */
diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h
index 73b6a771a9f4..2113a8e7695d 100644
--- a/tools/include/nolibc/stdlib.h
+++ b/tools/include/nolibc/stdlib.h
@@ -55,7 +55,7 @@ void abort(void);
__attribute__((weak,unused,noreturn,section(".text.nolibc_abort")))
void abort(void)
{
- sys_kill(sys_getpid(), SIGABRT);
+ _sys_kill(_sys_getpid(), SIGABRT);
for (;;);
}
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index bc1c76cb2f63..6335fd51f07f 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -63,7 +63,7 @@ static __inline__ int __nolibc_enosys(const char *syscall, ...)
* - the "internal" ones, which matches the raw syscall interface at the
* kernel level, which may sometimes slightly differ from the documented
* libc-level ones. For example most of them return either a valid value
- * or -errno. All of these are prefixed with "sys_". They may be called
+ * or -errno. All of these are prefixed with "_sys_". They may be called
* by non-portable applications if desired.
*
* - the "exported" ones, whose interface must closely match the one
@@ -85,7 +85,7 @@ static __inline__ int __nolibc_enosys(const char *syscall, ...)
*/
static __attribute__((unused))
-void *sys_brk(void *addr)
+void *_sys_brk(void *addr)
{
return (void *)__nolibc_syscall1(__NR_brk, addr);
}
@@ -93,7 +93,7 @@ void *sys_brk(void *addr)
static __attribute__((unused))
int brk(void *addr)
{
- void *ret = sys_brk(addr);
+ void *ret = _sys_brk(addr);
if (!ret) {
SET_ERRNO(ENOMEM);
@@ -106,9 +106,9 @@ static __attribute__((unused))
void *sbrk(intptr_t inc)
{
/* first call to find current end */
- void *ret = sys_brk(NULL);
+ void *ret = _sys_brk(NULL);
- if (ret && sys_brk(ret + inc) == ret + inc)
+ if (ret && _sys_brk(ret + inc) == ret + inc)
return ret + inc;
SET_ERRNO(ENOMEM);
@@ -122,7 +122,7 @@ void *sbrk(intptr_t inc)
*/
static __attribute__((unused))
-int sys_chdir(const char *path)
+int _sys_chdir(const char *path)
{
return __nolibc_syscall1(__NR_chdir, path);
}
@@ -130,11 +130,11 @@ int sys_chdir(const char *path)
static __attribute__((unused))
int chdir(const char *path)
{
- return __sysret(sys_chdir(path));
+ return __sysret(_sys_chdir(path));
}
static __attribute__((unused))
-int sys_fchdir(int fildes)
+int _sys_fchdir(int fildes)
{
return __nolibc_syscall1(__NR_fchdir, fildes);
}
@@ -142,7 +142,7 @@ int sys_fchdir(int fildes)
static __attribute__((unused))
int fchdir(int fildes)
{
- return __sysret(sys_fchdir(fildes));
+ return __sysret(_sys_fchdir(fildes));
}
@@ -151,7 +151,7 @@ int fchdir(int fildes)
*/
static __attribute__((unused))
-int sys_chmod(const char *path, mode_t mode)
+int _sys_chmod(const char *path, mode_t mode)
{
#if defined(__NR_fchmodat)
return __nolibc_syscall4(__NR_fchmodat, AT_FDCWD, path, mode, 0);
@@ -163,7 +163,7 @@ int sys_chmod(const char *path, mode_t mode)
static __attribute__((unused))
int chmod(const char *path, mode_t mode)
{
- return __sysret(sys_chmod(path, mode));
+ return __sysret(_sys_chmod(path, mode));
}
@@ -172,7 +172,7 @@ int chmod(const char *path, mode_t mode)
*/
static __attribute__((unused))
-int sys_chown(const char *path, uid_t owner, gid_t group)
+int _sys_chown(const char *path, uid_t owner, gid_t group)
{
#if defined(__NR_fchownat)
return __nolibc_syscall5(__NR_fchownat, AT_FDCWD, path, owner, group, 0);
@@ -184,7 +184,7 @@ int sys_chown(const char *path, uid_t owner, gid_t group)
static __attribute__((unused))
int chown(const char *path, uid_t owner, gid_t group)
{
- return __sysret(sys_chown(path, owner, group));
+ return __sysret(_sys_chown(path, owner, group));
}
@@ -193,7 +193,7 @@ int chown(const char *path, uid_t owner, gid_t group)
*/
static __attribute__((unused))
-int sys_chroot(const char *path)
+int _sys_chroot(const char *path)
{
return __nolibc_syscall1(__NR_chroot, path);
}
@@ -201,7 +201,7 @@ int sys_chroot(const char *path)
static __attribute__((unused))
int chroot(const char *path)
{
- return __sysret(sys_chroot(path));
+ return __sysret(_sys_chroot(path));
}
@@ -210,7 +210,7 @@ int chroot(const char *path)
*/
static __attribute__((unused))
-int sys_close(int fd)
+int _sys_close(int fd)
{
return __nolibc_syscall1(__NR_close, fd);
}
@@ -218,7 +218,7 @@ int sys_close(int fd)
static __attribute__((unused))
int close(int fd)
{
- return __sysret(sys_close(fd));
+ return __sysret(_sys_close(fd));
}
@@ -227,7 +227,7 @@ int close(int fd)
*/
static __attribute__((unused))
-int sys_dup(int fd)
+int _sys_dup(int fd)
{
return __nolibc_syscall1(__NR_dup, fd);
}
@@ -235,7 +235,7 @@ int sys_dup(int fd)
static __attribute__((unused))
int dup(int fd)
{
- return __sysret(sys_dup(fd));
+ return __sysret(_sys_dup(fd));
}
@@ -244,7 +244,7 @@ int dup(int fd)
*/
static __attribute__((unused))
-int sys_dup2(int old, int new)
+int _sys_dup2(int old, int new)
{
#if defined(__NR_dup3)
int ret, nr_fcntl;
@@ -269,7 +269,7 @@ int sys_dup2(int old, int new)
static __attribute__((unused))
int dup2(int old, int new)
{
- return __sysret(sys_dup2(old, new));
+ return __sysret(_sys_dup2(old, new));
}
@@ -279,7 +279,7 @@ int dup2(int old, int new)
#if defined(__NR_dup3)
static __attribute__((unused))
-int sys_dup3(int old, int new, int flags)
+int _sys_dup3(int old, int new, int flags)
{
return __nolibc_syscall3(__NR_dup3, old, new, flags);
}
@@ -287,7 +287,7 @@ int sys_dup3(int old, int new, int flags)
static __attribute__((unused))
int dup3(int old, int new, int flags)
{
- return __sysret(sys_dup3(old, new, flags));
+ return __sysret(_sys_dup3(old, new, flags));
}
#endif
@@ -297,7 +297,7 @@ int dup3(int old, int new, int flags)
*/
static __attribute__((unused))
-int sys_execve(const char *filename, char *const argv[], char *const envp[])
+int _sys_execve(const char *filename, char *const argv[], char *const envp[])
{
return __nolibc_syscall3(__NR_execve, filename, argv, envp);
}
@@ -305,7 +305,7 @@ int sys_execve(const char *filename, char *const argv[], char *const envp[])
static __attribute__((unused))
int execve(const char *filename, char *const argv[], char *const envp[])
{
- return __sysret(sys_execve(filename, argv, envp));
+ return __sysret(_sys_execve(filename, argv, envp));
}
@@ -314,7 +314,7 @@ int execve(const char *filename, char *const argv[], char *const envp[])
*/
static __attribute__((noreturn,unused))
-void sys_exit(int status)
+void _sys_exit(int status)
{
__nolibc_syscall1(__NR_exit, status & 255);
while(1); /* shut the "noreturn" warnings. */
@@ -323,7 +323,7 @@ void sys_exit(int status)
static __attribute__((noreturn,unused))
void _exit(int status)
{
- sys_exit(status);
+ _sys_exit(status);
}
static __attribute__((noreturn,unused))
@@ -337,9 +337,9 @@ void exit(int status)
* pid_t fork(void);
*/
-#ifndef sys_fork
+#ifndef _sys_fork
static __attribute__((unused))
-pid_t sys_fork(void)
+pid_t _sys_fork(void)
{
#if defined(__NR_clone)
/* note: some archs only have clone() and not fork(). Different archs
@@ -356,15 +356,15 @@ pid_t sys_fork(void)
static __attribute__((unused))
pid_t fork(void)
{
- return __sysret(sys_fork());
+ return __sysret(_sys_fork());
}
-#ifndef sys_vfork
+#ifndef _sys_vfork
static __attribute__((unused))
-pid_t sys_vfork(void)
+pid_t _sys_vfork(void)
{
#if defined(__NR_clone)
- /* See the note in sys_fork(). */
+ /* See the note in _sys_fork(). */
return __nolibc_syscall5(__NR_clone, CLONE_VM | CLONE_VFORK | SIGCHLD, 0, 0, 0, 0);
#elif defined(__NR_vfork)
return __nolibc_syscall0(__NR_vfork);
@@ -375,7 +375,7 @@ pid_t sys_vfork(void)
static __attribute__((unused))
pid_t vfork(void)
{
- return __sysret(sys_vfork());
+ return __sysret(_sys_vfork());
}
/*
@@ -383,7 +383,7 @@ pid_t vfork(void)
*/
static __attribute__((unused))
-int sys_fsync(int fd)
+int _sys_fsync(int fd)
{
return __nolibc_syscall1(__NR_fsync, fd);
}
@@ -391,7 +391,7 @@ int sys_fsync(int fd)
static __attribute__((unused))
int fsync(int fd)
{
- return __sysret(sys_fsync(fd));
+ return __sysret(_sys_fsync(fd));
}
@@ -400,7 +400,7 @@ int fsync(int fd)
*/
static __attribute__((unused))
-int sys_getdents64(int fd, struct linux_dirent64 *dirp, int count)
+int _sys_getdents64(int fd, struct linux_dirent64 *dirp, int count)
{
return __nolibc_syscall3(__NR_getdents64, fd, dirp, count);
}
@@ -408,7 +408,7 @@ int sys_getdents64(int fd, struct linux_dirent64 *dirp, int count)
static __attribute__((unused))
int getdents64(int fd, struct linux_dirent64 *dirp, int count)
{
- return __sysret(sys_getdents64(fd, dirp, count));
+ return __sysret(_sys_getdents64(fd, dirp, count));
}
@@ -417,7 +417,7 @@ int getdents64(int fd, struct linux_dirent64 *dirp, int count)
*/
static __attribute__((unused))
-uid_t sys_geteuid(void)
+uid_t _sys_geteuid(void)
{
#if defined(__NR_geteuid32)
return __nolibc_syscall0(__NR_geteuid32);
@@ -429,7 +429,7 @@ uid_t sys_geteuid(void)
static __attribute__((unused))
uid_t geteuid(void)
{
- return sys_geteuid();
+ return _sys_geteuid();
}
@@ -438,7 +438,7 @@ uid_t geteuid(void)
*/
static __attribute__((unused))
-pid_t sys_getpgid(pid_t pid)
+pid_t _sys_getpgid(pid_t pid)
{
return __nolibc_syscall1(__NR_getpgid, pid);
}
@@ -446,7 +446,7 @@ pid_t sys_getpgid(pid_t pid)
static __attribute__((unused))
pid_t getpgid(pid_t pid)
{
- return __sysret(sys_getpgid(pid));
+ return __sysret(_sys_getpgid(pid));
}
@@ -455,15 +455,15 @@ pid_t getpgid(pid_t pid)
*/
static __attribute__((unused))
-pid_t sys_getpgrp(void)
+pid_t _sys_getpgrp(void)
{
- return sys_getpgid(0);
+ return _sys_getpgid(0);
}
static __attribute__((unused))
pid_t getpgrp(void)
{
- return sys_getpgrp();
+ return _sys_getpgrp();
}
@@ -472,7 +472,7 @@ pid_t getpgrp(void)
*/
static __attribute__((unused))
-pid_t sys_getpid(void)
+pid_t _sys_getpid(void)
{
return __nolibc_syscall0(__NR_getpid);
}
@@ -480,7 +480,7 @@ pid_t sys_getpid(void)
static __attribute__((unused))
pid_t getpid(void)
{
- return sys_getpid();
+ return _sys_getpid();
}
@@ -489,7 +489,7 @@ pid_t getpid(void)
*/
static __attribute__((unused))
-pid_t sys_getppid(void)
+pid_t _sys_getppid(void)
{
return __nolibc_syscall0(__NR_getppid);
}
@@ -497,7 +497,7 @@ pid_t sys_getppid(void)
static __attribute__((unused))
pid_t getppid(void)
{
- return sys_getppid();
+ return _sys_getppid();
}
@@ -506,7 +506,7 @@ pid_t getppid(void)
*/
static __attribute__((unused))
-pid_t sys_gettid(void)
+pid_t _sys_gettid(void)
{
return __nolibc_syscall0(__NR_gettid);
}
@@ -514,7 +514,7 @@ pid_t sys_gettid(void)
static __attribute__((unused))
pid_t gettid(void)
{
- return sys_gettid();
+ return _sys_gettid();
}
#ifndef NOLIBC_NO_RUNTIME
@@ -536,7 +536,7 @@ int getpagesize(void)
*/
static __attribute__((unused))
-uid_t sys_getuid(void)
+uid_t _sys_getuid(void)
{
#if defined(__NR_getuid32)
return __nolibc_syscall0(__NR_getuid32);
@@ -548,7 +548,7 @@ uid_t sys_getuid(void)
static __attribute__((unused))
uid_t getuid(void)
{
- return sys_getuid();
+ return _sys_getuid();
}
@@ -557,7 +557,7 @@ uid_t getuid(void)
*/
static __attribute__((unused))
-int sys_kill(pid_t pid, int signal)
+int _sys_kill(pid_t pid, int signal)
{
return __nolibc_syscall2(__NR_kill, pid, signal);
}
@@ -565,7 +565,7 @@ int sys_kill(pid_t pid, int signal)
static __attribute__((unused))
int kill(pid_t pid, int signal)
{
- return __sysret(sys_kill(pid, signal));
+ return __sysret(_sys_kill(pid, signal));
}
@@ -574,7 +574,7 @@ int kill(pid_t pid, int signal)
*/
static __attribute__((unused))
-int sys_link(const char *old, const char *new)
+int _sys_link(const char *old, const char *new)
{
#if defined(__NR_linkat)
return __nolibc_syscall5(__NR_linkat, AT_FDCWD, old, AT_FDCWD, new, 0);
@@ -586,7 +586,7 @@ int sys_link(const char *old, const char *new)
static __attribute__((unused))
int link(const char *old, const char *new)
{
- return __sysret(sys_link(old, new));
+ return __sysret(_sys_link(old, new));
}
@@ -595,7 +595,7 @@ int link(const char *old, const char *new)
*/
static __attribute__((unused))
-off_t sys_lseek(int fd, off_t offset, int whence)
+off_t _sys_lseek(int fd, off_t offset, int whence)
{
#if defined(__NR_llseek)
__kernel_loff_t loff = 0;
@@ -617,7 +617,7 @@ off_t sys_lseek(int fd, off_t offset, int whence)
static __attribute__((unused))
off_t lseek(int fd, off_t offset, int whence)
{
- return __sysret(sys_lseek(fd, offset, whence));
+ return __sysret(_sys_lseek(fd, offset, whence));
}
@@ -626,7 +626,7 @@ off_t lseek(int fd, off_t offset, int whence)
*/
static __attribute__((unused))
-int sys_mkdir(const char *path, mode_t mode)
+int _sys_mkdir(const char *path, mode_t mode)
{
#if defined(__NR_mkdirat)
return __nolibc_syscall3(__NR_mkdirat, AT_FDCWD, path, mode);
@@ -638,7 +638,7 @@ int sys_mkdir(const char *path, mode_t mode)
static __attribute__((unused))
int mkdir(const char *path, mode_t mode)
{
- return __sysret(sys_mkdir(path, mode));
+ return __sysret(_sys_mkdir(path, mode));
}
/*
@@ -646,7 +646,7 @@ int mkdir(const char *path, mode_t mode)
*/
static __attribute__((unused))
-int sys_rmdir(const char *path)
+int _sys_rmdir(const char *path)
{
#if defined(__NR_rmdir)
return __nolibc_syscall1(__NR_rmdir, path);
@@ -658,7 +658,7 @@ int sys_rmdir(const char *path)
static __attribute__((unused))
int rmdir(const char *path)
{
- return __sysret(sys_rmdir(path));
+ return __sysret(_sys_rmdir(path));
}
@@ -667,7 +667,7 @@ int rmdir(const char *path)
*/
static __attribute__((unused))
-long sys_mknod(const char *path, mode_t mode, dev_t dev)
+long _sys_mknod(const char *path, mode_t mode, dev_t dev)
{
#if defined(__NR_mknodat)
return __nolibc_syscall4(__NR_mknodat, AT_FDCWD, path, mode, dev);
@@ -679,7 +679,7 @@ long sys_mknod(const char *path, mode_t mode, dev_t dev)
static __attribute__((unused))
int mknod(const char *path, mode_t mode, dev_t dev)
{
- return __sysret(sys_mknod(path, mode, dev));
+ return __sysret(_sys_mknod(path, mode, dev));
}
@@ -689,7 +689,7 @@ int mknod(const char *path, mode_t mode, dev_t dev)
*/
static __attribute__((unused))
-int sys_pipe2(int pipefd[2], int flags)
+int _sys_pipe2(int pipefd[2], int flags)
{
return __nolibc_syscall2(__NR_pipe2, pipefd, flags);
}
@@ -697,7 +697,7 @@ int sys_pipe2(int pipefd[2], int flags)
static __attribute__((unused))
int pipe2(int pipefd[2], int flags)
{
- return __sysret(sys_pipe2(pipefd, flags));
+ return __sysret(_sys_pipe2(pipefd, flags));
}
static __attribute__((unused))
@@ -712,7 +712,7 @@ int pipe(int pipefd[2])
*/
static __attribute__((unused))
-int sys_pivot_root(const char *new, const char *old)
+int _sys_pivot_root(const char *new, const char *old)
{
return __nolibc_syscall2(__NR_pivot_root, new, old);
}
@@ -720,7 +720,7 @@ int sys_pivot_root(const char *new, const char *old)
static __attribute__((unused))
int pivot_root(const char *new, const char *old)
{
- return __sysret(sys_pivot_root(new, old));
+ return __sysret(_sys_pivot_root(new, old));
}
@@ -729,7 +729,7 @@ int pivot_root(const char *new, const char *old)
*/
static __attribute__((unused))
-ssize_t sys_read(int fd, void *buf, size_t count)
+ssize_t _sys_read(int fd, void *buf, size_t count)
{
return __nolibc_syscall3(__NR_read, fd, buf, count);
}
@@ -737,7 +737,7 @@ ssize_t sys_read(int fd, void *buf, size_t count)
static __attribute__((unused))
ssize_t read(int fd, void *buf, size_t count)
{
- return __sysret(sys_read(fd, buf, count));
+ return __sysret(_sys_read(fd, buf, count));
}
@@ -746,7 +746,7 @@ ssize_t read(int fd, void *buf, size_t count)
*/
static __attribute__((unused))
-int sys_sched_yield(void)
+int _sys_sched_yield(void)
{
return __nolibc_syscall0(__NR_sched_yield);
}
@@ -754,7 +754,7 @@ int sys_sched_yield(void)
static __attribute__((unused))
int sched_yield(void)
{
- return __sysret(sys_sched_yield());
+ return __sysret(_sys_sched_yield());
}
@@ -763,7 +763,7 @@ int sched_yield(void)
*/
static __attribute__((unused))
-int sys_setpgid(pid_t pid, pid_t pgid)
+int _sys_setpgid(pid_t pid, pid_t pgid)
{
return __nolibc_syscall2(__NR_setpgid, pid, pgid);
}
@@ -771,7 +771,7 @@ int sys_setpgid(pid_t pid, pid_t pgid)
static __attribute__((unused))
int setpgid(pid_t pid, pid_t pgid)
{
- return __sysret(sys_setpgid(pid, pgid));
+ return __sysret(_sys_setpgid(pid, pgid));
}
/*
@@ -790,7 +790,7 @@ pid_t setpgrp(void)
*/
static __attribute__((unused))
-pid_t sys_setsid(void)
+pid_t _sys_setsid(void)
{
return __nolibc_syscall0(__NR_setsid);
}
@@ -798,7 +798,7 @@ pid_t sys_setsid(void)
static __attribute__((unused))
pid_t setsid(void)
{
- return __sysret(sys_setsid());
+ return __sysret(_sys_setsid());
}
@@ -807,7 +807,7 @@ pid_t setsid(void)
*/
static __attribute__((unused))
-int sys_symlink(const char *old, const char *new)
+int _sys_symlink(const char *old, const char *new)
{
#if defined(__NR_symlinkat)
return __nolibc_syscall3(__NR_symlinkat, old, AT_FDCWD, new);
@@ -819,7 +819,7 @@ int sys_symlink(const char *old, const char *new)
static __attribute__((unused))
int symlink(const char *old, const char *new)
{
- return __sysret(sys_symlink(old, new));
+ return __sysret(_sys_symlink(old, new));
}
@@ -828,7 +828,7 @@ int symlink(const char *old, const char *new)
*/
static __attribute__((unused))
-mode_t sys_umask(mode_t mode)
+mode_t _sys_umask(mode_t mode)
{
return __nolibc_syscall1(__NR_umask, mode);
}
@@ -836,7 +836,7 @@ mode_t sys_umask(mode_t mode)
static __attribute__((unused))
mode_t umask(mode_t mode)
{
- return sys_umask(mode);
+ return _sys_umask(mode);
}
@@ -845,7 +845,7 @@ mode_t umask(mode_t mode)
*/
static __attribute__((unused))
-int sys_umount2(const char *path, int flags)
+int _sys_umount2(const char *path, int flags)
{
return __nolibc_syscall2(__NR_umount2, path, flags);
}
@@ -853,7 +853,7 @@ int sys_umount2(const char *path, int flags)
static __attribute__((unused))
int umount2(const char *path, int flags)
{
- return __sysret(sys_umount2(path, flags));
+ return __sysret(_sys_umount2(path, flags));
}
@@ -862,7 +862,7 @@ int umount2(const char *path, int flags)
*/
static __attribute__((unused))
-int sys_unlink(const char *path)
+int _sys_unlink(const char *path)
{
#if defined(__NR_unlinkat)
return __nolibc_syscall3(__NR_unlinkat, AT_FDCWD, path, 0);
@@ -874,7 +874,7 @@ int sys_unlink(const char *path)
static __attribute__((unused))
int unlink(const char *path)
{
- return __sysret(sys_unlink(path));
+ return __sysret(_sys_unlink(path));
}
@@ -883,7 +883,7 @@ int unlink(const char *path)
*/
static __attribute__((unused))
-ssize_t sys_write(int fd, const void *buf, size_t count)
+ssize_t _sys_write(int fd, const void *buf, size_t count)
{
return __nolibc_syscall3(__NR_write, fd, buf, count);
}
@@ -891,7 +891,7 @@ ssize_t sys_write(int fd, const void *buf, size_t count)
static __attribute__((unused))
ssize_t write(int fd, const void *buf, size_t count)
{
- return __sysret(sys_write(fd, buf, count));
+ return __sysret(_sys_write(fd, buf, count));
}
@@ -900,7 +900,7 @@ ssize_t write(int fd, const void *buf, size_t count)
*/
static __attribute__((unused))
-int sys_memfd_create(const char *name, unsigned int flags)
+int _sys_memfd_create(const char *name, unsigned int flags)
{
return __nolibc_syscall2(__NR_memfd_create, name, flags);
}
@@ -908,7 +908,7 @@ int sys_memfd_create(const char *name, unsigned int flags)
static __attribute__((unused))
int memfd_create(const char *name, unsigned int flags)
{
- return __sysret(sys_memfd_create(name, flags));
+ return __sysret(_sys_memfd_create(name, flags));
}
#endif /* _NOLIBC_SYS_H */
diff --git a/tools/include/nolibc/sys/ioctl.h b/tools/include/nolibc/sys/ioctl.h
index 289cc1494f2c..f062a7b806cf 100644
--- a/tools/include/nolibc/sys/ioctl.h
+++ b/tools/include/nolibc/sys/ioctl.h
@@ -19,11 +19,11 @@
*/
static __attribute__((unused))
-long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+long _sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
{
return __nolibc_syscall3(__NR_ioctl, fd, cmd, arg);
}
-#define ioctl(fd, cmd, arg) __sysret(sys_ioctl(fd, cmd, (unsigned long)(arg)))
+#define ioctl(fd, cmd, arg) __sysret(_sys_ioctl(fd, cmd, (unsigned long)(arg)))
#endif /* _NOLIBC_SYS_IOCTL_H */
diff --git a/tools/include/nolibc/sys/mman.h b/tools/include/nolibc/sys/mman.h
index 5679fdda0a87..91d77a51412d 100644
--- a/tools/include/nolibc/sys/mman.h
+++ b/tools/include/nolibc/sys/mman.h
@@ -13,10 +13,10 @@
#include "../arch.h"
#include "../sys.h"
-#ifndef sys_mmap
+#ifndef _sys_mmap
static __attribute__((unused))
-void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
- off_t offset)
+void *_sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
+ off_t offset)
{
int n;
@@ -34,7 +34,7 @@ void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
static __attribute__((unused))
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
- void *ret = sys_mmap(addr, length, prot, flags, fd, offset);
+ void *ret = _sys_mmap(addr, length, prot, flags, fd, offset);
if ((unsigned long)ret >= -4095UL) {
SET_ERRNO(-(long)ret);
@@ -44,7 +44,7 @@ void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
}
static __attribute__((unused))
-void *sys_mremap(void *old_address, size_t old_size, size_t new_size, int flags, void *new_address)
+void *_sys_mremap(void *old_address, size_t old_size, size_t new_size, int flags, void *new_address)
{
return (void *)__nolibc_syscall5(__NR_mremap, old_address, old_size,
new_size, flags, new_address);
@@ -53,7 +53,7 @@ void *sys_mremap(void *old_address, size_t old_size, size_t new_size, int flags,
static __attribute__((unused))
void *mremap(void *old_address, size_t old_size, size_t new_size, int flags, void *new_address)
{
- void *ret = sys_mremap(old_address, old_size, new_size, flags, new_address);
+ void *ret = _sys_mremap(old_address, old_size, new_size, flags, new_address);
if ((unsigned long)ret >= -4095UL) {
SET_ERRNO(-(long)ret);
@@ -63,7 +63,7 @@ void *mremap(void *old_address, size_t old_size, size_t new_size, int flags, voi
}
static __attribute__((unused))
-int sys_munmap(void *addr, size_t length)
+int _sys_munmap(void *addr, size_t length)
{
return __nolibc_syscall2(__NR_munmap, addr, length);
}
@@ -71,7 +71,7 @@ int sys_munmap(void *addr, size_t length)
static __attribute__((unused))
int munmap(void *addr, size_t length)
{
- return __sysret(sys_munmap(addr, length));
+ return __sysret(_sys_munmap(addr, length));
}
#endif /* _NOLIBC_SYS_MMAN_H */
diff --git a/tools/include/nolibc/sys/mount.h b/tools/include/nolibc/sys/mount.h
index 1f8d14da276f..8d3128ebc536 100644
--- a/tools/include/nolibc/sys/mount.h
+++ b/tools/include/nolibc/sys/mount.h
@@ -20,8 +20,8 @@
* const void *data);
*/
static __attribute__((unused))
-int sys_mount(const char *src, const char *tgt, const char *fst,
- unsigned long flags, const void *data)
+int _sys_mount(const char *src, const char *tgt, const char *fst,
+ unsigned long flags, const void *data)
{
return __nolibc_syscall5(__NR_mount, src, tgt, fst, flags, data);
}
@@ -31,7 +31,7 @@ int mount(const char *src, const char *tgt,
const char *fst, unsigned long flags,
const void *data)
{
- return __sysret(sys_mount(src, tgt, fst, flags, data));
+ return __sysret(_sys_mount(src, tgt, fst, flags, data));
}
#endif /* _NOLIBC_SYS_MOUNT_H */
diff --git a/tools/include/nolibc/sys/prctl.h b/tools/include/nolibc/sys/prctl.h
index b019b4618328..3e11d3e5af12 100644
--- a/tools/include/nolibc/sys/prctl.h
+++ b/tools/include/nolibc/sys/prctl.h
@@ -20,8 +20,8 @@
*/
static __attribute__((unused))
-int sys_prctl(int option, unsigned long arg2, unsigned long arg3,
- unsigned long arg4, unsigned long arg5)
+int _sys_prctl(int option, unsigned long arg2, unsigned long arg3,
+ unsigned long arg4, unsigned long arg5)
{
return __nolibc_syscall5(__NR_prctl, option, arg2, arg3, arg4, arg5);
}
@@ -30,7 +30,7 @@ static __attribute__((unused))
int prctl(int option, unsigned long arg2, unsigned long arg3,
unsigned long arg4, unsigned long arg5)
{
- return __sysret(sys_prctl(option, arg2, arg3, arg4, arg5));
+ return __sysret(_sys_prctl(option, arg2, arg3, arg4, arg5));
}
#endif /* _NOLIBC_SYS_PRCTL_H */
diff --git a/tools/include/nolibc/sys/ptrace.h b/tools/include/nolibc/sys/ptrace.h
index 6cde77e93ceb..4c4820f4f336 100644
--- a/tools/include/nolibc/sys/ptrace.h
+++ b/tools/include/nolibc/sys/ptrace.h
@@ -19,7 +19,7 @@
* long ptrace(int op, pid_t pid, void *addr, void *data);
*/
static __attribute__((unused))
-long sys_ptrace(int op, pid_t pid, void *addr, void *data)
+long _sys_ptrace(int op, pid_t pid, void *addr, void *data)
{
return __nolibc_syscall4(__NR_ptrace, op, pid, addr, data);
}
@@ -27,7 +27,7 @@ long sys_ptrace(int op, pid_t pid, void *addr, void *data)
static __attribute__((unused))
ssize_t ptrace(int op, pid_t pid, void *addr, void *data)
{
- return __sysret(sys_ptrace(op, pid, addr, data));
+ return __sysret(_sys_ptrace(op, pid, addr, data));
}
#endif /* _NOLIBC_SYS_PTRACE_H */
diff --git a/tools/include/nolibc/sys/random.h b/tools/include/nolibc/sys/random.h
index af9a270fc29d..6d055b00bd90 100644
--- a/tools/include/nolibc/sys/random.h
+++ b/tools/include/nolibc/sys/random.h
@@ -20,7 +20,7 @@
*/
static __attribute__((unused))
-ssize_t sys_getrandom(void *buf, size_t buflen, unsigned int flags)
+ssize_t _sys_getrandom(void *buf, size_t buflen, unsigned int flags)
{
return __nolibc_syscall3(__NR_getrandom, buf, buflen, flags);
}
@@ -28,7 +28,7 @@ ssize_t sys_getrandom(void *buf, size_t buflen, unsigned int flags)
static __attribute__((unused))
ssize_t getrandom(void *buf, size_t buflen, unsigned int flags)
{
- return __sysret(sys_getrandom(buf, buflen, flags));
+ return __sysret(_sys_getrandom(buf, buflen, flags));
}
#endif /* _NOLIBC_SYS_RANDOM_H */
diff --git a/tools/include/nolibc/sys/reboot.h b/tools/include/nolibc/sys/reboot.h
index 20431025ccc6..73cbca37c1f0 100644
--- a/tools/include/nolibc/sys/reboot.h
+++ b/tools/include/nolibc/sys/reboot.h
@@ -20,7 +20,7 @@
*/
static __attribute__((unused))
-ssize_t sys_reboot(int magic1, int magic2, int cmd, void *arg)
+ssize_t _sys_reboot(int magic1, int magic2, int cmd, void *arg)
{
return __nolibc_syscall4(__NR_reboot, magic1, magic2, cmd, arg);
}
@@ -28,7 +28,7 @@ ssize_t sys_reboot(int magic1, int magic2, int cmd, void *arg)
static __attribute__((unused))
int reboot(int cmd)
{
- return __sysret(sys_reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, NULL));
+ return __sysret(_sys_reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, NULL));
}
#endif /* _NOLIBC_SYS_REBOOT_H */
diff --git a/tools/include/nolibc/sys/resource.h b/tools/include/nolibc/sys/resource.h
index ff3c65f5fade..f35de1c4e9ad 100644
--- a/tools/include/nolibc/sys/resource.h
+++ b/tools/include/nolibc/sys/resource.h
@@ -20,8 +20,8 @@
*/
static __attribute__((unused))
-int sys_prlimit64(pid_t pid, int resource,
- const struct rlimit64 *new_limit, struct rlimit64 *old_limit)
+int _sys_prlimit64(pid_t pid, int resource,
+ const struct rlimit64 *new_limit, struct rlimit64 *old_limit)
{
return __nolibc_syscall4(__NR_prlimit64, pid, resource, new_limit, old_limit);
}
@@ -32,7 +32,7 @@ int getrlimit(int resource, struct rlimit *rlim)
struct rlimit64 rlim64;
int ret;
- ret = __sysret(sys_prlimit64(0, resource, NULL, &rlim64));
+ ret = __sysret(_sys_prlimit64(0, resource, NULL, &rlim64));
rlim->rlim_cur = rlim64.rlim_cur;
rlim->rlim_max = rlim64.rlim_max;
@@ -47,7 +47,7 @@ int setrlimit(int resource, const struct rlimit *rlim)
.rlim_max = rlim->rlim_max,
};
- return __sysret(sys_prlimit64(0, resource, &rlim64, NULL));
+ return __sysret(_sys_prlimit64(0, resource, &rlim64, NULL));
}
#endif /* _NOLIBC_SYS_RESOURCE_H */
diff --git a/tools/include/nolibc/sys/select.h b/tools/include/nolibc/sys/select.h
index fcbcf4d0f8d1..6d65d9ef3d6a 100644
--- a/tools/include/nolibc/sys/select.h
+++ b/tools/include/nolibc/sys/select.h
@@ -61,7 +61,7 @@ typedef struct {
*/
static __attribute__((unused))
-int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeout)
+int _sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeout)
{
#if defined(__NR_pselect6_time64)
struct __kernel_timespec t;
@@ -87,7 +87,7 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva
static __attribute__((unused))
int select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeout)
{
- return __sysret(sys_select(nfds, rfds, wfds, efds, timeout));
+ return __sysret(_sys_select(nfds, rfds, wfds, efds, timeout));
}
diff --git a/tools/include/nolibc/sys/stat.h b/tools/include/nolibc/sys/stat.h
index 2777217793db..b2ef34a617ca 100644
--- a/tools/include/nolibc/sys/stat.h
+++ b/tools/include/nolibc/sys/stat.h
@@ -23,7 +23,7 @@
*/
static __attribute__((unused))
-int sys_statx(int fd, const char *path, int flags, unsigned int mask, struct statx *buf)
+int _sys_statx(int fd, const char *path, int flags, unsigned int mask, struct statx *buf)
{
#ifdef __NR_statx
return __nolibc_syscall5(__NR_statx, fd, path, flags, mask, buf);
@@ -35,7 +35,7 @@ int sys_statx(int fd, const char *path, int flags, unsigned int mask, struct sta
static __attribute__((unused))
int statx(int fd, const char *path, int flags, unsigned int mask, struct statx *buf)
{
- return __sysret(sys_statx(fd, path, flags, mask, buf));
+ return __sysret(_sys_statx(fd, path, flags, mask, buf));
}
@@ -45,7 +45,7 @@ int fstatat(int fd, const char *path, struct stat *buf, int flag)
struct statx statx;
long ret;
- ret = __sysret(sys_statx(fd, path, flag | AT_NO_AUTOMOUNT, STATX_BASIC_STATS, &statx));
+ ret = __sysret(_sys_statx(fd, path, flag | AT_NO_AUTOMOUNT, STATX_BASIC_STATS, &statx));
if (ret == -1)
return ret;
diff --git a/tools/include/nolibc/sys/time.h b/tools/include/nolibc/sys/time.h
index afdb7e326df1..c3bb47f69f06 100644
--- a/tools/include/nolibc/sys/time.h
+++ b/tools/include/nolibc/sys/time.h
@@ -13,21 +13,21 @@
#include "../arch.h"
#include "../sys.h"
-static int sys_clock_gettime(clockid_t clockid, struct timespec *tp);
+static int _sys_clock_gettime(clockid_t clockid, struct timespec *tp);
/*
* int gettimeofday(struct timeval *tv, struct timezone *tz);
*/
static __attribute__((unused))
-int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
+int _sys_gettimeofday(struct timeval *tv, struct timezone *tz)
{
(void) tz; /* Non-NULL tz is undefined behaviour */
struct timespec tp;
int ret;
- ret = sys_clock_gettime(CLOCK_REALTIME, &tp);
+ ret = _sys_clock_gettime(CLOCK_REALTIME, &tp);
if (!ret && tv) {
tv->tv_sec = tp.tv_sec;
tv->tv_usec = (uint32_t)tp.tv_nsec / 1000;
@@ -39,7 +39,7 @@ int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
static __attribute__((unused))
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
- return __sysret(sys_gettimeofday(tv, tz));
+ return __sysret(_sys_gettimeofday(tv, tz));
}
#endif /* _NOLIBC_SYS_TIME_H */
diff --git a/tools/include/nolibc/sys/timerfd.h b/tools/include/nolibc/sys/timerfd.h
index 87f89c789b3b..cb7fef37a7a4 100644
--- a/tools/include/nolibc/sys/timerfd.h
+++ b/tools/include/nolibc/sys/timerfd.h
@@ -17,7 +17,7 @@
static __attribute__((unused))
-int sys_timerfd_create(int clockid, int flags)
+int _sys_timerfd_create(int clockid, int flags)
{
return __nolibc_syscall2(__NR_timerfd_create, clockid, flags);
}
@@ -25,12 +25,12 @@ int sys_timerfd_create(int clockid, int flags)
static __attribute__((unused))
int timerfd_create(int clockid, int flags)
{
- return __sysret(sys_timerfd_create(clockid, flags));
+ return __sysret(_sys_timerfd_create(clockid, flags));
}
static __attribute__((unused))
-int sys_timerfd_gettime(int fd, struct itimerspec *curr_value)
+int _sys_timerfd_gettime(int fd, struct itimerspec *curr_value)
{
#if defined(__NR_timerfd_gettime64)
__nolibc_assert_time64_type(curr_value->it_value.tv_sec);
@@ -44,13 +44,13 @@ int sys_timerfd_gettime(int fd, struct itimerspec *curr_value)
static __attribute__((unused))
int timerfd_gettime(int fd, struct itimerspec *curr_value)
{
- return __sysret(sys_timerfd_gettime(fd, curr_value));
+ return __sysret(_sys_timerfd_gettime(fd, curr_value));
}
static __attribute__((unused))
-int sys_timerfd_settime(int fd, int flags,
- const struct itimerspec *new_value, struct itimerspec *old_value)
+int _sys_timerfd_settime(int fd, int flags,
+ const struct itimerspec *new_value, struct itimerspec *old_value)
{
#if defined(__NR_timerfd_settime64)
__nolibc_assert_time64_type(new_value->it_value.tv_sec);
@@ -65,7 +65,7 @@ static __attribute__((unused))
int timerfd_settime(int fd, int flags,
const struct itimerspec *new_value, struct itimerspec *old_value)
{
- return __sysret(sys_timerfd_settime(fd, flags, new_value, old_value));
+ return __sysret(_sys_timerfd_settime(fd, flags, new_value, old_value));
}
#endif /* _NOLIBC_SYS_TIMERFD_H */
diff --git a/tools/include/nolibc/sys/uio.h b/tools/include/nolibc/sys/uio.h
index 21ff8c626dfe..06bf17ddd5d2 100644
--- a/tools/include/nolibc/sys/uio.h
+++ b/tools/include/nolibc/sys/uio.h
@@ -19,7 +19,7 @@
* ssize_t readv(int fd, const struct iovec *iovec, int count);
*/
static __attribute__((unused))
-ssize_t sys_readv(int fd, const struct iovec *iovec, int count)
+ssize_t _sys_readv(int fd, const struct iovec *iovec, int count)
{
return __nolibc_syscall3(__NR_readv, fd, iovec, count);
}
@@ -27,14 +27,14 @@ ssize_t sys_readv(int fd, const struct iovec *iovec, int count)
static __attribute__((unused))
ssize_t readv(int fd, const struct iovec *iovec, int count)
{
- return __sysret(sys_readv(fd, iovec, count));
+ return __sysret(_sys_readv(fd, iovec, count));
}
/*
* ssize_t writev(int fd, const struct iovec *iovec, int count);
*/
static __attribute__((unused))
-ssize_t sys_writev(int fd, const struct iovec *iovec, int count)
+ssize_t _sys_writev(int fd, const struct iovec *iovec, int count)
{
return __nolibc_syscall3(__NR_writev, fd, iovec, count);
}
@@ -42,7 +42,7 @@ ssize_t sys_writev(int fd, const struct iovec *iovec, int count)
static __attribute__((unused))
ssize_t writev(int fd, const struct iovec *iovec, int count)
{
- return __sysret(sys_writev(fd, iovec, count));
+ return __sysret(_sys_writev(fd, iovec, count));
}
diff --git a/tools/include/nolibc/sys/utsname.h b/tools/include/nolibc/sys/utsname.h
index 25992d644525..2aaf873b7985 100644
--- a/tools/include/nolibc/sys/utsname.h
+++ b/tools/include/nolibc/sys/utsname.h
@@ -28,7 +28,7 @@ struct utsname {
};
static __attribute__((unused))
-int sys_uname(struct utsname *buf)
+int _sys_uname(struct utsname *buf)
{
return __nolibc_syscall1(__NR_uname, buf);
}
@@ -36,7 +36,7 @@ int sys_uname(struct utsname *buf)
static __attribute__((unused))
int uname(struct utsname *buf)
{
- return __sysret(sys_uname(buf));
+ return __sysret(_sys_uname(buf));
}
#endif /* _NOLIBC_SYS_UTSNAME_H */
diff --git a/tools/include/nolibc/sys/wait.h b/tools/include/nolibc/sys/wait.h
index bc11100e7f82..7a1feb2b66fc 100644
--- a/tools/include/nolibc/sys/wait.h
+++ b/tools/include/nolibc/sys/wait.h
@@ -21,7 +21,7 @@
*/
static __attribute__((unused))
-int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct rusage *rusage)
+int _sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct rusage *rusage)
{
return __nolibc_syscall5(__NR_waitid, which, pid, infop, options, rusage);
}
@@ -29,7 +29,7 @@ int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct rusag
static __attribute__((unused))
int waitid(int which, pid_t pid, siginfo_t *infop, int options)
{
- return __sysret(sys_waitid(which, pid, infop, options, NULL));
+ return __sysret(_sys_waitid(which, pid, infop, options, NULL));
}
diff --git a/tools/include/nolibc/time.h b/tools/include/nolibc/time.h
index 4d93d5188cec..9ba930710ff9 100644
--- a/tools/include/nolibc/time.h
+++ b/tools/include/nolibc/time.h
@@ -33,7 +33,7 @@
*/
static __attribute__((unused))
-int sys_clock_getres(clockid_t clockid, struct timespec *res)
+int _sys_clock_getres(clockid_t clockid, struct timespec *res)
{
#if defined(__NR_clock_getres_time64)
__nolibc_assert_time64_type(res->tv_sec);
@@ -47,11 +47,11 @@ int sys_clock_getres(clockid_t clockid, struct timespec *res)
static __attribute__((unused))
int clock_getres(clockid_t clockid, struct timespec *res)
{
- return __sysret(sys_clock_getres(clockid, res));
+ return __sysret(_sys_clock_getres(clockid, res));
}
static __attribute__((unused))
-int sys_clock_gettime(clockid_t clockid, struct timespec *tp)
+int _sys_clock_gettime(clockid_t clockid, struct timespec *tp)
{
#if defined(__NR_clock_gettime64)
__nolibc_assert_time64_type(tp->tv_sec);
@@ -65,11 +65,11 @@ int sys_clock_gettime(clockid_t clockid, struct timespec *tp)
static __attribute__((unused))
int clock_gettime(clockid_t clockid, struct timespec *tp)
{
- return __sysret(sys_clock_gettime(clockid, tp));
+ return __sysret(_sys_clock_gettime(clockid, tp));
}
static __attribute__((unused))
-int sys_clock_settime(clockid_t clockid, struct timespec *tp)
+int _sys_clock_settime(clockid_t clockid, struct timespec *tp)
{
#if defined(__NR_clock_settime64)
__nolibc_assert_time64_type(tp->tv_sec);
@@ -83,12 +83,12 @@ int sys_clock_settime(clockid_t clockid, struct timespec *tp)
static __attribute__((unused))
int clock_settime(clockid_t clockid, struct timespec *tp)
{
- return __sysret(sys_clock_settime(clockid, tp));
+ return __sysret(_sys_clock_settime(clockid, tp));
}
static __attribute__((unused))
-int sys_clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp,
- struct timespec *rmtp)
+int _sys_clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp,
+ struct timespec *rmtp)
{
#if defined(__NR_clock_nanosleep_time64)
__nolibc_assert_time64_type(rqtp->tv_sec);
@@ -104,7 +104,7 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp,
struct timespec *rmtp)
{
/* Directly return a positive error number */
- return -sys_clock_nanosleep(clockid, flags, rqtp, rmtp);
+ return -_sys_clock_nanosleep(clockid, flags, rqtp, rmtp);
}
static __inline__
@@ -116,7 +116,7 @@ double difftime(time_t time1, time_t time2)
static __inline__
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
- return __sysret(sys_clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rmtp));
+ return __sysret(_sys_clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rmtp));
}
@@ -126,7 +126,7 @@ time_t time(time_t *tptr)
struct timeval tv;
/* note, cannot fail here */
- sys_gettimeofday(&tv, NULL);
+ _sys_gettimeofday(&tv, NULL);
if (tptr)
*tptr = tv.tv_sec;
@@ -141,7 +141,7 @@ time_t time(time_t *tptr)
*/
static __attribute__((unused))
-int sys_timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
+int _sys_timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
{
return __nolibc_syscall3(__NR_timer_create, clockid, evp, timerid);
}
@@ -149,11 +149,11 @@ int sys_timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
static __attribute__((unused))
int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
{
- return __sysret(sys_timer_create(clockid, evp, timerid));
+ return __sysret(_sys_timer_create(clockid, evp, timerid));
}
static __attribute__((unused))
-int sys_timer_delete(timer_t timerid)
+int _sys_timer_delete(timer_t timerid)
{
return __nolibc_syscall1(__NR_timer_delete, timerid);
}
@@ -161,11 +161,11 @@ int sys_timer_delete(timer_t timerid)
static __attribute__((unused))
int timer_delete(timer_t timerid)
{
- return __sysret(sys_timer_delete(timerid));
+ return __sysret(_sys_timer_delete(timerid));
}
static __attribute__((unused))
-int sys_timer_gettime(timer_t timerid, struct itimerspec *curr_value)
+int _sys_timer_gettime(timer_t timerid, struct itimerspec *curr_value)
{
#if defined(__NR_timer_gettime64)
__nolibc_assert_time64_type(curr_value->it_value.tv_sec);
@@ -179,12 +179,12 @@ int sys_timer_gettime(timer_t timerid, struct itimerspec *curr_value)
static __attribute__((unused))
int timer_gettime(timer_t timerid, struct itimerspec *curr_value)
{
- return __sysret(sys_timer_gettime(timerid, curr_value));
+ return __sysret(_sys_timer_gettime(timerid, curr_value));
}
static __attribute__((unused))
-int sys_timer_settime(timer_t timerid, int flags,
- const struct itimerspec *new_value, struct itimerspec *old_value)
+int _sys_timer_settime(timer_t timerid, int flags,
+ const struct itimerspec *new_value, struct itimerspec *old_value)
{
#if defined(__NR_timer_settime64)
__nolibc_assert_time64_type(new_value->it_value.tv_sec);
@@ -199,7 +199,7 @@ static __attribute__((unused))
int timer_settime(timer_t timerid, int flags,
const struct itimerspec *new_value, struct itimerspec *old_value)
{
- return __sysret(sys_timer_settime(timerid, flags, new_value, old_value));
+ return __sysret(_sys_timer_settime(timerid, flags, new_value, old_value));
}
#endif /* _NOLIBC_TIME_H */
diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h
index 6456d60daa02..5882a6862066 100644
--- a/tools/include/nolibc/unistd.h
+++ b/tools/include/nolibc/unistd.h
@@ -31,7 +31,7 @@
*/
static __attribute__((unused))
-int sys_faccessat(int fd, const char *path, int amode, int flag)
+int _sys_faccessat(int fd, const char *path, int amode, int flag)
{
return __nolibc_syscall4(__NR_faccessat, fd, path, amode, flag);
}
@@ -39,7 +39,7 @@ int sys_faccessat(int fd, const char *path, int amode, int flag)
static __attribute__((unused))
int faccessat(int fd, const char *path, int amode, int flag)
{
- return __sysret(sys_faccessat(fd, path, amode, flag));
+ return __sysret(_sys_faccessat(fd, path, amode, flag));
}
static __attribute__((unused))
@@ -54,7 +54,7 @@ int msleep(unsigned int msecs)
{
struct timeval my_timeval = { msecs / 1000, (msecs % 1000) * 1000 };
- if (sys_select(0, NULL, NULL, NULL, &my_timeval) < 0)
+ if (_sys_select(0, NULL, NULL, NULL, &my_timeval) < 0)
return (my_timeval.tv_sec * 1000) +
(my_timeval.tv_usec / 1000) +
!!(my_timeval.tv_usec % 1000);
@@ -67,7 +67,7 @@ unsigned int sleep(unsigned int seconds)
{
struct timeval my_timeval = { seconds, 0 };
- if (sys_select(0, NULL, NULL, NULL, &my_timeval) < 0)
+ if (_sys_select(0, NULL, NULL, NULL, &my_timeval) < 0)
return my_timeval.tv_sec + !!my_timeval.tv_usec;
else
return 0;
@@ -78,7 +78,7 @@ int usleep(unsigned int usecs)
{
struct timeval my_timeval = { usecs / 1000000, usecs % 1000000 };
- return sys_select(0, NULL, NULL, NULL, &my_timeval);
+ return _sys_select(0, NULL, NULL, NULL, &my_timeval);
}
static __attribute__((unused))
---
base-commit: 82436bacd5b2c0243f2d1a45f53f960aa24e5c56
change-id: 20260225-nolibc-namespacing-a5f9b5a497a3
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] tools/nolibc: rename sys_foo() functions to _sys_foo()
2026-03-19 16:20 [PATCH] tools/nolibc: rename sys_foo() functions to _sys_foo() Thomas Weißschuh
@ 2026-03-22 9:06 ` Willy Tarreau
2026-03-22 10:43 ` Thomas Weißschuh
0 siblings, 1 reply; 6+ messages in thread
From: Willy Tarreau @ 2026-03-22 9:06 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: linux-kernel
Hi Thomas,
On Thu, Mar 19, 2026 at 05:20:17PM +0100, Thomas Weißschuh wrote:
> The sys_foo() naming scheme used by the syscall wrappers may collide
> with application symbols. Especially as 'sys_' is an obvious naming
> scheme an application may choose for its own custom systemcall wrappers.
Yes but on the other hand it might implement it when missing the one
offered by the libc.
> Avoid these conflicts by using an leading underscore which moves the
> names into the implementation's namespace. This naming scheme was chosen
> over a '__nolibc_' prefix, as these functions are not an implementation
> detail but a documented interface meant to be used by applications.
Agreed.
> While this may break some existing users, adapting them should be
> straightforward. Given that nolibc is most-likely vendored, no
> unexpected breakage should happen. No in-tree users are affected.
I also checked in my local stuff (preinit, watchdog daemon etc) and
didn't find any user of sys_*.
> These conflicts happen when compiling some of the kernel selftests
> with nolibc.
You mean some of the syscall entry points ? If so, I'm seeing one
exception of _sys_rt_sigreturn(), not convinced it could be an issue
though.
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> I am not really thrilled about breaking these names.
> But every other option seems to be horribly to maintain
> or will break sooner or later anyways.
> Any ideas?
I think your approach is reasonable for the reasons you explained. Yes we
do want to continue to export these, and they're not supposed to be spread
all over application code, so changes if any should be very limited. So:
Acked-by: Willy Tarreau <w@1wt.eu>
On a related topic, I've been thinking several times about how to discover
support or not of a syscall in nolibc by the application, especially since
the lib improves fast and applications might not want to wait for it to
support a new syscall, and end up with their own as you suggested above.
Maybe this _sys_foo thing could be the opportunity for us to generalize
the systematic addition of:
#define _sys_foo _sys_foo
before every definition, so that application can simply use #ifndef to
define their own local version. There's no emergency, it's been that way
for years, I'm sharing it just as food for thought.
Cheers,
Willy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/nolibc: rename sys_foo() functions to _sys_foo()
2026-03-22 9:06 ` Willy Tarreau
@ 2026-03-22 10:43 ` Thomas Weißschuh
2026-03-22 11:03 ` Willy Tarreau
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Weißschuh @ 2026-03-22 10:43 UTC (permalink / raw)
To: Willy Tarreau; +Cc: linux-kernel
On 2026-03-22 10:06:42+0100, Willy Tarreau wrote:
> On Thu, Mar 19, 2026 at 05:20:17PM +0100, Thomas Weißschuh wrote:
> > The sys_foo() naming scheme used by the syscall wrappers may collide
> > with application symbols. Especially as 'sys_' is an obvious naming
> > scheme an application may choose for its own custom systemcall wrappers.
>
> Yes but on the other hand it might implement it when missing the one
> offered by the libc.
I don't really get this sentence. Do you refer to the '#ifdef sys_foo'
as you mention below?
(...)
> > While this may break some existing users, adapting them should be
> > straightforward. Given that nolibc is most-likely vendored, no
> > unexpected breakage should happen. No in-tree users are affected.
>
> I also checked in my local stuff (preinit, watchdog daemon etc) and
> didn't find any user of sys_*.
Nice!
> > These conflicts happen when compiling some of the kernel selftests
> > with nolibc.
>
> You mean some of the syscall entry points ? If so, I'm seeing one
> exception of _sys_rt_sigreturn(), not convinced it could be an issue
> though.
Not the syscall entrypoints, these are internal to the kernel.
Some selftests bypass libc (for various, legitimate reasons) and
directly call the syscalls. They tend to name their wrappers
'sys_foo()'.
See for example these:
* tools/testing/selftests/vDSO/vdso_test_correctness.c
* tools/testing/selftests/bpf/bpf_util.h
* tools/testing/selftests/bpf/task_local_storage_helpers.h
* tools/testing/selftests/rseq/param_test.c
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > ---
> > I am not really thrilled about breaking these names.
> > But every other option seems to be horribly to maintain
> > or will break sooner or later anyways.
> > Any ideas?
>
> I think your approach is reasonable for the reasons you explained. Yes we
> do want to continue to export these, and they're not supposed to be spread
> all over application code, so changes if any should be very limited. So:
>
> Acked-by: Willy Tarreau <w@1wt.eu>
Thanks! And pushed to the git tree.
> On a related topic, I've been thinking several times about how to discover
> support or not of a syscall in nolibc by the application, especially since
> the lib improves fast and applications might not want to wait for it to
> support a new syscall, and end up with their own as you suggested above.
> Maybe this _sys_foo thing could be the opportunity for us to generalize
> the systematic addition of:
>
> #define _sys_foo _sys_foo
>
> before every definition, so that application can simply use #ifndef to
> define their own local version. There's no emergency, it's been that way
> for years, I'm sharing it just as food for thought.
I am not sure about that.
In the most common case, where the version of nolibc is locked,
the local version would either be used all the time or never.
So any ifdeffery would only make the code harder to read.
Even if a user really needs to handle different versions of nolibc,
in my opinion they should just always use their custom code to make
sure to keep the behavior predictable.
Thomas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/nolibc: rename sys_foo() functions to _sys_foo()
2026-03-22 10:43 ` Thomas Weißschuh
@ 2026-03-22 11:03 ` Willy Tarreau
2026-03-24 17:01 ` Thomas Weißschuh
0 siblings, 1 reply; 6+ messages in thread
From: Willy Tarreau @ 2026-03-22 11:03 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: linux-kernel
On Sun, Mar 22, 2026 at 11:43:56AM +0100, Thomas Weißschuh wrote:
> On 2026-03-22 10:06:42+0100, Willy Tarreau wrote:
> > On Thu, Mar 19, 2026 at 05:20:17PM +0100, Thomas Weißschuh wrote:
> > > The sys_foo() naming scheme used by the syscall wrappers may collide
> > > with application symbols. Especially as 'sys_' is an obvious naming
> > > scheme an application may choose for its own custom systemcall wrappers.
> >
> > Yes but on the other hand it might implement it when missing the one
> > offered by the libc.
>
> I don't really get this sentence. Do you refer to the '#ifdef sys_foo'
> as you mention below?
Ah no, but rereading my message shows me it was not really parsable :-)
I meant that some applications missing a syscall in nolibc (and detecting
this miss via any method) could decide to implement their own equivalent
for the time it takes to integrate the feature into nolibc, and thus it
can make sense that they call their feature sys_foo like we do, so that
their sys_foo is basically the same as ours (i.e. they really just have
to detect the conflict one way or another but that's all).
> > > These conflicts happen when compiling some of the kernel selftests
> > > with nolibc.
> >
> > You mean some of the syscall entry points ? If so, I'm seeing one
> > exception of _sys_rt_sigreturn(), not convinced it could be an issue
> > though.
>
> Not the syscall entrypoints, these are internal to the kernel.
That's why it surprised me ;-)
> Some selftests bypass libc (for various, legitimate reasons) and
> directly call the syscalls. They tend to name their wrappers
> 'sys_foo()'.
>
> See for example these:
> * tools/testing/selftests/vDSO/vdso_test_correctness.c
> * tools/testing/selftests/bpf/bpf_util.h
> * tools/testing/selftests/bpf/task_local_storage_helpers.h
> * tools/testing/selftests/rseq/param_test.c
Ah OK! That totally makes sense.
> Thanks! And pushed to the git tree.
Thank you!
> > On a related topic, I've been thinking several times about how to discover
> > support or not of a syscall in nolibc by the application, especially since
> > the lib improves fast and applications might not want to wait for it to
> > support a new syscall, and end up with their own as you suggested above.
> > Maybe this _sys_foo thing could be the opportunity for us to generalize
> > the systematic addition of:
> >
> > #define _sys_foo _sys_foo
> >
> > before every definition, so that application can simply use #ifndef to
> > define their own local version. There's no emergency, it's been that way
> > for years, I'm sharing it just as food for thought.
>
> I am not sure about that.
>
> In the most common case, where the version of nolibc is locked,
> the local version would either be used all the time or never.
> So any ifdeffery would only make the code harder to read.
> Even if a user really needs to handle different versions of nolibc,
> in my opinion they should just always use their custom code to make
> sure to keep the behavior predictable.
In fact it's not about handling different versions, it's really about
working around what's missing. I face this every day as a userland
developer. As soon as you depend on a lib, you figure something is
missing, and you cannot stop your project because of this. So the
right thing to do is to implement what you're missing in a mostly
discoverable way, and the try to upstream your work into the lib that
was missing the feature.
Inside the kernel, this problem is less visible because it's the same
repository, so anyone working on their selftest etc can also directly
commit into the nolibc subdir as well. When you're using code outside
it's totally different, as you have less control over the selection of
kernel headers version, hence nolibc version.
I personally don't think that a single define in front of each syscall
definition will make the code harder to read. It can be argued that glibc
doesn't offer this and that the user application will have to compose with
all of this, however glibc offers lots more stuff than we do, and users
rely on its version to guess whether or not something is present, which
is something we don't really have.
Willy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/nolibc: rename sys_foo() functions to _sys_foo()
2026-03-22 11:03 ` Willy Tarreau
@ 2026-03-24 17:01 ` Thomas Weißschuh
2026-03-29 5:06 ` Willy Tarreau
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Weißschuh @ 2026-03-24 17:01 UTC (permalink / raw)
To: Willy Tarreau; +Cc: linux-kernel
On 2026-03-22 12:03:30+0100, Willy Tarreau wrote:
> On Sun, Mar 22, 2026 at 11:43:56AM +0100, Thomas Weißschuh wrote:
> > On 2026-03-22 10:06:42+0100, Willy Tarreau wrote:
> > > On Thu, Mar 19, 2026 at 05:20:17PM +0100, Thomas Weißschuh wrote:
> > > > The sys_foo() naming scheme used by the syscall wrappers may collide
> > > > with application symbols. Especially as 'sys_' is an obvious naming
> > > > scheme an application may choose for its own custom systemcall wrappers.
> > >
> > > Yes but on the other hand it might implement it when missing the one
> > > offered by the libc.
> >
> > I don't really get this sentence. Do you refer to the '#ifdef sys_foo'
> > as you mention below?
>
> Ah no, but rereading my message shows me it was not really parsable :-)
> I meant that some applications missing a syscall in nolibc (and detecting
> this miss via any method) could decide to implement their own equivalent
> for the time it takes to integrate the feature into nolibc, and thus it
> can make sense that they call their feature sys_foo like we do, so that
> their sys_foo is basically the same as ours (i.e. they really just have
> to detect the conflict one way or another but that's all).
What is the advantage of switching over to the nolibc-provided
implementation? The custom implementation would be good enough anyways.
(...)
> > > On a related topic, I've been thinking several times about how to discover
> > > support or not of a syscall in nolibc by the application, especially since
> > > the lib improves fast and applications might not want to wait for it to
> > > support a new syscall, and end up with their own as you suggested above.
> > > Maybe this _sys_foo thing could be the opportunity for us to generalize
> > > the systematic addition of:
> > >
> > > #define _sys_foo _sys_foo
> > >
> > > before every definition, so that application can simply use #ifndef to
> > > define their own local version. There's no emergency, it's been that way
> > > for years, I'm sharing it just as food for thought.
> >
> > I am not sure about that.
> >
> > In the most common case, where the version of nolibc is locked,
> > the local version would either be used all the time or never.
> > So any ifdeffery would only make the code harder to read.
> > Even if a user really needs to handle different versions of nolibc,
> > in my opinion they should just always use their custom code to make
> > sure to keep the behavior predictable.
>
> In fact it's not about handling different versions, it's really about
> working around what's missing. I face this every day as a userland
> developer. As soon as you depend on a lib, you figure something is
> missing, and you cannot stop your project because of this. So the
> right thing to do is to implement what you're missing in a mostly
> discoverable way, and the try to upstream your work into the lib that
> was missing the feature.
That makes sense where you have to work with the external library in the
form it is provided to you by somebody else. nolibc should be vendored,
so you always know exactly what it supports. Or do you have existing
usecases where you detect nolibc features?
> Inside the kernel, this problem is less visible because it's the same
> repository, so anyone working on their selftest etc can also directly
> commit into the nolibc subdir as well. When you're using code outside
> it's totally different, as you have less control over the selection of
> kernel headers version, hence nolibc version.
With the UAPI headers the detection makes slightly more sense.
On the other hand we try to be backwards-compatible to fairly old
versions.
> I personally don't think that a single define in front of each syscall
> definition will make the code harder to read. It can be argued that glibc
> doesn't offer this and that the user application will have to compose with
> all of this, however glibc offers lots more stuff than we do, and users
> rely on its version to guess whether or not something is present, which
> is something we don't really have.
I don't think it makes the code worse or really have anything against it
in general. I just don't really see the advantage. For glibc this makes
sense, as an application will have to do with the version that is
present during compilation and at runtime. For nolibc this doesn't
really happen. Or I might be missing something :-)
If we adopt that scheme it should not only cover the _sys_*() functions
but also the regular ones, no?
Thomas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/nolibc: rename sys_foo() functions to _sys_foo()
2026-03-24 17:01 ` Thomas Weißschuh
@ 2026-03-29 5:06 ` Willy Tarreau
0 siblings, 0 replies; 6+ messages in thread
From: Willy Tarreau @ 2026-03-29 5:06 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: linux-kernel
Hi Thomas,
On Tue, Mar 24, 2026 at 06:01:35PM +0100, Thomas Weißschuh wrote:
> On 2026-03-22 12:03:30+0100, Willy Tarreau wrote:
> > On Sun, Mar 22, 2026 at 11:43:56AM +0100, Thomas Weißschuh wrote:
> > > On 2026-03-22 10:06:42+0100, Willy Tarreau wrote:
> > > > On Thu, Mar 19, 2026 at 05:20:17PM +0100, Thomas Weißschuh wrote:
> > > > > The sys_foo() naming scheme used by the syscall wrappers may collide
> > > > > with application symbols. Especially as 'sys_' is an obvious naming
> > > > > scheme an application may choose for its own custom systemcall wrappers.
> > > >
> > > > Yes but on the other hand it might implement it when missing the one
> > > > offered by the libc.
> > >
> > > I don't really get this sentence. Do you refer to the '#ifdef sys_foo'
> > > as you mention below?
> >
> > Ah no, but rereading my message shows me it was not really parsable :-)
> > I meant that some applications missing a syscall in nolibc (and detecting
> > this miss via any method) could decide to implement their own equivalent
> > for the time it takes to integrate the feature into nolibc, and thus it
> > can make sense that they call their feature sys_foo like we do, so that
> > their sys_foo is basically the same as ours (i.e. they really just have
> > to detect the conflict one way or another but that's all).
>
> What is the advantage of switching over to the nolibc-provided
> implementation? The custom implementation would be good enough anyways.
It's not an "advantage", it's just remaining compatible. When you have
to locally implement some missing functions, and your build breaks again
once you update nolibc, it's a real pain, and sometimes depending on the
environment you have different toolchain versions, yet you don't want to
be forced to fork your local code which didn't change between the versions.
> > In fact it's not about handling different versions, it's really about
> > working around what's missing. I face this every day as a userland
> > developer. As soon as you depend on a lib, you figure something is
> > missing, and you cannot stop your project because of this. So the
> > right thing to do is to implement what you're missing in a mostly
> > discoverable way, and the try to upstream your work into the lib that
> > was missing the feature.
>
> That makes sense where you have to work with the external library in the
> form it is provided to you by somebody else. nolibc should be vendored,
> so you always know exactly what it supports. Or do you have existing
> usecases where you detect nolibc features?
I'm not sure to understand what you mean here. Let's take this example
for illustration, that I have in my preinit code:
static void enable_signals(void)
{
struct sigaction act = { 0 };
sigset_t blk = { 0 };
#ifdef NOLIBC
#ifdef SA_RESTORER
act.sa_flags = SA_RESTORER;
act.sa_restorer = sig_return;
#endif
act.sa_handler = sig_handler;
my_syscall4(__NR_rt_sigaction, SIGTERM, &act, NULL, sizeof(sigset_t));
my_syscall4(__NR_rt_sigaction, SIGINT, &act, NULL, sizeof(sigset_t));
my_syscall4(__NR_rt_sigprocmask, SIG_SETMASK, &blk, NULL, sizeof(sigset_t));
#else
signal(SIGTERM, sig_handler);
signal(SIGINT, sig_handler);
sigprocmask(SIG_SETMASK, &blk, NULL);
#endif
}
Since this is where nolibc was born, I've always been very careful about
not redefining standard calls (this is where all the my_* stuff came
from). A cleaner implementation would have donne this:
#if defined(NOLIBC)
typedef void (*sighandler_t)(int);
sighandler_t signal(int signum, sighandler_t handler)
{
struct sigaction act = { 0 };
#ifdef SA_RESTORER
act.sa_flags = SA_RESTORER;
act.sa_restorer = sig_return;
#endif
act.sa_handler = sig_handler;
my_syscall4(__NR_rt_sigaction, SIGTERM, &act, NULL, sizeof(sigset_t));
my_syscall4(__NR_rt_sigaction, SIGINT, &act, NULL, sizeof(sigset_t));
my_syscall4(__NR_rt_sigprocmask, SIG_SETMASK, &blk, NULL, sizeof(sigset_t));
}
#endif
static void enable_signals(void)
{
sigset_t blk = { 0 };
signal(SIGTERM, sig_handler);
signal(SIGINT, sig_handler);
sigprocmask(SIG_SETMASK, &blk, NULL);
}
With a patch applied to nolibc to include that new signal() definition.
But the day nolibc is updated, this code would break, with no easy way
to detect the support of the function. By experience I know pretty well
how it would end up, I'd look for a #define that appeared in a very
close version and would detect it as a proxy for the supporting nolibc
version. But this remains ugly.
A cleaner approach would be something like this:
#if defined(NOLIBC) && !defined(signal)
or maybe:
#if defined(NOLIBC) && !defined(_NOLIBC_HAVE_signal)
Note that it could work both ways. For example we removed support for
wait4() a while ago, and it could have been nice to be able to detect
it as well.
> > Inside the kernel, this problem is less visible because it's the same
> > repository, so anyone working on their selftest etc can also directly
> > commit into the nolibc subdir as well. When you're using code outside
> > it's totally different, as you have less control over the selection of
> > kernel headers version, hence nolibc version.
>
> With the UAPI headers the detection makes slightly more sense.
> On the other hand we try to be backwards-compatible to fairly old
> versions.
Not that much actually. I got some breakage a few months ago due to
upgrading nolibc for a coworker to benefit from something I don't
remember and that wouldn't build. It just failed to boot because of
the recent abandon for stat() in favor of statx() that causes silent
failures when __NR_statx is not defined. It turns out that the toolchain
was built with support for kernel 4.9 and above and didn't need to be
upgraded, and since kernel forward compatibility is pretty good, this
has always been fine. But there sys_stat() was silently implemented as
"return -ENOSYS" which made the system fail to boot. I could quickly
bisect and offer him a copy of nolibc from 6.1 which was still
compatible and had the missing feature I needed. As a comparison, I
checked, and glibc-2.44 on my local machine was built with support
for kernel 4.4 and above, and it probably still supports much older
ones for various reasons.
This made me think that it was not a good idea in the end to report
-ENOSYS, it should only be left to the kernel (i.e. runtime detect)
but not build time detection. In other programs I've employed link
time failure for unsupported features. This is quite efficient. For
example in sys_statx() we could have done something like this instead
of return -ENOSYS:
extern int __nolibc_API_failure_statx_requires_NR_statx;
return __nolibc_API_failure_statx_requires_NR_statx;
This way it's discoverable at build time if the function is used.
But I'm digressing (not that much actually since we're discussing
features discoverability).
> > I personally don't think that a single define in front of each syscall
> > definition will make the code harder to read. It can be argued that glibc
> > doesn't offer this and that the user application will have to compose with
> > all of this, however glibc offers lots more stuff than we do, and users
> > rely on its version to guess whether or not something is present, which
> > is something we don't really have.
>
> I don't think it makes the code worse or really have anything against it
> in general. I just don't really see the advantage. For glibc this makes
> sense, as an application will have to do with the version that is
> present during compilation and at runtime. For nolibc this doesn't
> really happen. Or I might be missing something :-)
It's exactly the same actually. You use a nolibc repository to build your
code, your kernel headers come from anywhere, very often from the glibc-
based cross-compiler that includes support for the oldest kernel your
build system supports, and that's done. If you remember, originally there
was only nolibc.h to include and nothing else.
> If we adopt that scheme it should not only cover the _sys_*() functions
> but also the regular ones, no?
I've been wondering about this and probably yes. When I look at my preinit,
there are my_memmove(), my_strcpy(), my_strlen(), my_strlcpy(), my_getenv(),
my_atoul(), in addition for the syscall definitions. So yes, this
illustrates that it would be desirable to have that for the rest as well.
Maybe it ends up being about making the public API discoverable at build
time after all.
We could possibly also just use a version that applications could check
against. While the project has no declared version, we could for example
adopt the kernel's version since it's where it mostly evolves nowadays,
so maybe we could set a pair of _NOLIBC_KVER_MAJOR and _NOLIBC_KVER_MINOR
macros reflecting the kernel version this comes form (which is not the
same as the UAPI version but could be set at install time). At least with
a single version it would cover everything, and it's not much different
from what can be done with glibc.
Willy
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-29 5:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 16:20 [PATCH] tools/nolibc: rename sys_foo() functions to _sys_foo() Thomas Weißschuh
2026-03-22 9:06 ` Willy Tarreau
2026-03-22 10:43 ` Thomas Weißschuh
2026-03-22 11:03 ` Willy Tarreau
2026-03-24 17:01 ` Thomas Weißschuh
2026-03-29 5:06 ` Willy Tarreau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox