aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/include/nolibc/Makefile14
-rw-r--r--tools/include/nolibc/arch-arm.h14
-rw-r--r--tools/include/nolibc/arch-arm64.h14
-rw-r--r--tools/include/nolibc/arch-loongarch.h14
-rw-r--r--tools/include/nolibc/arch-m68k.h14
-rw-r--r--tools/include/nolibc/arch-mips.h33
-rw-r--r--tools/include/nolibc/arch-powerpc.h14
-rw-r--r--tools/include/nolibc/arch-riscv.h14
-rw-r--r--tools/include/nolibc/arch-s390.h34
-rw-r--r--tools/include/nolibc/arch-sh.h14
-rw-r--r--tools/include/nolibc/arch-sparc.h26
-rw-r--r--tools/include/nolibc/arch-x86.h68
-rw-r--r--tools/include/nolibc/byteswap.h21
-rw-r--r--tools/include/nolibc/compiler.h21
-rw-r--r--tools/include/nolibc/crt.h31
-rw-r--r--tools/include/nolibc/dirent.h4
-rw-r--r--tools/include/nolibc/endian.h32
-rw-r--r--tools/include/nolibc/err.h87
-rw-r--r--tools/include/nolibc/errno.h4
-rw-r--r--tools/include/nolibc/fcntl.h12
-rw-r--r--tools/include/nolibc/nolibc.h13
-rw-r--r--tools/include/nolibc/poll.h8
-rw-r--r--tools/include/nolibc/sched.h12
-rw-r--r--tools/include/nolibc/signal.h2
-rw-r--r--tools/include/nolibc/stackprotector.h8
-rw-r--r--tools/include/nolibc/std.h2
-rw-r--r--tools/include/nolibc/stddef.h2
-rw-r--r--tools/include/nolibc/stdio.h565
-rw-r--r--tools/include/nolibc/stdlib.h175
-rw-r--r--tools/include/nolibc/sys.h288
-rw-r--r--tools/include/nolibc/sys/ioctl.h6
-rw-r--r--tools/include/nolibc/sys/mman.h24
-rw-r--r--tools/include/nolibc/sys/mount.h8
-rw-r--r--tools/include/nolibc/sys/prctl.h8
-rw-r--r--tools/include/nolibc/sys/ptrace.h6
-rw-r--r--tools/include/nolibc/sys/random.h6
-rw-r--r--tools/include/nolibc/sys/reboot.h6
-rw-r--r--tools/include/nolibc/sys/resource.h10
-rw-r--r--tools/include/nolibc/sys/select.h10
-rw-r--r--tools/include/nolibc/sys/stat.h17
-rw-r--r--tools/include/nolibc/sys/syscall.h11
-rw-r--r--tools/include/nolibc/sys/sysmacros.h25
-rw-r--r--tools/include/nolibc/sys/time.h8
-rw-r--r--tools/include/nolibc/sys/timerfd.h24
-rw-r--r--tools/include/nolibc/sys/uio.h12
-rw-r--r--tools/include/nolibc/sys/utsname.h6
-rw-r--r--tools/include/nolibc/sys/wait.h6
-rw-r--r--tools/include/nolibc/time.h68
-rw-r--r--tools/include/nolibc/unistd.h12
-rw-r--r--tools/testing/selftests/nolibc/Makefile4
-rw-r--r--tools/testing/selftests/nolibc/Makefile.include5
-rw-r--r--tools/testing/selftests/nolibc/Makefile.nolibc23
-rw-r--r--tools/testing/selftests/nolibc/nolibc-test-ignore-errno.c6
-rw-r--r--tools/testing/selftests/nolibc/nolibc-test.c337
-rwxr-xr-xtools/testing/selftests/nolibc/run-tests.sh2
55 files changed, 1453 insertions, 757 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); \
@@ -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 1c00cacf57e1..386ebb9f5b08 100644
--- a/