projects/linux·commit 542fed2e

Merge tag 'nolibc-20261018-for-7.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/nolibc/linux-nolibc

542fed2e · Linus Torvalds <[email protected]> · 2026-10-20 14:36:18 -10:00

Pull nolibc updates from Thomas Weißschuh:

 - New architectures: Hexagon, 64-bit parisc

 - New library functionality: sendfile(), pread(), pwrite()

 - Various bugfixes and cleanups

* tag 'nolibc-20261018-for-7.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/nolibc/linux-nolibc: (28 commits)
  selftests/nolibc: explicitly disable position independent executables
  selftests/nolibc: use the configured kernel header directory
  tools/nolibc: fix the function argument order of calloc()
  tools/nolibc: check for overflow in malloc()
  tools/nolibc: stop rounding malloc() sizes up to 4096 bytes
  tools/nolibc: add support for pread() and pwrite()
  tools/nolibc: introduce __NOLIBC_BITS_PER_SYSCALL_ARG
  tools/nolibc: move __NOLIBC_LLARGPART() to compiler.h
  tools/nolibc: make 64-bit systemcall argument padding generic
  selftests/nolibc: make the broken MIPS N32 argument detection reusable
  tools/nolibc: add 64-bit parisc support
  selftests/nolibc: test the FD_* macros
  tools/nolibc: fix FD_SET(), FD_CLR() and FD_ISSET() on 64-bit
  tools/nolibc: fix readdir_r() with 64-bit directory offsets
  tools/nolibc: fix verrx() and errx() message formatting
  selftests/nolibc: add tests for the wait status macros
  tools/nolibc: fix WIFSIGNALED() for status 0
  tools/nolibc/parisc: consistently use %dp to refer to register %r27
  selftests/nolibc: validate ENOTDIR return values from opendir()/fdopendir()
  tools/nolibc: verify that a directory is opened
  ...
Commit
542fed2ef2ff7e580cc25efb174f5e1237e3b0eb
Parents
2a0d3d73 · 700ce4da

Merge commit. Changes below are compared with the first parent: 2a0d3d73.

Changes

24 files changed · +562 −62

Only the first 600 diff lines are shown. Download the complete patch.

tools/include/nolibc/Makefile

View file
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 6d213d3..0880be0 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -17,7 +17,23 @@ endif
# it defaults to this nolibc directory.
OUTPUT ?= $(CURDIR)/
-architectures := alpha arm arm64 loongarch m68k mips openrisc parisc powerpc riscv s390 sh sparc x86
+architectures := \
+ alpha \
+ arm \
+ arm64 \
+ hexagon \
+ loongarch \
+ m68k \
+ mips \
+ openrisc \
+ parisc \
+ powerpc \
+ riscv \
+ s390 \
+ sh \
+ sparc \
+ x86 \
+
arch_files := arch.h $(addsuffix .h, $(addprefix arch-, $(architectures)))
all_files := \
alloca.h \
@@ -59,6 +75,7 @@ all_files := \
sys/reboot.h \
sys/resource.h \
sys/select.h \
+ sys/sendfile.h \
sys/stat.h \
sys/syscall.h \
sys/sysmacros.h \

tools/include/nolibc/arch-arm.h

View file
diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h
index b88686f..b5b3456 100644
--- a/tools/include/nolibc/arch-arm.h
+++ b/tools/include/nolibc/arch-arm.h
@@ -196,11 +196,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __nolibc_no_stack_prote
}
#endif /* NOLIBC_NO_RUNTIME */
-static __attribute__((unused))
-int _sys_ftruncate64(int fd, uint32_t length0, uint32_t length1)
-{
- return __nolibc_syscall4(__NR_ftruncate64, fd, 0, length0, length1);
-}
-#define _sys_ftruncate64 _sys_ftruncate64
+#define __NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR
#endif /* _NOLIBC_ARCH_ARM_H */

tools/include/nolibc/arch-hexagon.h

