History log of /linux-6.15/tools/include/nolibc/sys.h (Results 1 – 25 of 52)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: v6.15, v6.15-rc7, v6.15-rc6, v6.15-rc5, v6.15-rc4, v6.15-rc3, v6.15-rc2, v6.15-rc1, v6.14, v6.14-rc7, v6.14-rc6
# bceb7390 07-Mar-2025 Thomas Weißschuh <[email protected]>

tools/nolibc: don't use asm/ UAPI headers

The asm/ and asm-generic/ namespaces are implementation details of the UAPI
headers and not meant for direct usage.

Use the equivalent headers from the lin

tools/nolibc: don't use asm/ UAPI headers

The asm/ and asm-generic/ namespaces are implementation details of the UAPI
headers and not meant for direct usage.

Use the equivalent headers from the linux/ namespace instead.

While at it also drop the duplicate include of linux/signal.h from sys.h.

Signed-off-by: Thomas Weißschuh <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

show more ...


# 90e1f9f7 06-Mar-2025 Louis Taylor <[email protected]>

tools/nolibc: process open() vararg as mode_t

openat() uses mode_t for this, so also update open() to be consistent.

Signed-off-by: Louis Taylor <[email protected]>
Link: https://lore.kernel.org/r/2

tools/nolibc: process open() vararg as mode_t

openat() uses mode_t for this, so also update open() to be consistent.

Signed-off-by: Louis Taylor <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Thomas Weißschuh <[email protected]>

show more ...


# fbd4f52f 06-Mar-2025 Louis Taylor <[email protected]>

tools/nolibc: always use openat(2) instead of open(2)

All architectures support openat, so we don't need to make its use
conditional.

Signed-off-by: Louis Taylor <[email protected]>
Link: https://lo

tools/nolibc: always use openat(2) instead of open(2)

All architectures support openat, so we don't need to make its use
conditional.

Signed-off-by: Louis Taylor <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Thomas Weißschuh <[email protected]>

show more ...


# b2edaad7 06-Mar-2025 Louis Taylor <[email protected]>

tools/nolibc: add support for openat(2)

openat is useful to avoid needing to construct relative paths, so expose
a wrapper for using it directly.

Signed-off-by: Louis Taylor <[email protected]>
Link

tools/nolibc: add support for openat(2)

openat is useful to avoid needing to construct relative paths, so expose
a wrapper for using it directly.

Signed-off-by: Louis Taylor <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Thomas Weißschuh <[email protected]>

show more ...


Revision tags: v6.14-rc5, v6.14-rc4, v6.14-rc3, v6.14-rc2
# dde5625d 09-Feb-2025 Thomas Weißschuh <[email protected]>

tools/nolibc: add support for sys_llseek()

Not all architectures have the old sys_lseek(), notably riscv32.
Implement lseek() in terms of sys_llseek() in that case.

Signed-off-by: Thomas Weißschuh

tools/nolibc: add support for sys_llseek()

Not all architectures have the old sys_lseek(), notably riscv32.
Implement lseek() in terms of sys_llseek() in that case.

Signed-off-by: Thomas Weißschuh <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Thomas Weißschuh <[email protected]>

show more ...


Revision tags: v6.14-rc1
# cfb1bfe9 28-Jan-2025 Thomas Weißschuh <[email protected]>

tools/nolibc: make signature of ioctl() more flexible

