From: Thomas Weißschuh Date: Mon, 23 Feb 2026 21:40:14 +0000 (+0100) Subject: tools/nolibc: rename my_syscallX() to __nolibc_syscallX() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=55f1d6a9d6780e779e882a4d2d1b3db311835798;p=thirdparty%2Fkernel%2Flinux.git tools/nolibc: rename my_syscallX() to __nolibc_syscallX() The naming convention of the my_syscallX() macros is a bit unfortunate. They may conflict with application code and the name is very generic. Switch to __nolibc_syscallX(). The leading underscores place the symbols in the implementation-defined namespace, avoiding conflicting names. It is also clearer that these are non-standard extensions from nolibc. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau Link: https://patch.msgid.link/20260223-nolibc-namespacing-v1-1-52574ffebb2c@weissschuh.net --- diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index 251c425790282..a4d3a777a051b 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -50,7 +50,7 @@ #endif /* end THUMB */ -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _num __asm__(_NOLIBC_SYSCALL_REG) = (num); \ register long _arg1 __asm__ ("r0"); \ @@ -67,7 +67,7 @@ _arg1; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ register long _num __asm__(_NOLIBC_SYSCALL_REG) = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ @@ -84,7 +84,7 @@ _arg1; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__(_NOLIBC_SYSCALL_REG) = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ @@ -102,7 +102,7 @@ _arg1; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__(_NOLIBC_SYSCALL_REG) = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ @@ -121,7 +121,7 @@ _arg1; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__(_NOLIBC_SYSCALL_REG) = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ @@ -141,7 +141,7 @@ _arg1; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__(_NOLIBC_SYSCALL_REG) = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ @@ -162,7 +162,7 @@ _arg1; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__(_NOLIBC_SYSCALL_REG) = (num); \ register long _arg1 __asm__ ("r0") = (long)(arg1); \ diff --git a/tools/include/nolibc/arch-arm64.h b/tools/include/nolibc/arch-arm64.h index 080a55a7144ee..28b3c7536ad6d 100644 --- a/tools/include/nolibc/arch-arm64.h +++ b/tools/include/nolibc/arch-arm64.h @@ -22,7 +22,7 @@ * don't have to experience issues with register constraints. */ -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0"); \ @@ -36,7 +36,7 @@ _arg1; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -51,7 +51,7 @@ _arg1; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -67,7 +67,7 @@ _arg1; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -84,7 +84,7 @@ _arg1; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -102,7 +102,7 @@ _arg1; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ @@ -121,7 +121,7 @@ _arg1; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("x8") = (num); \ register long _arg1 __asm__ ("x0") = (long)(arg1); \ diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index c894176c3f89a..86fb34bbf1857 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -24,7 +24,7 @@ #define _NOLIBC_SYSCALL_CLOBBERLIST \ "memory", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8" -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0"); \ @@ -38,7 +38,7 @@ _arg1; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -52,7 +52,7 @@ _arg1; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -68,7 +68,7 @@ _arg1; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -85,7 +85,7 @@ _arg1; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -103,7 +103,7 @@ _arg1; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -122,7 +122,7 @@ _arg1; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ diff --git a/tools/include/nolibc/arch-m68k.h b/tools/include/nolibc/arch-m68k.h index 2a4fbada5e79c..81d34c219a421 100644 --- a/tools/include/nolibc/arch-m68k.h +++ b/tools/include/nolibc/arch-m68k.h @@ -15,7 +15,7 @@ #define _NOLIBC_SYSCALL_CLOBBERLIST "memory" -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _num __asm__ ("d0") = (num); \ \ @@ -28,7 +28,7 @@ _num; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("d0") = (num); \ register long _arg1 __asm__ ("d1") = (long)(arg1); \ @@ -42,7 +42,7 @@ _num; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("d0") = (num); \ register long _arg1 __asm__ ("d1") = (long)(arg1); \ @@ -57,7 +57,7 @@ _num; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("d0") = (num); \ register long _arg1 __asm__ ("d1") = (long)(arg1); \ @@ -73,7 +73,7 @@ _num; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("d0") = (num); \ register long _arg1 __asm__ ("d1") = (long)(arg1); \ @@ -90,7 +90,7 @@ _num; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("d0") = (num); \ register long _arg1 __asm__ ("d1") = (long)(arg1); \ @@ -108,7 +108,7 @@ _num; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("d0") = (num); \ register long _arg1 __asm__ ("d1") = (long)(arg1); \ diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index a72506ceec6bd..bd4a9b57e1f02 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -59,7 +59,7 @@ #endif /* _ABIO32 */ -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg4 __asm__ ("a3"); \ @@ -75,7 +75,7 @@ _arg4 ? -_num : _num; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -93,7 +93,7 @@ _arg4 ? -_num : _num; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -112,7 +112,7 @@ _arg4 ? -_num : _num; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -132,7 +132,7 @@ _arg4 ? -_num : _num; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -154,7 +154,7 @@ #if defined(_ABIO32) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -176,7 +176,7 @@ _arg4 ? -_num : _num; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -203,7 +203,7 @@ #else /* _ABIN32 || _ABI64 */ -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("$4") = (long)(arg1); \ @@ -222,7 +222,7 @@ _arg4 ? -_num : _num; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg1 __asm__ ("$4") = (long)(arg1); \ diff --git a/tools/include/nolibc/arch-powerpc.h b/tools/include/nolibc/arch-powerpc.h index e0c7e0b81f7cd..ef878868aa4ad 100644 --- a/tools/include/nolibc/arch-powerpc.h +++ b/tools/include/nolibc/arch-powerpc.h @@ -25,7 +25,7 @@ #define _NOLIBC_SYSCALL_CLOBBERLIST \ "memory", "cr0", "r12", "r11", "r10", "r9" -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _ret __asm__ ("r3"); \ register long _num __asm__ ("r0") = (num); \ @@ -42,7 +42,7 @@ _ret; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ register long _ret __asm__ ("r3"); \ register long _num __asm__ ("r0") = (num); \ @@ -61,7 +61,7 @@ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ register long _ret __asm__ ("r3"); \ register long _num __asm__ ("r0") = (num); \ @@ -81,7 +81,7 @@ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _ret __asm__ ("r3"); \ register long _num __asm__ ("r0") = (num); \ @@ -102,7 +102,7 @@ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _ret __asm__ ("r3"); \ register long _num __asm__ ("r0") = (num); \ @@ -125,7 +125,7 @@ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _ret __asm__ ("r3"); \ register long _num __asm__ ("r0") = (num); \ @@ -148,7 +148,7 @@ _ret; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _ret __asm__ ("r3"); \ register long _num __asm__ ("r0") = (num); \ diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index 1c00cacf57e15..386ebb9f5b087 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -21,7 +21,7 @@ * so that we don't have to experience issues with register constraints. */ -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0"); \ @@ -35,7 +35,7 @@ _arg1; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -49,7 +49,7 @@ _arg1; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -65,7 +65,7 @@ _arg1; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -82,7 +82,7 @@ _arg1; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -100,7 +100,7 @@ _arg1; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ @@ -119,7 +119,7 @@ _arg1; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("a7") = (num); \ register long _arg1 __asm__ ("a0") = (long)(arg1); \ diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h index 904281e95f999..d301b636e083e 100644 --- a/tools/include/nolibc/arch-s390.h +++ b/tools/include/nolibc/arch-s390.h @@ -28,7 +28,7 @@ * */ -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _num __asm__ ("1") = (num); \ register long _rc __asm__ ("2"); \ @@ -42,7 +42,7 @@ _rc; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("1") = (num); \ register long _arg1 __asm__ ("2") = (long)(arg1); \ @@ -56,7 +56,7 @@ _arg1; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("1") = (num); \ register long _arg1 __asm__ ("2") = (long)(arg1); \ @@ -71,7 +71,7 @@ _arg1; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("1") = (num); \ register long _arg1 __asm__ ("2") = (long)(arg1); \ @@ -87,7 +87,7 @@ _arg1; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("1") = (num); \ register long _arg1 __asm__ ("2") = (long)(arg1); \ @@ -104,7 +104,7 @@ _arg1; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("1") = (num); \ register long _arg1 __asm__ ("2") = (long)(arg1); \ @@ -123,7 +123,7 @@ _arg1; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("1") = (num); \ register long _arg1 __asm__ ("2") = (long)(arg1); \ @@ -179,21 +179,21 @@ void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd, .offset = (unsigned long)offset }; - return (void *)my_syscall1(__NR_mmap, &args); + return (void *)__nolibc_syscall1(__NR_mmap, &args); } #define sys_mmap sys_mmap static __attribute__((unused)) pid_t sys_fork(void) { - return my_syscall5(__NR_clone, 0, SIGCHLD, 0, 0, 0); + return __nolibc_syscall5(__NR_clone, 0, SIGCHLD, 0, 0, 0); } #define sys_fork sys_fork static __attribute__((unused)) pid_t sys_vfork(void) { - return my_syscall5(__NR_clone, 0, CLONE_VM | CLONE_VFORK | SIGCHLD, 0, 0, 0); + return __nolibc_syscall5(__NR_clone, 0, CLONE_VM | CLONE_VFORK | SIGCHLD, 0, 0, 0); } #define sys_vfork sys_vfork diff --git a/tools/include/nolibc/arch-sh.h b/tools/include/nolibc/arch-sh.h index 7a421197d104d..b5a64ceeec974 100644 --- a/tools/include/nolibc/arch-sh.h +++ b/tools/include/nolibc/arch-sh.h @@ -19,7 +19,7 @@ * - syscall return value is in r0 */ -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _num __asm__ ("r3") = (num); \ register long _ret __asm__ ("r0"); \ @@ -33,7 +33,7 @@ _ret; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("r3") = (num); \ register long _ret __asm__ ("r0"); \ @@ -48,7 +48,7 @@ _ret; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("r3") = (num); \ register long _ret __asm__ ("r0"); \ @@ -64,7 +64,7 @@ _ret; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("r3") = (num); \ register long _ret __asm__ ("r0"); \ @@ -81,7 +81,7 @@ _ret; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("r3") = (num); \ register long _ret __asm__ ("r0"); \ @@ -99,7 +99,7 @@ _ret; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("r3") = (num); \ register long _ret __asm__ ("r0"); \ @@ -119,7 +119,7 @@ _ret; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("r3") = (num); \ register long _ret __asm__ ("r0"); \ diff --git a/tools/include/nolibc/arch-sparc.h b/tools/include/nolibc/arch-sparc.h index 2ebb5686e1053..02aca6579cb22 100644 --- a/tools/include/nolibc/arch-sparc.h +++ b/tools/include/nolibc/arch-sparc.h @@ -38,7 +38,7 @@ #endif /* __arch64__ */ -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _num __asm__ ("g1") = (num); \ register long _arg1 __asm__ ("o0"); \ @@ -52,7 +52,7 @@ _arg1; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ register long _num __asm__ ("g1") = (num); \ register long _arg1 __asm__ ("o0") = (long)(arg1); \ @@ -66,7 +66,7 @@ _arg1; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ register long _num __asm__ ("g1") = (num); \ register long _arg1 __asm__ ("o0") = (long)(arg1); \ @@ -81,7 +81,7 @@ _arg1; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ register long _num __asm__ ("g1") = (num); \ register long _arg1 __asm__ ("o0") = (long)(arg1); \ @@ -97,7 +97,7 @@ _arg1; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ register long _num __asm__ ("g1") = (num); \ register long _arg1 __asm__ ("o0") = (long)(arg1); \ @@ -114,7 +114,7 @@ _arg1; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ register long _num __asm__ ("g1") = (num); \ register long _arg1 __asm__ ("o0") = (long)(arg1); \ @@ -132,7 +132,7 @@ _arg1; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ register long _num __asm__ ("g1") = (num); \ register long _arg1 __asm__ ("o0") = (long)(arg1); \ @@ -180,7 +180,7 @@ pid_t sys_fork(void) pid_t parent, ret; parent = getpid(); - ret = my_syscall0(__NR_fork); + ret = __nolibc_syscall0(__NR_fork); /* The syscall returns the parent pid in the child instead of 0 */ if (ret == parent) @@ -196,7 +196,7 @@ pid_t sys_vfork(void) pid_t parent, ret; parent = getpid(); - ret = my_syscall0(__NR_vfork); + ret = __nolibc_syscall0(__NR_vfork); /* The syscall returns the parent pid in the child instead of 0 */ if (ret == parent) diff --git a/tools/include/nolibc/arch-x86.h b/tools/include/nolibc/arch-x86.h index f6c43ac5377bb..769ba01a8629f 100644 --- a/tools/include/nolibc/arch-x86.h +++ b/tools/include/nolibc/arch-x86.h @@ -30,7 +30,7 @@ */ #define __ARCH_WANT_SYS_OLD_SELECT -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -44,7 +44,7 @@ _ret; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -60,7 +60,7 @@ _ret; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -77,7 +77,7 @@ _ret; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -95,7 +95,7 @@ _ret; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -114,7 +114,7 @@ _ret; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ long _ret; \ register long _num __asm__ ("eax") = (num); \ @@ -134,27 +134,27 @@ _ret; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ -({ \ - long _eax = (long)(num); \ - long _arg6 = (long)(arg6); /* Always in memory */ \ - __asm__ volatile ( \ - "pushl %[_arg6]\n\t" \ - "pushl %%ebp\n\t" \ - "movl 4(%%esp),%%ebp\n\t" \ - "int $0x80\n\t" \ - "popl %%ebp\n\t" \ - "addl $4,%%esp\n\t" \ - : "+a"(_eax) /* %eax */ \ - : "b"(arg1), /* %ebx */ \ - "c"(arg2), /* %ecx */ \ - "d"(arg3), /* %edx */ \ - "S"(arg4), /* %esi */ \ - "D"(arg5), /* %edi */ \ - [_arg6]"m"(_arg6) /* memory */ \ - : "memory", "cc" \ - ); \ - _eax; \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +({ \ + long _eax = (long)(num); \ + long _arg6 = (long)(arg6); /* Always in memory */ \ + __asm__ volatile ( \ + "pushl %[_arg6]\n\t" \ + "pushl %%ebp\n\t" \ + "movl 4(%%esp),%%ebp\n\t" \ + "int $0x80\n\t" \ + "popl %%ebp\n\t" \ + "addl $4,%%esp\n\t" \ + : "+a"(_eax) /* %eax */ \ + : "b"(arg1), /* %ebx */ \ + "c"(arg2), /* %ecx */ \ + "d"(arg3), /* %edx */ \ + "S"(arg4), /* %esi */ \ + "D"(arg5), /* %edi */ \ + [_arg6]"m"(_arg6) /* memory */ \ + : "memory", "cc" \ + ); \ + _eax; \ }) #ifndef NOLIBC_NO_RUNTIME @@ -200,7 +200,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s * */ -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -214,7 +214,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s _ret; \ }) -#define my_syscall1(num, arg1) \ +#define __nolibc_syscall1(num, arg1) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -230,7 +230,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s _ret; \ }) -#define my_syscall2(num, arg1, arg2) \ +#define __nolibc_syscall2(num, arg1, arg2) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -247,7 +247,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s _ret; \ }) -#define my_syscall3(num, arg1, arg2, arg3) \ +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -265,7 +265,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s _ret; \ }) -#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -284,7 +284,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s _ret; \ }) -#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ @@ -304,7 +304,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s _ret; \ }) -#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ ({ \ long _ret; \ register long _num __asm__ ("rax") = (num); \ diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h index bff2e542f20f9..8d82768dea9d4 100644 --- a/tools/include/nolibc/fcntl.h +++ b/tools/include/nolibc/fcntl.h @@ -21,7 +21,7 @@ static __attribute__((unused)) int sys_openat(int dirfd, const char *path, int flags, mode_t mode) { - return my_syscall4(__NR_openat, dirfd, path, flags, mode); + return __nolibc_syscall4(__NR_openat, dirfd, path, flags, mode); } static __attribute__((unused)) @@ -47,7 +47,7 @@ int openat(int dirfd, const char *path, int flags, ...) static __attribute__((unused)) int sys_open(const char *path, int flags, mode_t mode) { - return my_syscall4(__NR_openat, AT_FDCWD, path, flags, mode); + return __nolibc_syscall4(__NR_openat, AT_FDCWD, path, flags, mode); } static __attribute__((unused)) diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 9c7f43b9218b3..d1d08b7f85995 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -12,14 +12,14 @@ * * Syscalls are split into 3 levels: * - The lower level is the arch-specific syscall() definition, consisting in - * assembly code in compound expressions. These are called my_syscall0() to - * my_syscall6() depending on the number of arguments. All input arguments + * assembly code in compound expressions. These are called __nolibc_syscall0() to + * __nolibc_syscall6() depending on the number of arguments. All input arguments * are castto a long stored in a register. These expressions always return * the syscall's return value as a signed long value which is often either * a pointer or the negated errno value. * * - The second level is mostly architecture-independent. It is made of - * static functions called sys_() which rely on my_syscallN() + * static functions called sys_() 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). diff --git a/tools/include/nolibc/poll.h b/tools/include/nolibc/poll.h index e854c94647b1e..ea5a6d08c43cb 100644 --- a/tools/include/nolibc/poll.h +++ b/tools/include/nolibc/poll.h @@ -30,7 +30,7 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout) t.tv_sec = timeout / 1000; t.tv_nsec = (timeout % 1000) * 1000000; } - return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0); + return __nolibc_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0); #else struct __kernel_old_timespec t; @@ -38,7 +38,7 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout) t.tv_sec = timeout / 1000; t.tv_nsec = (timeout % 1000) * 1000000; } - return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0); + return __nolibc_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0); #endif } diff --git a/tools/include/nolibc/sched.h b/tools/include/nolibc/sched.h index 32221562c1663..b1af7fa6672db 100644 --- a/tools/include/nolibc/sched.h +++ b/tools/include/nolibc/sched.h @@ -21,7 +21,7 @@ static __attribute__((unused)) int sys_setns(int fd, int nstype) { - return my_syscall2(__NR_setns, fd, nstype); + return __nolibc_syscall2(__NR_setns, fd, nstype); } static __attribute__((unused)) @@ -38,7 +38,7 @@ int setns(int fd, int nstype) static __attribute__((unused)) int sys_unshare(int flags) { - return my_syscall1(__NR_unshare, flags); + return __nolibc_syscall1(__NR_unshare, flags); } static __attribute__((unused)) diff --git a/tools/include/nolibc/stackprotector.h b/tools/include/nolibc/stackprotector.h index 7123aa056cb09..ae8b1d3a374dc 100644 --- a/tools/include/nolibc/stackprotector.h +++ b/tools/include/nolibc/stackprotector.h @@ -24,9 +24,9 @@ __attribute__((weak,used,noreturn,section(".text.nolibc_stack_chk"))) void __stack_chk_fail(void) { pid_t pid; - my_syscall3(__NR_write, STDERR_FILENO, "!!Stack smashing detected!!\n", 28); - pid = my_syscall0(__NR_getpid); - my_syscall2(__NR_kill, pid, SIGABRT); + __nolibc_syscall3(__NR_write, STDERR_FILENO, "!!Stack smashing detected!!\n", 28); + pid = __nolibc_syscall0(__NR_getpid); + __nolibc_syscall2(__NR_kill, pid, SIGABRT); for (;;); } @@ -42,7 +42,7 @@ uintptr_t __stack_chk_guard; static __no_stack_protector void __stack_chk_init(void) { - my_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0); + __nolibc_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0); /* a bit more randomness in case getrandom() fails, ensure the guard is never 0 */ if (__stack_chk_guard != (uintptr_t) &__stack_chk_guard) __stack_chk_guard ^= (uintptr_t) &__stack_chk_guard; diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 403ee9ce8389d..bc1c76cb2f63e 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -87,7 +87,7 @@ static __inline__ int __nolibc_enosys(const char *syscall, ...) static __attribute__((unused)) void *sys_brk(void *addr) { - return (void *)my_syscall1(__NR_brk, addr); + return (void *)__nolibc_syscall1(__NR_brk, addr); } static __attribute__((unused)) @@ -124,7 +124,7 @@ void *sbrk(intptr_t inc) static __attribute__((unused)) int sys_chdir(const char *path) { - return my_syscall1(__NR_chdir, path); + return __nolibc_syscall1(__NR_chdir, path); } static __attribute__((unused)) @@ -136,7 +136,7 @@ int chdir(const char *path) static __attribute__((unused)) int sys_fchdir(int fildes) { - return my_syscall1(__NR_fchdir, fildes); + return __nolibc_syscall1(__NR_fchdir, fildes); } static __attribute__((unused)) @@ -154,9 +154,9 @@ static __attribute__((unused)) int sys_chmod(const char *path, mode_t mode) { #if defined(__NR_fchmodat) - return my_syscall4(__NR_fchmodat, AT_FDCWD, path, mode, 0); + return __nolibc_syscall4(__NR_fchmodat, AT_FDCWD, path, mode, 0); #else - return my_syscall2(__NR_chmod, path, mode); + return __nolibc_syscall2(__NR_chmod, path, mode); #endif } @@ -175,9 +175,9 @@ static __attribute__((unused)) int sys_chown(const char *path, uid_t owner, gid_t group) { #if defined(__NR_fchownat) - return my_syscall5(__NR_fchownat, AT_FDCWD, path, owner, group, 0); + return __nolibc_syscall5(__NR_fchownat, AT_FDCWD, path, owner, group, 0); #else - return my_syscall3(__NR_chown, path, owner, group); + return __nolibc_syscall3(__NR_chown, path, owner, group); #endif } @@ -195,7 +195,7 @@ int chown(const char *path, uid_t owner, gid_t group) static __attribute__((unused)) int sys_chroot(const char *path) { - return my_syscall1(__NR_chroot, path); + return __nolibc_syscall1(__NR_chroot, path); } static __attribute__((unused)) @@ -212,7 +212,7 @@ int chroot(const char *path) static __attribute__((unused)) int sys_close(int fd) { - return my_syscall1(__NR_close, fd); + return __nolibc_syscall1(__NR_close, fd); } static __attribute__((unused)) @@ -229,7 +229,7 @@ int close(int fd) static __attribute__((unused)) int sys_dup(int fd) { - return my_syscall1(__NR_dup, fd); + return __nolibc_syscall1(__NR_dup, fd); } static __attribute__((unused)) @@ -256,13 +256,13 @@ int sys_dup2(int old, int new) #endif if (old == new) { - ret = my_syscall2(nr_fcntl, old, F_GETFD); + ret = __nolibc_syscall2(nr_fcntl, old, F_GETFD); return ret < 0 ? ret : old; } - return my_syscall3(__NR_dup3, old, new, 0); + return __nolibc_syscall3(__NR_dup3, old, new, 0); #else - return my_syscall2(__NR_dup2, old, new); + return __nolibc_syscall2(__NR_dup2, old, new); #endif } @@ -281,7 +281,7 @@ int dup2(int old, int new) static __attribute__((unused)) int sys_dup3(int old, int new, int flags) { - return my_syscall3(__NR_dup3, old, new, flags); + return __nolibc_syscall3(__NR_dup3, old, new, flags); } static __attribute__((unused)) @@ -299,7 +299,7 @@ int dup3(int old, int new, int flags) static __attribute__((unused)) int sys_execve(const char *filename, char *const argv[], char *const envp[]) { - return my_syscall3(__NR_execve, filename, argv, envp); + return __nolibc_syscall3(__NR_execve, filename, argv, envp); } static __attribute__((unused)) @@ -316,7 +316,7 @@ int execve(const char *filename, char *const argv[], char *const envp[]) static __attribute__((noreturn,unused)) void sys_exit(int status) { - my_syscall1(__NR_exit, status & 255); + __nolibc_syscall1(__NR_exit, status & 255); while(1); /* shut the "noreturn" warnings. */ } @@ -346,9 +346,9 @@ pid_t sys_fork(void) * have a different API, but most archs have the flags on first arg and * will not use the rest with no other flag. */ - return my_syscall5(__NR_clone, SIGCHLD, 0, 0, 0, 0); + return __nolibc_syscall5(__NR_clone, SIGCHLD, 0, 0, 0, 0); #else - return my_syscall0(__NR_fork); + return __nolibc_syscall0(__NR_fork); #endif } #endif @@ -365,9 +365,9 @@ pid_t sys_vfork(void) { #if defined(__NR_clone) /* See the note in sys_fork(). */ - return my_syscall5(__NR_clone, CLONE_VM | CLONE_VFORK | SIGCHLD, 0, 0, 0, 0); + return __nolibc_syscall5(__NR_clone, CLONE_VM | CLONE_VFORK | SIGCHLD, 0, 0, 0, 0); #elif defined(__NR_vfork) - return my_syscall0(__NR_vfork); + return __nolibc_syscall0(__NR_vfork); #endif } #endif @@ -385,7 +385,7 @@ pid_t vfork(void) static __attribute__((unused)) int sys_fsync(int fd) { - return my_syscall1(__NR_fsync, fd); + return __nolibc_syscall1(__NR_fsync, fd); } static __attribute__((unused)) @@ -402,7 +402,7 @@ int fsync(int fd) static __attribute__((unused)) int sys_getdents64(int fd, struct linux_dirent64 *dirp, int count) { - return my_syscall3(__NR_getdents64, fd, dirp, count); + return __nolibc_syscall3(__NR_getdents64, fd, dirp, count); } static __attribute__((unused)) @@ -420,9 +420,9 @@ static __attribute__((unused)) uid_t sys_geteuid(void) { #if defined(__NR_geteuid32) - return my_syscall0(__NR_geteuid32); + return __nolibc_syscall0(__NR_geteuid32); #else - return my_syscall0(__NR_geteuid); + return __nolibc_syscall0(__NR_geteuid); #endif } @@ -440,7 +440,7 @@ uid_t geteuid(void) static __attribute__((unused)) pid_t sys_getpgid(pid_t pid) { - return my_syscall1(__NR_getpgid, pid); + return __nolibc_syscall1(__NR_getpgid, pid); } static __attribute__((unused)) @@ -474,7 +474,7 @@ pid_t getpgrp(void) static __attribute__((unused)) pid_t sys_getpid(void) { - return my_syscall0(__NR_getpid); + return __nolibc_syscall0(__NR_getpid); } static __attribute__((unused)) @@ -491,7 +491,7 @@ pid_t getpid(void) static __attribute__((unused)) pid_t sys_getppid(void) { - return my_syscall0(__NR_getppid); + return __nolibc_syscall0(__NR_getppid); } static __attribute__((unused)) @@ -508,7 +508,7 @@ pid_t getppid(void) static __attribute__((unused)) pid_t sys_gettid(void) { - return my_syscall0(__NR_gettid); + return __nolibc_syscall0(__NR_gettid); } static __attribute__((unused)) @@ -539,9 +539,9 @@ static __attribute__((unused)) uid_t sys_getuid(void) { #if defined(__NR_getuid32) - return my_syscall0(__NR_getuid32); + return __nolibc_syscall0(__NR_getuid32); #else - return my_syscall0(__NR_getuid); + return __nolibc_syscall0(__NR_getuid); #endif } @@ -559,7 +559,7 @@ uid_t getuid(void) static __attribute__((unused)) int sys_kill(pid_t pid, int signal) { - return my_syscall2(__NR_kill, pid, signal); + return __nolibc_syscall2(__NR_kill, pid, signal); } static __attribute__((unused)) @@ -577,9 +577,9 @@ static __attribute__((unused)) int sys_link(const char *old, const char *new) { #if defined(__NR_linkat) - return my_syscall5(__NR_linkat, AT_FDCWD, old, AT_FDCWD, new, 0); + return __nolibc_syscall5(__NR_linkat, AT_FDCWD, old, AT_FDCWD, new, 0); #else - return my_syscall2(__NR_link, old, new); + return __nolibc_syscall2(__NR_link, old, new); #endif } @@ -602,7 +602,7 @@ off_t sys_lseek(int fd, off_t offset, int whence) off_t result; int ret; - ret = my_syscall5(__NR_llseek, fd, offset >> 32, (uint32_t)offset, &loff, whence); + ret = __nolibc_syscall5(__NR_llseek, fd, offset >> 32, (uint32_t)offset, &loff, whence); if (ret < 0) result = ret; else @@ -610,7 +610,7 @@ off_t sys_lseek(int fd, off_t offset, int whence) return result; #else - return my_syscall3(__NR_lseek, fd, offset, whence); + return __nolibc_syscall3(__NR_lseek, fd, offset, whence); #endif } @@ -629,9 +629,9 @@ static __attribute__((unused)) int sys_mkdir(const char *path, mode_t mode) { #if defined(__NR_mkdirat) - return my_syscall3(__NR_mkdirat, AT_FDCWD, path, mode); + return __nolibc_syscall3(__NR_mkdirat, AT_FDCWD, path, mode); #else - return my_syscall2(__NR_mkdir, path, mode); + return __nolibc_syscall2(__NR_mkdir, path, mode); #endif } @@ -649,9 +649,9 @@ static __attribute__((unused)) int sys_rmdir(const char *path) { #if defined(__NR_rmdir) - return my_syscall1(__NR_rmdir, path); + return __nolibc_syscall1(__NR_rmdir, path); #else - return my_syscall3(__NR_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); + return __nolibc_syscall3(__NR_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); #endif } @@ -670,9 +670,9 @@ static __attribute__((unused)) long sys_mknod(const char *path, mode_t mode, dev_t dev) { #if defined(__NR_mknodat) - return my_syscall4(__NR_mknodat, AT_FDCWD, path, mode, dev); + return __nolibc_syscall4(__NR_mknodat, AT_FDCWD, path, mode, dev); #else - return my_syscall3(__NR_mknod, path, mode, dev); + return __nolibc_syscall3(__NR_mknod, path, mode, dev); #endif } @@ -691,7 +691,7 @@ int mknod(const char *path, mode_t mode, dev_t dev) static __attribute__((unused)) int sys_pipe2(int pipefd[2], int flags) { - return my_syscall2(__NR_pipe2, pipefd, flags); + return __nolibc_syscall2(__NR_pipe2, pipefd, flags); } static __attribute__((unused)) @@ -714,7 +714,7 @@ int pipe(int pipefd[2]) static __attribute__((unused)) int sys_pivot_root(const char *new, const char *old) { - return my_syscall2(__NR_pivot_root, new, old); + return __nolibc_syscall2(__NR_pivot_root, new, old); } static __attribute__((unused)) @@ -731,7 +731,7 @@ int pivot_root(const char *new, const char *old) static __attribute__((unused)) ssize_t sys_read(int fd, void *buf, size_t count) { - return my_syscall3(__NR_read, fd, buf, count); + return __nolibc_syscall3(__NR_read, fd, buf, count); } static __attribute__((unused)) @@ -748,7 +748,7 @@ ssize_t read(int fd, void *buf, size_t count) static __attribute__((unused)) int sys_sched_yield(void) { - return my_syscall0(__NR_sched_yield); + return __nolibc_syscall0(__NR_sched_yield); } static __attribute__((unused)) @@ -765,7 +765,7 @@ int sched_yield(void) static __attribute__((unused)) int sys_setpgid(pid_t pid, pid_t pgid) { - return my_syscall2(__NR_setpgid, pid, pgid); + return __nolibc_syscall2(__NR_setpgid, pid, pgid); } static __attribute__((unused)) @@ -792,7 +792,7 @@ pid_t setpgrp(void) static __attribute__((unused)) pid_t sys_setsid(void) { - return my_syscall0(__NR_setsid); + return __nolibc_syscall0(__NR_setsid); } static __attribute__((unused)) @@ -810,9 +810,9 @@ static __attribute__((unused)) int sys_symlink(const char *old, const char *new) { #if defined(__NR_symlinkat) - return my_syscall3(__NR_symlinkat, old, AT_FDCWD, new); + return __nolibc_syscall3(__NR_symlinkat, old, AT_FDCWD, new); #else - return my_syscall2(__NR_symlink, old, new); + return __nolibc_syscall2(__NR_symlink, old, new); #endif } @@ -830,7 +830,7 @@ int symlink(const char *old, const char *new) static __attribute__((unused)) mode_t sys_umask(mode_t mode) { - return my_syscall1(__NR_umask, mode); + return __nolibc_syscall1(__NR_umask, mode); } static __attribute__((unused)) @@ -847,7 +847,7 @@ mode_t umask(mode_t mode) static __attribute__((unused)) int sys_umount2(const char *path, int flags) { - return my_syscall2(__NR_umount2, path, flags); + return __nolibc_syscall2(__NR_umount2, path, flags); } static __attribute__((unused)) @@ -865,9 +865,9 @@ static __attribute__((unused)) int sys_unlink(const char *path) { #if defined(__NR_unlinkat) - return my_syscall3(__NR_unlinkat, AT_FDCWD, path, 0); + return __nolibc_syscall3(__NR_unlinkat, AT_FDCWD, path, 0); #else - return my_syscall1(__NR_unlink, path); + return __nolibc_syscall1(__NR_unlink, path); #endif } @@ -885,7 +885,7 @@ int unlink(const char *path) static __attribute__((unused)) ssize_t sys_write(int fd, const void *buf, size_t count) { - return my_syscall3(__NR_write, fd, buf, count); + return __nolibc_syscall3(__NR_write, fd, buf, count); } static __attribute__((unused)) @@ -902,7 +902,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) { - return my_syscall2(__NR_memfd_create, name, flags); + return __nolibc_syscall2(__NR_memfd_create, name, flags); } static __attribute__((unused)) diff --git a/tools/include/nolibc/sys/ioctl.h b/tools/include/nolibc/sys/ioctl.h index fc880687e02af..289cc1494f2c3 100644 --- a/tools/include/nolibc/sys/ioctl.h +++ b/tools/include/nolibc/sys/ioctl.h @@ -21,7 +21,7 @@ static __attribute__((unused)) long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) { - return my_syscall3(__NR_ioctl, fd, cmd, arg); + return __nolibc_syscall3(__NR_ioctl, fd, cmd, arg); } #define ioctl(fd, cmd, arg) __sysret(sys_ioctl(fd, cmd, (unsigned long)(arg))) diff --git a/tools/include/nolibc/sys/mman.h b/tools/include/nolibc/sys/mman.h index 77084ac3405a0..5679fdda0a872 100644 --- a/tools/include/nolibc/sys/mman.h +++ b/tools/include/nolibc/sys/mman.h @@ -27,7 +27,7 @@ void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd, n = __NR_mmap; #endif - return (void *)my_syscall6(n, addr, length, prot, flags, fd, offset); + return (void *)__nolibc_syscall6(n, addr, length, prot, flags, fd, offset); } #endif @@ -46,8 +46,8 @@ 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) { - return (void *)my_syscall5(__NR_mremap, old_address, old_size, - new_size, flags, new_address); + return (void *)__nolibc_syscall5(__NR_mremap, old_address, old_size, + new_size, flags, new_address); } static __attribute__((unused)) @@ -65,7 +65,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) { - return my_syscall2(__NR_munmap, addr, length); + return __nolibc_syscall2(__NR_munmap, addr, length); } static __attribute__((unused)) diff --git a/tools/include/nolibc/sys/mount.h b/tools/include/nolibc/sys/mount.h index e39ec02ea24c0..1f8d14da276f9 100644 --- a/tools/include/nolibc/sys/mount.h +++ b/tools/include/nolibc/sys/mount.h @@ -23,7 +23,7 @@ static __attribute__((unused)) int sys_mount(const char *src, const char *tgt, const char *fst, unsigned long flags, const void *data) { - return my_syscall5(__NR_mount, src, tgt, fst, flags, data); + return __nolibc_syscall5(__NR_mount, src, tgt, fst, flags, data); } static __attribute__((unused)) diff --git a/tools/include/nolibc/sys/prctl.h b/tools/include/nolibc/sys/prctl.h index 0205907b6ac83..b019b46183289 100644 --- a/tools/include/nolibc/sys/prctl.h +++ b/tools/include/nolibc/sys/prctl.h @@ -23,7 +23,7 @@ static __attribute__((unused)) int sys_prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) { - return my_syscall5(__NR_prctl, option, arg2, arg3, arg4, arg5); + return __nolibc_syscall5(__NR_prctl, option, arg2, arg3, arg4, arg5); } static __attribute__((unused)) diff --git a/tools/include/nolibc/sys/ptrace.h b/tools/include/nolibc/sys/ptrace.h index 72ca285416335..6cde77e93ceb6 100644 --- a/tools/include/nolibc/sys/ptrace.h +++ b/tools/include/nolibc/sys/ptrace.h @@ -21,7 +21,7 @@ static __attribute__((unused)) long sys_ptrace(int op, pid_t pid, void *addr, void *data) { - return my_syscall4(__NR_ptrace, op, pid, addr, data); + return __nolibc_syscall4(__NR_ptrace, op, pid, addr, data); } static __attribute__((unused)) diff --git a/tools/include/nolibc/sys/random.h b/tools/include/nolibc/sys/random.h index cd5d25c571a8b..af9a270fc29d5 100644 --- a/tools/include/nolibc/sys/random.h +++ b/tools/include/nolibc/sys/random.h @@ -22,7 +22,7 @@ static __attribute__((unused)) ssize_t sys_getrandom(void *buf, size_t buflen, unsigned int flags) { - return my_syscall3(__NR_getrandom, buf, buflen, flags); + return __nolibc_syscall3(__NR_getrandom, buf, buflen, flags); } static __attribute__((unused)) diff --git a/tools/include/nolibc/sys/reboot.h b/tools/include/nolibc/sys/reboot.h index 38274c64a7228..20431025ccc69 100644 --- a/tools/include/nolibc/sys/reboot.h +++ b/tools/include/nolibc/sys/reboot.h @@ -22,7 +22,7 @@ static __attribute__((unused)) ssize_t sys_reboot(int magic1, int magic2, int cmd, void *arg) { - return my_syscall4(__NR_reboot, magic1, magic2, cmd, arg); + return __nolibc_syscall4(__NR_reboot, magic1, magic2, cmd, arg); } static __attribute__((unused)) diff --git a/tools/include/nolibc/sys/resource.h b/tools/include/nolibc/sys/resource.h index b990f914dc561..ff3c65f5fade0 100644 --- a/tools/include/nolibc/sys/resource.h +++ b/tools/include/nolibc/sys/resource.h @@ -23,7 +23,7 @@ static __attribute__((unused)) int sys_prlimit64(pid_t pid, int resource, const struct rlimit64 *new_limit, struct rlimit64 *old_limit) { - return my_syscall4(__NR_prlimit64, pid, resource, new_limit, old_limit); + return __nolibc_syscall4(__NR_prlimit64, pid, resource, new_limit, old_limit); } static __attribute__((unused)) diff --git a/tools/include/nolibc/sys/select.h b/tools/include/nolibc/sys/select.h index 80cb3755ba188..fcbcf4d0f8d10 100644 --- a/tools/include/nolibc/sys/select.h +++ b/tools/include/nolibc/sys/select.h @@ -70,7 +70,8 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva t.tv_sec = timeout->tv_sec; t.tv_nsec = (uint32_t)timeout->tv_usec * 1000; } - return my_syscall6(__NR_pselect6_time64, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL); + return __nolibc_syscall6(__NR_pselect6_time64, nfds, rfds, wfds, efds, + timeout ? &t : NULL, NULL); #else struct __kernel_old_timespec t; @@ -78,7 +79,8 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva t.tv_sec = timeout->tv_sec; t.tv_nsec = (uint32_t)timeout->tv_usec * 1000; } - return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL); + return __nolibc_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, + timeout ? &t : NULL, NULL); #endif } diff --git a/tools/include/nolibc/sys/stat.h b/tools/include/nolibc/sys/stat.h index 8b4d80e3ea036..2777217793db7 100644 --- a/tools/include/nolibc/sys/stat.h +++ b/tools/include/nolibc/sys/stat.h @@ -26,7 +26,7 @@ static __attribute__((unused)) int sys_statx(int fd, const char *path, int flags, unsigned int mask, struct statx *buf) { #ifdef __NR_statx - return my_syscall5(__NR_statx, fd, path, flags, mask, buf); + return __nolibc_syscall5(__NR_statx, fd, path, flags, mask, buf); #else return __nolibc_enosys(__func__, fd, path, flags, mask, buf); #endif diff --git a/tools/include/nolibc/sys/syscall.h b/tools/include/nolibc/sys/syscall.h index 4bf97f1386a03..8cbcae4a32aae 100644 --- a/tools/include/nolibc/sys/syscall.h +++ b/tools/include/nolibc/sys/syscall.h @@ -12,7 +12,7 @@ #define __syscall_narg(_0, _1, _2, _3, _4, _5, _6, N, ...) N #define _syscall_narg(...) __syscall_narg(__VA_ARGS__, 6, 5, 4, 3, 2, 1, 0) -#define _syscall(N, ...) __sysret(my_syscall##N(__VA_ARGS__)) +#define _syscall(N, ...) __sysret(__nolibc_syscall##N(__VA_ARGS__)) #define _syscall_n(N, ...) _syscall(N, __VA_ARGS__) #define syscall(...) _syscall_n(_syscall_narg(__VA_ARGS__), ##__VA_ARGS__) diff --git a/tools/include/nolibc/sys/timerfd.h b/tools/include/nolibc/sys/timerfd.h index 29fd92bd47d25..87f89c789b3bc 100644 --- a/tools/include/nolibc/sys/timerfd.h +++ b/tools/include/nolibc/sys/timerfd.h @@ -19,7 +19,7 @@ static __attribute__((unused)) int sys_timerfd_create(int clockid, int flags) { - return my_syscall2(__NR_timerfd_create, clockid, flags); + return __nolibc_syscall2(__NR_timerfd_create, clockid, flags); } static __attribute__((unused)) @@ -34,10 +34,10 @@ 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); - return my_syscall2(__NR_timerfd_gettime64, fd, curr_value); + return __nolibc_syscall2(__NR_timerfd_gettime64, fd, curr_value); #else __nolibc_assert_native_time64(); - return my_syscall2(__NR_timerfd_gettime, fd, curr_value); + return __nolibc_syscall2(__NR_timerfd_gettime, fd, curr_value); #endif } @@ -54,10 +54,10 @@ int sys_timerfd_settime(int fd, int flags, { #if defined(__NR_timerfd_settime64) __nolibc_assert_time64_type(new_value->it_value.tv_sec); - return my_syscall4(__NR_timerfd_settime64, fd, flags, new_value, old_value); + return __nolibc_syscall4(__NR_timerfd_settime64, fd, flags, new_value, old_value); #else __nolibc_assert_native_time64(); - return my_syscall4(__NR_timerfd_settime, fd, flags, new_value, old_value); + return __nolibc_syscall4(__NR_timerfd_settime, fd, flags, new_value, old_value); #endif } diff --git a/tools/include/nolibc/sys/uio.h b/tools/include/nolibc/sys/uio.h index 7ad42b927d2fa..21ff8c626dfe0 100644 --- a/tools/include/nolibc/sys/uio.h +++ b/tools/include/nolibc/sys/uio.h @@ -21,7 +21,7 @@ static __attribute__((unused)) ssize_t sys_readv(int fd, const struct iovec *iovec, int count) { - return my_syscall3(__NR_readv, fd, iovec, count); + return __nolibc_syscall3(__NR_readv, fd, iovec, count); } static __attribute__((unused)) @@ -36,7 +36,7 @@ ssize_t readv(int fd, const struct iovec *iovec, int count) static __attribute__((unused)) ssize_t sys_writev(int fd, const struct iovec *iovec, int count) { - return my_syscall3(__NR_writev, fd, iovec, count); + return __nolibc_syscall3(__NR_writev, fd, iovec, count); } static __attribute__((unused)) diff --git a/tools/include/nolibc/sys/utsname.h b/tools/include/nolibc/sys/utsname.h index 01023e1bb439c..25992d644525d 100644 --- a/tools/include/nolibc/sys/utsname.h +++ b/tools/include/nolibc/sys/utsname.h @@ -30,7 +30,7 @@ struct utsname { static __attribute__((unused)) int sys_uname(struct utsname *buf) { - return my_syscall1(__NR_uname, buf); + return __nolibc_syscall1(__NR_uname, buf); } static __attribute__((unused)) diff --git a/tools/include/nolibc/sys/wait.h b/tools/include/nolibc/sys/wait.h index 9d9319ba92cbd..bc11100e7f82a 100644 --- a/tools/include/nolibc/sys/wait.h +++ b/tools/include/nolibc/sys/wait.h @@ -23,7 +23,7 @@ static __attribute__((unused)) int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct rusage *rusage) { - return my_syscall5(__NR_waitid, which, pid, infop, options, rusage); + return __nolibc_syscall5(__NR_waitid, which, pid, infop, options, rusage); } static __attribute__((unused)) diff --git a/tools/include/nolibc/time.h b/tools/include/nolibc/time.h index f9257d6a78783..4d93d5188cecc 100644 --- a/tools/include/nolibc/time.h +++ b/tools/include/nolibc/time.h @@ -37,10 +37,10 @@ int sys_clock_getres(clockid_t clockid, struct timespec *res) { #if defined(__NR_clock_getres_time64) __nolibc_assert_time64_type(res->tv_sec); - return my_syscall2(__NR_clock_getres_time64, clockid, res); + return __nolibc_syscall2(__NR_clock_getres_time64, clockid, res); #else __nolibc_assert_native_time64(); - return my_syscall2(__NR_clock_getres, clockid, res); + return __nolibc_syscall2(__NR_clock_getres, clockid, res); #endif } @@ -55,10 +55,10 @@ int sys_clock_gettime(clockid_t clockid, struct timespec *tp) { #if defined(__NR_clock_gettime64) __nolibc_assert_time64_type(tp->tv_sec); - return my_syscall2(__NR_clock_gettime64, clockid, tp); + return __nolibc_syscall2(__NR_clock_gettime64, clockid, tp); #else __nolibc_assert_native_time64(); - return my_syscall2(__NR_clock_gettime, clockid, tp); + return __nolibc_syscall2(__NR_clock_gettime, clockid, tp); #endif } @@ -73,10 +73,10 @@ int sys_clock_settime(clockid_t clockid, struct timespec *tp) { #if defined(__NR_clock_settime64) __nolibc_assert_time64_type(tp->tv_sec); - return my_syscall2(__NR_clock_settime64, clockid, tp); + return __nolibc_syscall2(__NR_clock_settime64, clockid, tp); #else __nolibc_assert_native_time64(); - return my_syscall2(__NR_clock_settime, clockid, tp); + return __nolibc_syscall2(__NR_clock_settime, clockid, tp); #endif } @@ -92,10 +92,10 @@ int sys_clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqt { #if defined(__NR_clock_nanosleep_time64) __nolibc_assert_time64_type(rqtp->tv_sec); - return my_syscall4(__NR_clock_nanosleep_time64, clockid, flags, rqtp, rmtp); + return __nolibc_syscall4(__NR_clock_nanosleep_time64, clockid, flags, rqtp, rmtp); #else __nolibc_assert_native_time64(); - return my_syscall4(__NR_clock_nanosleep, clockid, flags, rqtp, rmtp); + return __nolibc_syscall4(__NR_clock_nanosleep, clockid, flags, rqtp, rmtp); #endif } @@ -143,7 +143,7 @@ time_t time(time_t *tptr) static __attribute__((unused)) int sys_timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) { - return my_syscall3(__NR_timer_create, clockid, evp, timerid); + return __nolibc_syscall3(__NR_timer_create, clockid, evp, timerid); } static __attribute__((unused)) @@ -155,7 +155,7 @@ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) static __attribute__((unused)) int sys_timer_delete(timer_t timerid) { - return my_syscall1(__NR_timer_delete, timerid); + return __nolibc_syscall1(__NR_timer_delete, timerid); } static __attribute__((unused)) @@ -169,10 +169,10 @@ 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); - return my_syscall2(__NR_timer_gettime64, timerid, curr_value); + return __nolibc_syscall2(__NR_timer_gettime64, timerid, curr_value); #else __nolibc_assert_native_time64(); - return my_syscall2(__NR_timer_gettime, timerid, curr_value); + return __nolibc_syscall2(__NR_timer_gettime, timerid, curr_value); #endif } @@ -188,10 +188,10 @@ int sys_timer_settime(timer_t timerid, int flags, { #if defined(__NR_timer_settime64) __nolibc_assert_time64_type(new_value->it_value.tv_sec); - return my_syscall4(__NR_timer_settime64, timerid, flags, new_value, old_value); + return __nolibc_syscall4(__NR_timer_settime64, timerid, flags, new_value, old_value); #else __nolibc_assert_native_time64(); - return my_syscall4(__NR_timer_settime, timerid, flags, new_value, old_value); + return __nolibc_syscall4(__NR_timer_settime, timerid, flags, new_value, old_value); #endif } diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h index bb5e80f3f05d5..6456d60daa02d 100644 --- a/tools/include/nolibc/unistd.h +++ b/tools/include/nolibc/unistd.h @@ -33,7 +33,7 @@ static __attribute__((unused)) int sys_faccessat(int fd, const char *path, int amode, int flag) { - return my_syscall4(__NR_faccessat, fd, path, amode, flag); + return __nolibc_syscall4(__NR_faccessat, fd, path, amode, flag); } static __attribute__((unused))