mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
tools/nolibc: rename sys_foo() functions to _sys_foo()
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> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://patch.msgid.link/20260319-nolibc-namespacing-v1-1-33c22eaddb5e@weissschuh.net
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 (;;);
|
||||
}
|
||||
|
||||
|
||||
+89
-89
File diff suppressed because it is too large
Load Diff
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user