View file
diff --git a/tools/include/nolibc/arch-hexagon.h b/tools/include/nolibc/arch-hexagon.h
new file mode 100644
index 0000000..68f7352
--- /dev/null
+++ b/tools/include/nolibc/arch-hexagon.h
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * hexagon specific definitions for NOLIBC
+ * Copyright (C) 2026 Thomas Weißschuh <[email protected]>
+ */
+
+#ifndef _NOLIBC_ARCH_HEXAGON_H
+#define _NOLIBC_ARCH_HEXAGON_H
+
+#include <linux/unistd.h>
+
+#include "compiler.h"
+#include "crt.h"
+
+/*
+ * Syscalls for hexagon:
+ * - syscall number is passed in r6
+ * - arguments are in r0, r1, r2, r3, r4, r5
+ * - the system call is performed by calling trap0(#1)
+ * - syscall return value is in r0
+ */
+
+#define _NOLIBC_SYSCALL_CLOBBERLIST "memory"
+
+#define __nolibc_syscall0(num) \
+({ \
+ register long _num __asm__ ("r6") = (num); \
+ register long _arg1 __asm__ ("r0"); \
+ \
+ __asm__ volatile ( \
+ "trap0(#1)\n" \
+ : "=r"(_arg1) \
+ : "r"(_num) \
+ : _NOLIBC_SYSCALL_CLOBBERLIST \
+ ); \
+ _arg1; \
+})
+
+#define __nolibc_syscall1(num, arg1) \
+({ \
+ register long _num __asm__ ("r6") = (num); \
+ register long _arg1 __asm__ ("r0") = (long)(arg1); \
+ \
+ __asm__ volatile ( \
+ "trap0(#1)\n" \
+ : "+r"(_arg1) \
+ : "r"(_num) \
+ : _NOLIBC_SYSCALL_CLOBBERLIST \
+ ); \
+ _arg1; \
+})
+
+#define __nolibc_syscall2(num, arg1, arg2) \
+({ \
+ register long _num __asm__ ("r6") = (num); \
+ register long _arg1 __asm__ ("r0") = (long)(arg1); \
+ register long _arg2 __asm__ ("r1") = (long)(arg2); \
+ \
+ __asm__ volatile ( \
+ "trap0(#1)\n" \
+ : "+r"(_arg1) \
+ : "r"(_arg2), \
+ "r"(_num) \
+ : _NOLIBC_SYSCALL_CLOBBERLIST \
+ ); \
+ _arg1; \
+})
+
+#define __nolibc_syscall3(num, arg1, arg2, arg3) \
+({ \
+ register long _num __asm__ ("r6") = (num); \
+ register long _arg1 __asm__ ("r0") = (long)(arg1); \
+ register long _arg2 __asm__ ("r1") = (long)(arg2); \
+ register long _arg3 __asm__ ("r2") = (long)(arg3); \
+ \
+ __asm__ volatile ( \
+ "trap0(#1)\n" \
+ : "+r"(_arg1) \
+ : "r"(_arg2), "r"(_arg3), \
+ "r"(_num) \
+ : _NOLIBC_SYSCALL_CLOBBERLIST \
+ ); \
+ _arg1; \
+})
+
+#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \
+({ \
+ register long _num __asm__ ("r6") = (num); \
+ register long _arg1 __asm__ ("r0") = (long)(arg1); \
+ register long _arg2 __asm__ ("r1") = (long)(arg2); \
+ register long _arg3 __asm__ ("r2") = (long)(arg3); \
+ register long _arg4 __asm__ ("r3") = (long)(arg4); \
+ \
+ __asm__ volatile ( \
+ "trap0(#1)\n" \
+ : "+r"(_arg1) \
+ : "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_num) \
+ : _NOLIBC_SYSCALL_CLOBBERLIST \
+ ); \
+ _arg1; \
+})
+
+#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \
+({ \
+ register long _num __asm__ ("r6") = (num); \
+ register long _arg1 __asm__ ("r0") = (long)(arg1); \
+ register long _arg2 __asm__ ("r1") = (long)(arg2); \
+ register long _arg3 __asm__ ("r2") = (long)(arg3); \
+ register long _arg4 __asm__ ("r3") = (long)(arg4); \
+ register long _arg5 __asm__ ("r4") = (long)(arg5); \
+ \
+ __asm__ volatile ( \
+ "trap0(#1)\n" \
+ : "+r"(_arg1) \
+ : "r"(_arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5), \
+ "r"(_num) \
+ : _NOLIBC_SYSCALL_CLOBBERLIST \
+ ); \
+ _arg1; \
+})
+
+#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \
+({ \
+ register long _num __asm__ ("r6") = (num); \
+ register long _arg1 __asm__ ("r0") = (long)(arg1); \
+ register long _arg2 __asm__ ("r1") = (long)(arg2); \
+ register long _arg3 __asm__ ("r2") = (long)(arg3); \
+ register long _arg4 __asm__ ("r3") = (long)(arg4); \
+ register long _arg5 __asm__ ("r4") = (long)(arg5); \
+ register long _arg6 __asm__ ("r5") = (long)(arg6); \
+ \
+ __asm__ volatile ( \
+ "trap0(#1)\n" \
+ : "+r"(_arg1) \
+ : "r"(_arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5), "r"(_arg6), \
+ "r"(_num) \
+ : _NOLIBC_SYSCALL_CLOBBERLIST \
+ ); \
+ _arg1; \
+})
+
+#ifndef NOLIBC_NO_RUNTIME
+/* startup code */
+void __attribute__((weak, noreturn))
+__nolibc_entrypoint __nolibc_no_stack_protector
+_start(void)
+{
+ __asm__ volatile (
+ "r0 = sp\n" /* save stack pointer to r0, as arg1 of _start_c */
+ "call _start_c\n" /* transfer to c runtime */
+ );
+ __nolibc_entrypoint_epilogue();
+}
+#endif /* NOLIBC_NO_RUNTIME */
+
+#define __NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR
+
+#endif /* _NOLIBC_ARCH_HEXAGON_H */

tools/include/nolibc/arch-mips.h

View file
diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
index 26ad413..c0da0cc 100644
--- a/tools/include/nolibc/arch-mips.h
+++ b/tools/include/nolibc/arch-mips.h
@@ -72,6 +72,7 @@
#define _NOLIBC_SYSCALL_STACK_UNRESERVE
#define _NOLIBC_SYSCALL_REG register long long
+#define __NOLIBC_BITS_PER_SYSCALL_ARG 64
#endif /* _ABIO32 */
@@ -286,12 +287,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __nolibc_no_stack_prote
#endif /* NOLIBC_NO_RUNTIME */
#if defined(_ABIO32)
-static __attribute__((unused))
-int _sys_ftruncate64(int fd, uint32_t length0, uint32_t length1)
-{
- return __nolibc_syscall4(__NR_ftruncate64, fd, 0, length0, length1);
-}
-#define _sys_ftruncate64 _sys_ftruncate64
+#define __NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR
#endif
#endif /* _NOLIBC_ARCH_MIPS_H */

tools/include/nolibc/arch-parisc.h

View file
diff --git a/tools/include/nolibc/arch-parisc.h b/tools/include/nolibc/arch-parisc.h
index 417043e..bf57ba1 100644
--- a/tools/include/nolibc/arch-parisc.h
+++ b/tools/include/nolibc/arch-parisc.h
@@ -7,9 +7,7 @@
#ifndef _NOLIBC_ARCH_PARISC_H
#define _NOLIBC_ARCH_PARISC_H
-#if defined(__LP64__)
-#error 64-bit not supported
-#endif
+#include <linux/unistd.h>
#include "compiler.h"
#include "crt.h"
@@ -167,9 +165,15 @@
void __attribute__((weak, noreturn)) __nolibc_entrypoint __nolibc_no_stack_protector _start(void)
{
__asm__ volatile (
+#ifdef __LP64__
+ ".import __gp\n" /* Set up the dp register */
+ "ldil L%__gp, %dp\n"
+ "ldo R%__gp(%dp), %dp\n"
+#else
".import $global$\n" /* Set up the dp register */
"ldil L%$global$, %dp\n"
- "ldo R%$global$(%r27), %dp\n"
+ "ldo R%$global$(%dp), %dp\n"
+#endif
"b _start_c\n" /* Call _start_c, the load below is executed first */
@@ -182,4 +186,20 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __nolibc_no_stack_prote
}
#endif /* NOLIBC_NO_RUNTIME */
+#ifdef __LP64__
+/*
+ * This override is normally only meant for 32-bit architectures.
+ * But parisc 64-bit has __NR_ftruncate64, so this path is taken.
+ * Add an unused second argument to satisfy the calling convention.
+ */
+static __attribute__((unused))
+int _sys_ftruncate64(int fd, uint64_t length, uint64_t unused)
+{
+ (void)unused;
+
+ return __nolibc_syscall2(__NR_ftruncate64, fd, length);
+}
+#define _sys_ftruncate64 _sys_ftruncate64
+#endif
+
#endif /* _NOLIBC_ARCH_PARISC_H */

tools/include/nolibc/arch-powerpc.h

View file
diff --git a/tools/include/nolibc/arch-powerpc.h b/tools/include/nolibc/arch-powerpc.h
index dbe2e52..a471163 100644
--- a/tools/include/nolibc/arch-powerpc.h
+++ b/tools/include/nolibc/arch-powerpc.h
@@ -222,12 +222,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __nolibc_no_stack_prote
#endif /* NOLIBC_NO_RUNTIME */
#if !defined(__powerpc64__)
-static __attribute__((unused))
-int _sys_ftruncate64(int fd, uint32_t length0, uint32_t length1)
-{
- return __nolibc_syscall4(__NR_ftruncate64, fd, 0, length0, length1);
-}
-#define _sys_ftruncate64 _sys_ftruncate64
+#define __NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR
#endif
#endif /* _NOLIBC_ARCH_POWERPC_H */

tools/include/nolibc/arch-sh.h

View file
diff --git a/tools/include/nolibc/arch-sh.h b/tools/include/nolibc/arch-sh.h
index a32378f..996cfbe 100644
--- a/tools/include/nolibc/arch-sh.h
+++ b/tools/include/nolibc/arch-sh.h
@@ -10,6 +10,8 @@
#include "compiler.h"
#include "crt.h"
+#include <linux/unistd.h>
+
/*
* Syscalls for SuperH:
* - registers are 32bit wide
@@ -161,4 +163,20 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __nolibc_no_stack_prote
}
#endif /* NOLIBC_NO_RUNTIME */
+static __attribute__((unused))
+ssize_t _sys_pread(int fd, void *buf, size_t count, off_t offset)
+{
+ return __nolibc_syscall6(__NR_pread64, fd, buf, count, 0,
+ __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1));
+}
+#define _sys_pread _sys_pread
+
+static __attribute__((unused))
+ssize_t _sys_pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+ return __nolibc_syscall6(__NR_pwrite64, fd, buf, count, 0,
+ __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1));
+}
+#define _sys_pwrite _sys_pwrite
+
#endif /* _NOLIBC_ARCH_SH_H */

tools/include/nolibc/arch-x86.h

View file
diff --git a/tools/include/nolibc/arch-x86.h b/tools/include/nolibc/arch-x86.h
index 577e9b6..0638f93 100644
--- a/tools/include/nolibc/arch-x86.h
+++ b/tools/include/nolibc/arch-x86.h
@@ -386,5 +386,7 @@ __asm__ (
".popsection\n"
);
+#define __NOLIBC_BITS_PER_SYSCALL_ARG 64
+
#endif /* !defined(__x86_64__) */
#endif /* _NOLIBC_ARCH_X86_H */

tools/include/nolibc/arch.h

View file
diff --git a/tools/include/nolibc/arch.h b/tools/include/nolibc/arch.h
index 06cc2db..79ed590 100644
--- a/tools/include/nolibc/arch.h
+++ b/tools/include/nolibc/arch.h
@@ -34,8 +34,15 @@
#include "arch-parisc.h"
#elif defined(__alpha__)
#include "arch-alpha.h"
+#elif defined(__hexagon__)
+#include "arch-hexagon.h"
#else
#error Unsupported Architecture
#endif
+
+#ifndef __NOLIBC_BITS_PER_SYSCALL_ARG
+#define __NOLIBC_BITS_PER_SYSCALL_ARG __BITS_PER_LONG
+#endif
+
#endif /* _NOLIBC_ARCH_H */

tools/include/nolibc/compiler.h

View file
diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h
index f2d7a81..375c45c 100644
--- a/tools/include/nolibc/compiler.h
+++ b/tools/include/nolibc/compiler.h
@@ -90,4 +90,13 @@
# define __nolibc_no_sanitize_undefined
#endif
+/*
+ * Helper for 32-bit machines where a 64-bit syscall arg needs to be split into
+ * two 32-bit parts while making sure the order of the low/high parts are correct
+ * for the endianness:
+ * __NOLIBC_LLARGPART(x, 0), __NOLIBC_LLARGPART(x, 1)
+ */
+#define __NOLIBC_LLARGPART(_arg, _part) \
+ (((union { long long ll; long l[2]; }) { .ll = _arg }).l[_part])
+
#endif /* _NOLIBC_COMPILER_H */

tools/include/nolibc/dirent.h

View file
diff --git a/tools/include/nolibc/dirent.h b/tools/include/nolibc/dirent.h
index 4e02ef2..1985736 100644
--- a/tools/include/nolibc/dirent.h
+++ b/tools/include/nolibc/dirent.h
@@ -30,10 +30,23 @@ typedef struct {
static __attribute__((unused))
DIR *fdopendir(int fd)
{
+ struct stat buf;
+ int ret;
+
if (fd < 0) {
SET_ERRNO(EBADF);
return NULL;
}
+
+ ret = fstat(fd, &buf);
+ if (ret < 0)
+ return NULL;
+
+ if (!S_ISDIR(buf.st_mode)) {
+ SET_ERRNO(ENOTDIR);
+ return NULL;
+ }
+
return (DIR *)(intptr_t)~fd;
}
@@ -42,10 +55,11 @@ DIR *opendir(const char *name)
{
int fd;
- fd = open(name, O_RDONLY);
+ fd = open(name, O_RDONLY | O_DIRECTORY);
if (fd == -1)
return NULL;
- return fdopendir(fd);
+
+ return (DIR *)(intptr_t)~fd;
}
static __attribute__((unused))
@@ -67,6 +81,7 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
struct linux_dirent64 *ldir = (void *)buf;
intptr_t i = (intptr_t)dirp;
int fd, ret;
+ off_t off;
if (i >= 0)
return EBADF;
@@ -86,9 +101,9 @@ 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);
- if (ret < 0)
- return -ret;
+ off = _sys_lseek(fd, ldir->d_off, SEEK_SET);
+ if (off < 0)
+ return -off;
entry->d_ino = ldir->d_ino;
/* the destination should always be big enough */

tools/include/nolibc/err.h

View file
diff --git a/tools/include/nolibc/err.h b/tools/include/nolibc/err.h
index e22ae87..61978d5 100644
--- a/tools/include/nolibc/err.h
+++ b/tools/include/nolibc/err.h
@@ -60,7 +60,7 @@ void verr(int eval, const char *fmt, va_list args)
static __attribute__((noreturn, unused))
void verrx(int eval, const char *fmt, va_list args)
{
- warnx(fmt, args);
+ vwarnx(fmt, args);
exit(eval);
}

tools/include/nolibc/nolibc.h

View file
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index faa94f2..352a207 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -106,6 +106,7 @@
#include "sys/reboot.h"
#include "sys/resource.h"
#include "sys/select.h"
+#include "sys/sendfile.h"
#include "sys/stat.h"
#include "sys/syscall.h"
#include "sys/sysmacros.h"

tools/include/nolibc/stdlib.h

View file
diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h
index 1816c23..1c5a914 100644
--- a/tools/include/nolibc/stdlib.h
+++ b/tools/include/nolibc/stdlib.h
@@ -130,9 +130,11 @@ void *malloc(size_t len)
{
struct nolibc_heap *heap;
- /* Always allocate memory with size multiple of 4096. */
- len = sizeof(*heap) + len;
- len = (len + 4095UL) & -4096UL;
+ if (__builtin_expect(__builtin_add_overflow(len, sizeof(*heap), &len), 0)) {
+ SET_ERRNO(ENOMEM);
+ return NULL;
+ }
+
heap = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE,
-1, 0);
if (__builtin_expect(heap == MAP_FAILED, 0))
@@ -143,7 +145,7 @@ void *malloc(size_t len)
}
static __attribute__((unused))
-void *calloc(size_t size, size_t nmemb)
+void *calloc(size_t nmemb, size_t size)
{
size_t x;
@@ -230,7 +232,7 @@ int _nolibc_u64toa_base(uint64_t in, char *buffer, unsigned int base, uint64_t r
/* Generate least significant digit first */
do {
-#if defined(__SIZEOF_INT128__) && !defined(__mips__) && !defined(__sparc__)
+#if defined(__SIZEOF_INT128__) && !defined(__mips__) && !defined(__sparc__) && !defined(__hppa__)
q = ((unsigned __int128)in * recip) >> 64;
#else
uint64_t p = (uint32_t)in * (recip >> 32);

tools/include/nolibc/sys.h

View file
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 548f94d..b63fa6c 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -71,16 +71,6 @@ static __inline__ int __nolibc_enosys(const char *syscall, ...)
#endif
-/*
- * Helper for 32-bit machines where a 64-bit syscall arg needs to be split into
- * two 32-bit parts while making sure the order of the low/high parts are correct
- * for the endianness:
- * __NOLIBC_LLARGPART(x, 0), __NOLIBC_LLARGPART(x, 1)
- */
-#define __NOLIBC_LLARGPART(_arg, _part) \
- (((union { long long ll; long l[2]; }) { .ll = _arg }).l[_part])
-
-
/* Functions in this file only describe syscalls. They're declared static so
* that the compiler usually decides to inline them while still being allowed
* to pass a pointer to one of their instances. Each syscall exists in two
@@ -756,6 +746,56 @@ int pivot_root(const char *new, const char *old)
/*
+ * ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ * ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+ */
+
+#ifndef _sys_pread
+static __attribute__((unused))
+ssize_t _sys_pread(int fd, void *buf, size_t count, off_t offset)
+{
+#if __NOLIBC_BITS_PER_SYSCALL_ARG == 64
+ return __nolibc_syscall4(__NR_pread64, fd, buf, count, offset);
+#elif defined(__NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR)
+ return __nolibc_syscall6(__NR_pread64, fd, buf, count, 0,
+ __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1));
+#else
+ return __nolibc_syscall5(__NR_pread64, fd, buf, count,
+ __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1));
+#endif
+}
+#endif /* _sys_pread */
+
+static __attribute__((unused))
+ssize_t pread(int fd, void *buf, size_t count, off_t offset)
+{
+ return __sysret(_sys_pread(fd, buf, count, offset));
+}
+
+#ifndef _sys_pwrite
+static __attribute__((unused))
+ssize_t _sys_pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+#if __NOLIBC_BITS_PER_SYSCALL_ARG == 64
+ return __nolibc_syscall4(__NR_pwrite64, fd, buf, count, offset);
+#elif defined(__NOLIBC_PAD_64BIT_SYSCALL_ARGUMENT_PAIR)
+ return __nolibc_syscall6(__NR_pwrite64, fd, buf, count, 0,
+ __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1));
+#else
+ return __nolibc_syscall5(__NR_pwrite64, fd, buf, count,
+ __NOLIBC_LLARGPART(offset, 0), __NOLIBC_LLARGPART(offset, 1));
+#endif
+}
+#endif /* _sys_pwrite */
+
+static __attribute__((unused))
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+ return __sysret(_sys_pwrite(fd, buf, count, offset));
+}
+
+
+/*

This diff is incomplete. Download the complete patch.

tools/include/nolibc/sys/select.h

View file

This diff is incomplete. Download the complete patch.

tools/include/nolibc/sys/sendfile.h

View file

This diff is incomplete. Download the complete patch.

tools/include/nolibc/types.h

View file

This diff is incomplete. Download the complete patch.

tools/include/nolibc/unistd.h

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/nolibc/Makefile

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/nolibc/Makefile.include

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/nolibc/Makefile.nolibc

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/nolibc/nolibc-test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/nolibc/run-tests.sh

View file

This diff is incomplete. Download the complete patch.