POSIX defines the signature of ioctl() as follows,
to allow passing a pointer or integer without casting:
int ioctl(int fildes, int request, ..

tools/nolibc: make signature of ioctl() more flexible

POSIX defines the signature of ioctl() as follows,
to allow passing a pointer or integer without casting:
int ioctl(int fildes, int request, ... /* arg */);

Nolibc ioctl() expects a pointer, forcing the user to manually cast.
Using va_arg to make the signature more flexible would work but seems to
prevent inlining of the function. Instead use a macro. "fd" and "req"
will still be typechecked through sys_ioctl().

Acked-by: Willy Tarreau <[email protected]>
Signed-off-by: Thomas Weißschuh <[email protected]>

show more ...


Revision tags: v6.13, v6.13-rc7, v6.13-rc6, v6.13-rc5, v6.13-rc4
# 7f89bc51 21-Dec-2024 Thomas Weißschuh <[email protected]>

tools/nolibc: add support for waitid()

waitid() is the modern variant of the family of wait-like syscalls.
Some architectures have dropped support for wait(), wait4() and waitpid()
but all of them s

tools/nolibc: add support for waitid()

waitid() is the modern variant of the family of wait-like syscalls.
Some architectures have dropped support for wait(), wait4() and waitpid()
but all of them support waitid().
It is more flexible and easier to use than the older ones.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Thomas Weißschuh <[email protected]>

show more ...


Revision tags: v6.13-rc3, v6.13-rc2, v6.13-rc1, v6.12, v6.12-rc7, v6.12-rc6, v6.12-rc5, v6.12-rc4, v6.12-rc3, v6.12-rc2, v6.12-rc1, v6.11, v6.11-rc7, v6.11-rc6, v6.11-rc5, v6.11-rc4, v6.11-rc3, v6.11-rc2, v6.11-rc1, v6.10, v6.10-rc7, v6.10-rc6, v6.10-rc5, v6.10-rc4, v6.10-rc3, v6.10-rc2, v6.10-rc1, v6.9, v6.9-rc7, v6.9-rc6, v6.9-rc5, v6.9-rc4
# 0adab2b6 13-Apr-2024 Thomas Weißschuh <[email protected]>

tools/nolibc: add support for uname(2)

All supported kernels are assumed to use struct new_utsname.
This is validated in test_uname().

uname(2) can for example be used in ksft_min_kernel_version()

tools/nolibc: add support for uname(2)

All supported kernels are assumed to use struct new_utsname.
This is validated in test_uname().

uname(2) can for example be used in ksft_min_kernel_version() from the
kernels selftest framework.

Link: https://lore.kernel.org/lkml/[email protected]/
Signed-off-by: Thomas Weißschuh <[email protected]>
Acked-by: Willy Tarreau <[email protected]>

show more ...


Revision tags: v6.9-rc3, v6.9-rc2, v6.9-rc1, v6.8, v6.8-rc7, v6.8-rc6, v6.8-rc5, v6.8-rc4, v6.8-rc3, v6.8-rc2, v6.8-rc1, v6.7, v6.7-rc8, v6.7-rc7, v6.7-rc6, v6.7-rc5, v6.7-rc4, v6.7-rc3
# a0bb5f88 22-Nov-2023 Thomas Weißschuh <[email protected]>

tools/nolibc: add support for getrlimit/setrlimit

The implementation uses the prlimit64 systemcall as that is available on
all architectures.

Signed-off-by: Thomas Weißschuh <[email protected]>

tools/nolibc: add support for getrlimit/setrlimit

The implementation uses the prlimit64 systemcall as that is available on
all architectures.

Signed-off-by: Thomas Weißschuh <[email protected]>
Link: https://lore.kernel.org/lkml/[email protected]/
Acked-by: Willy Tarreau <[email protected]>

show more ...


Revision tags: v6.7-rc2, v6.7-rc1, v6.6, v6.6-rc7, v6.6-rc6, v6.6-rc5, v6.6-rc4, v6.6-rc3, v6.6-rc2
# eaa8c9a8 17-Sep-2023 Thomas Weißschuh <[email protected]>

tools/nolibc: automatically detect necessity to use pselect6

We can automatically detect if pselect6 is needed or not from the kernel
headers. This removes the need to manually specify it.

Signed-o

tools/nolibc: automatically detect necessity to use pselect6

We can automatically detect if pselect6 is needed or not from the kernel
headers. This removes the need to manually specify it.

Signed-off-by: Thomas Weißschuh <[email protected]>
Acked-by: Willy Tarreau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

show more ...


# e7b28f25 17-Sep-2023 Thomas Weißschuh <[email protected]>

tools/nolibc: don't define new syscall number

All symbols created by nolibc are also visible to user code.
Syscall constants are expected to come from the kernel headers and
should not be made up by

tools/nolibc: don't define new syscall number

All symbols created by nolibc are also visible to user code.
Syscall constants are expected to come from the kernel headers and
should not be made up by nolibc.

Refactor the logic to avoid defining syscall numbers.
Also the new code is easier to understand.

Signed-off-by: Thomas Weißschuh <[email protected]>
Acked-by: Willy Tarreau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

show more ...


# 535b70c1 17-Sep-2023 Thomas Weißschuh <[email protected]>

tools/nolibc: avoid unused parameter warnings for ENOSYS fallbacks

The ENOSYS fallback code does not use its functions parameters.
This can lead to compiler warnings about unused parameters.

Explic

tools/nolibc: avoid unused parameter warnings for ENOSYS fallbacks

The ENOSYS fallback code does not use its functions parameters.
This can lead to compiler warnings about unused parameters.

Explicitly avoid these warnings.

Signed-off-by: Thomas Weißschuh <[email protected]>
Acked-by: Willy Tarreau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

show more ...


Revision tags: v6.6-rc1
# b56a9492 30-Aug-2023 Thomas Weißschuh <[email protected]>

tools/nolibc: add stdarg.h header

This allows nolic to work with `-nostdinc` avoiding any reliance on
system headers.

The implementation has been lifted from musl libc 1.2.4.
There is already an im

tools/nolibc: add stdarg.h header

This allows nolic to work with `-nostdinc` avoiding any reliance on
system headers.

The implementation has been lifted from musl libc 1.2.4.
There is already an implementation of stdarg.h in include/linux/stdarg.h
but that is GPL licensed and therefore not suitable for nolibc.

The used compiler builtins have been validated to be at least available
since GCC 4.1.2 and clang 3.0.0.

Signed-off-by: Thomas Weißschuh <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


Revision tags: v6.5, v6.5-rc7
# 556fb713 15-Aug-2023 Willy Tarreau <[email protected]>

tools/nolibc: avoid undesired casts in the __sysret() macro

Having __sysret() as an inline function has the unfortunate effect of
adding casts and large constants comparisons after the syscall retur

tools/nolibc: avoid undesired casts in the __sysret() macro

Having __sysret() as an inline function has the unfortunate effect of
adding casts and large constants comparisons after the syscall returns
that significantly inflate some light code that's otherwise syscall-
heavy. Even nolibc-test grew by ~1%.

Let's switch back to a macro for this, and use it only with signed
arguments. Note that it is also possible to design a slightly more
complex macro covering unsigned and pointers but we only have 3 such
syscalls so it is pointless, and these were just addressed not to use
this macro anymore. Now for the argument (the local variable containing
the syscall return value), any negative value is an error, that results
in -1 being returned and errno to be assigned the opposite value.

This may be revisited again in the future if really needed but for now
let's get back to something sane.

Fixes: 428905da6ec4 ("tools/nolibc: sys.h: add a syscall return helper")
Link: https://lore.kernel.org/lkml/[email protected]/
Link: https://lore.kernel.org/lkml/[email protected]/
Cc: Zhangjin Wu <[email protected]>
Cc: David Laight <[email protected]>
Cc: Thomas Weißschuh <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


# fb01ff63 15-Aug-2023 Willy Tarreau <[email protected]>

tools/nolibc: keep brk(), sbrk(), mmap() away from __sysret()

The __sysret() function causes some undesirable casts so we'll revert
it. In order to keep it simple it will now only support integer re

tools/nolibc: keep brk(), sbrk(), mmap() away from __sysret()

The __sysret() function causes some undesirable casts so we'll revert
it. In order to keep it simple it will now only support integer return
values like in the past, so we must basically revert the changes that
were made to these 3 syscalls which return a pointer so that they
simply rely on their own test and the SET_ERRNO() macro.

Fixes: 4201cfce15fe ("tools/nolibc: clean up sbrk() routine")
Fixes: 924e9539aeaa ("tools/nolibc: clean up mmap() routine")
Fixes: d27447bc2e0a ("tools/nolibc: sys.h: apply __sysret() helper")
Link: https://lore.kernel.org/lkml/[email protected]/
Link: https://lore.kernel.org/lkml/[email protected]/
Cc: Zhangjin Wu <[email protected]>
Cc: David Laight <[email protected]>
Cc: Thomas Weißschuh <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


Revision tags: v6.5-rc6, v6.5-rc5
# 04694658 03-Aug-2023 Thomas Weißschuh <[email protected]>

tools/nolibc: sys: avoid implicit sign cast

getauxval() returns an unsigned long but the overall type of the ternary
operator needs to be signed.

Signed-off-by: Thomas Weißschuh <[email protected]

tools/nolibc: sys: avoid implicit sign cast

getauxval() returns an unsigned long but the overall type of the ternary
operator needs to be signed.

Signed-off-by: Thomas Weißschuh <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


# 64077502 03-Aug-2023 Thomas Weißschuh <[email protected]>

tools/nolibc: fix return type of getpagesize()

It's documented as returning int which is also implemented by glibc and
musl, so adopt that return type.

Signed-off-by: Thomas Weißschuh <linux@weisss

tools/nolibc: fix return type of getpagesize()

It's documented as returning int which is also implemented by glibc and
musl, so adopt that return type.

Signed-off-by: Thomas Weißschuh <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


# f2f5eaef 03-Aug-2023 Thomas Weißschuh <[email protected]>

tools/nolibc: drop unused variables

Nobody needs it, get rid of it.

Signed-off-by: Thomas Weißschuh <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>


# 3ec38af6 01-Aug-2023 Yuan Tan <[email protected]>

tools/nolibc: add pipe() and pipe2() support

According to manual page [1], posix spec [2] and source code like
arch/mips/kernel/syscall.c, for historic reasons, the sys_pipe() syscall
on some archit

tools/nolibc: add pipe() and pipe2() support

According to manual page [1], posix spec [2] and source code like
arch/mips/kernel/syscall.c, for historic reasons, the sys_pipe() syscall
on some architectures has an unusual calling convention. It returns
results in two registers which means there is no need for it to do
verify the validity of a userspace pointer argument. Historically that
used to be expensive in Linux. These days the performance advantage is
negligible.

Nolibc doesn't support the unusual calling convention above, luckily
Linux provides a generic sys_pipe2() with an additional flags argument
from 2.6.27. If flags is 0, then pipe2() is the same as pipe(). So here
we use sys_pipe2() to implement the pipe().

pipe2() is also provided to allow users to use flags argument on demand.

[1]: https://man7.org/linux/man-pages/man2/pipe.2.html
[2]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/pipe.html

Suggested-by: Zhangjin Wu <[email protected]>
Link: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Yuan Tan <[email protected]>
Reviewed-by: Thomas Weißschuh <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


Revision tags: v6.5-rc4, v6.5-rc3, v6.5-rc2
# af93807e 15-Jul-2023 Zhangjin Wu <[email protected]>

tools/nolibc: remove the old sys_stat support

The statx manpage [1] shows that it has been supported from Linux 4.11
and glibc 2.28, the Linux support can be checked for all of the
architectures wit

tools/nolibc: remove the old sys_stat support

The statx manpage [1] shows that it has been supported from Linux 4.11
and glibc 2.28, the Linux support can be checked for all of the
architectures with this command:

$ git grep -r statx v4.11 arch/ include/uapi/asm-generic/unistd.h \
| grep -E "aarch64|arm|mips|s390|x86|:include/uapi"

Besides riscv and loongarch, all of the nolibc supported architectures
have added sys_statx from Linux v4.11. riscv is mainlined to v4.15,
loongarch is mainlined to v5.19, both of them use the generic unistd.h,
so, they have added sys_statx from their first mainline versions.

The current oldest stable branch is v4.14, only reserving sys_statx
still preserves compatibility with all of the supported stable branches,
So, let's remove the old arch related and dependent sys_stat support
completely.

This is friendly to the future new architecture porting.

[1]: https://man7.org/linux/man-pages/man2/statx.2.html

Signed-off-by: Zhangjin Wu <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


Revision tags: v6.5-rc1
# f4191f3d 07-Jul-2023 Zhangjin Wu <[email protected]>

tools/nolibc: add rmdir() support

a reverse operation of mkdir() is meaningful, add rmdir() here.

required by nolibc-test to remove /proc while CONFIG_PROC_FS is not
enabled.

Reviewed-by: Thomas W

tools/nolibc: add rmdir() support

a reverse operation of mkdir() is meaningful, add rmdir() here.

required by nolibc-test to remove /proc while CONFIG_PROC_FS is not
enabled.

Reviewed-by: Thomas Weißschuh <[email protected]>
Signed-off-by: Zhangjin Wu <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


# 788aca91 07-Jul-2023 Zhangjin Wu <[email protected]>

tools/nolibc: types.h: add RB_ flags for reboot()

Both glibc and musl provide RB_ flags via <sys/reboot.h> for reboot(),
they don't need to include <linux/reboot.h>, let nolibc provide RB_
flags too

tools/nolibc: types.h: add RB_ flags for reboot()

Both glibc and musl provide RB_ flags via <sys/reboot.h> for reboot(),
they don't need to include <linux/reboot.h>, let nolibc provide RB_
flags too.

Signed-off-by: Zhangjin Wu <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


# 4201cfce 07-Jul-2023 Zhangjin Wu <[email protected]>

tools/nolibc: clean up sbrk() routine

Fix up the error reported by scripts/checkpatch.pl:

ERROR: do not use assignment in if condition
#95: FILE: tools/include/nolibc/sys.h:95:
+ if ((r

tools/nolibc: clean up sbrk() routine

Fix up the error reported by scripts/checkpatch.pl:

ERROR: do not use assignment in if condition
#95: FILE: tools/include/nolibc/sys.h:95:
+ if ((ret = sys_brk(0)) && (sys_brk(ret + inc) == ret + inc))

Apply the new generic __sysret() to merge the SET_ERRNO() and return
lines.

Signed-off-by: Zhangjin Wu <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


# 924e9539 07-Jul-2023 Zhangjin Wu <[email protected]>

tools/nolibc: clean up mmap() routine

Do several cleanups together:

- Since all supported architectures have my_syscall6() now, remove the
#ifdef check.

- Move the mmap() related macros to tools

tools/nolibc: clean up mmap() routine

Do several cleanups together:

- Since all supported architectures have my_syscall6() now, remove the
#ifdef check.

- Move the mmap() related macros to tools/include/nolibc/types.h and
reuse most of them from <linux/mman.h>

- Apply the new generic __sysret() to convert the calling of sys_map()
to oneline code

Note, since MAP_FAILED is -1 on Linux, so we can use the generic
__sysret() which returns -1 upon error and still satisfy user land that
checks for MAP_FAILED.

Suggested-by: Willy Tarreau <[email protected]>
Link: https://lore.kernel.org/lkml/[email protected]/
Signed-off-by: Zhangjin Wu <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


# 6591be4a 07-Jul-2023 Zhangjin Wu <[email protected]>

tools/nolibc: __sysret: support syscalls who return a pointer

No official reference states the errno range, here aligns with musl and
glibc and uses [-MAX_ERRNO, -1] instead of all negative ones.

-

tools/nolibc: __sysret: support syscalls who return a pointer

No official reference states the errno range, here aligns with musl and
glibc and uses [-MAX_ERRNO, -1] instead of all negative ones.

- musl: src/internal/syscall_ret.c
- glibc: sysdeps/unix/sysv/linux/sysdep.h

The MAX_ERRNO used by musl and glibc is 4095, just like the one nolibc
defined in tools/include/nolibc/errno.h.

Suggested-by: Willy Tarreau <[email protected]>
Link: https://lore.kernel.org/lkml/ZKKdD%[email protected]/
Suggested-by: David Laight <[email protected]>
Link: https://lore.kernel.org/linux-riscv/[email protected]/
Signed-off-by: Zhangjin Wu <[email protected]>
Signed-off-by: Willy Tarreau <[email protected]>

show more ...


123