diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-04-14 17:13:09 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-04-14 17:13:09 -0700 |
| commit | ee60c510fb3468ec6fab98419218c4e7b37e2ca3 (patch) | |
| tree | a7748768691d1accaf7e2c4522df58a7c8bf969d /tools/include | |
| parent | 3203a08c1266689c204fb8f10d6bb5186921fce2 (diff) | |
| parent | b070dc36291fec966ad915f80a4f239b5c70c290 (diff) | |
Merge tag 'nolibc-20260412-for-7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/nolibc/linux-nolibc
Pull nolibc updates from Thomas Weißschuh:
- Many new features and optimizations to printf()
- Rename non-standard symbols to avoid collisions with application code
- Support for byteswap.h, endian.h, err.h and asprintf()
- 64-bit dev_t
- Smaller cleanups and fixes to the code and build system
* tag 'nolibc-20260412-for-7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/nolibc/linux-nolibc: (61 commits)
selftests/nolibc: use gcc 15
tools/nolibc: support UBSAN on gcc
tools/nolibc: create __nolibc_no_sanitize_ubsan
selftests/nolibc: don't skip tests for unimplemented syscalls anymore
selftests/nolibc: explicitly handle ENOSYS from ptrace()
tools/nolibc: add byteorder conversions
tools/nolibc: add the _syscall() macro
tools/nolibc: move the call to __sysret() into syscall()
tools/nolibc: rename the internal macros used in syscall()
selftests/nolibc: only use libgcc when really necessary
selftests/nolibc: test the memory allocator
tools/nolibc: check for overflow in calloc() without divisions
tools/nolibc: add support for asprintf()
tools/nolibc: use __builtin_offsetof()
tools/nolibc: use makedev() in fstatat()
tools/nolibc: handle all major and minor numbers in makedev() and friends
tools/nolibc: make dev_t 64 bits wide
tools/nolibc: move the logic of makedev() and friends into functions
selftests/nolibc: add a test for stat().st_rdev
selftests/nolibc: add some tests for makedev() and friends
...
Diffstat (limited to 'tools/include')
49 files changed, 1174 insertions, 659 deletions
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 1958dda98895..7455097cff69 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -17,19 +17,17 @@ endif # it defaults to this nolibc directory. OUTPUT ?= $(CURDIR)/ -ifeq ($(V),1) -Q= -else -Q=@ -endif - -arch_files := arch.h $(wildcard arch-*.h) +architectures := arm arm64 loongarch m68k mips powerpc riscv s390 sh sparc x86 +arch_files := arch.h $(addsuffix .h, $(addprefix arch-, $(architectures))) all_files := \ + byteswap.h \ compiler.h \ crt.h \ ctype.h \ dirent.h \ elf.h \ + endian.h \ + err.h \ errno.h \ fcntl.h \ getopt.h \ @@ -96,12 +94,10 @@ help: # installs headers for all archs at once. headers: - $(Q)mkdir -p "$(OUTPUT)sysroot" $(Q)mkdir -p "$(OUTPUT)sysroot/include" $(Q)cp --parents $(arch_files) $(all_files) "$(OUTPUT)sysroot/include/" headers_standalone: headers - $(Q)$(MAKE) -C $(srctree) headers $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot CFLAGS_s390 := -m64 diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index 251c42579028..a4d3a777a051 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 080a55a7144e..28b3c7536ad6 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 c894176c3f89..86fb34bbf185 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 2a4fbada5e79..81d34c219a42 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 a72506ceec6b..bb9d580ea1b1 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -39,11 +39,19 @@ * - stack is 16-byte aligned */ +#if !defined(__mips_isa_rev) || __mips_isa_rev < 6 +#define _NOLIBC_SYSCALL_CLOBBER_HI_LO "hi", "lo" +#else +#define _NOLIBC_SYSCALL_CLOBBER_HI_LO "$0" +#endif + #if defined(_ABIO32) #define _NOLIBC_SYSCALL_CLOBBERLIST \ - "memory", "cc", "at", "v1", "hi", "lo", \ - "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9" + "memory", "cc", "at", "v1", \ + "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9", \ + _NOLIBC_SYSCALL_CLOBBER_HI_LO + #define _NOLIBC_SYSCALL_STACK_RESERVE "addiu $sp, $sp, -32\n" #define _NOLIBC_SYSCALL_STACK_UNRESERVE "addiu $sp, $sp, 32\n" @@ -52,14 +60,15 @@ /* binutils, GCC and clang disagree about register aliases, use numbers instead. */ #define _NOLIBC_SYSCALL_CLOBBERLIST \ "memory", "cc", "at", "v1", \ - "10", "11", "12", "13", "14", "15", "24", "25" + "10", "11", "12", "13", "14", "15", "24", "25", \ + _NOLIBC_SYSCALL_CLOBBER_HI_LO #define _NOLIBC_SYSCALL_STACK_RESERVE #define _NOLIBC_SYSCALL_STACK_UNRESERVE #endif /* _ABIO32 */ -#define my_syscall0(num) \ +#define __nolibc_syscall0(num) \ ({ \ register long _num __asm__ ("v0") = (num); \ register long _arg4 __asm__ ("a3"); \ @@ -75,7 +84,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 +102,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 +121,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 +141,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 +163,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 +185,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 +212,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 +231,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 e0c7e0b81f7c..ef878868aa4a 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); |
