summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common
AgeCommit message (Collapse)Author
2024-05-31epoll.h: Add epoll ioctlsJoe Damato
add two ioctls to get and set struct epoll_params to allow users to control epoll based busy polling of network sockets. added to uapi in commit 18e2bf0edf4dd88d9656ec92395aa47392e85b61 (Linux kernel 6.9 and newer). Signed-off-by: Joe Damato <jdamato@fastly.com>
2024-05-20libc/sysdeps/linux/common/utime.c: fix riscv32 buildFabrice Fontaine
Commit 48591e2a259d84247ae38f050bd58e6f7450bb77 forgot to update utime.c resulting in the following riscv32 build failure with applications using utime such as bzip2: /home/buildroot/autobuild/instance-0/output-1/host/riscv32-buildroot-linux-uclibc/bin/ld.real: bzip2.o: in function `copyFileName': bzip2.c:(.text+0x1fcc): undefined reference to `utime' Fixes: 48591e2a259d84247ae38f050bd58e6f7450bb77 - http://autobuild.buildroot.org/results/2e37d4e0bcef515fe9e643737419bfd26aa2833e Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2024-05-18Fix riscv32 build with gcc-14.Dmitry Chestnykh
Add missing includes and function decls. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-05-16Correct uClibc compilation.Dmitry Chestnykh
- Include sys/types.h instead of asm/types.h to prevent types conflict for uClibc typedefs and kernel headers typedefs. - Cast 3rd arg of utimensat_time64 syscall to integer type to avoid compiler's -Wint-conversion error. The error was found during uClibc compilation for mips32. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-05-08futimesat: add missing headerWaldemar Brodkorb
2024-04-18Fix vDSO support for all supported architectures.Dmitry Chestnykh
- Cleanup dl-vdso.c code. - Pass `void *` as first arg to `load_vdso()`, using 32-bit type is completely wrong on 64bit architectures. - Split libc code and vDSO-related code. Move arch-specific implementations into separate files. The performance improvement is for example 50-60 times on ARMv7 and about 4 times on x86_64. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-04-14tree: Remove ^LPetr Vorel
Remove ^L (0x0c) chars from source code. Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2024-04-13Provide fixups for riscv32.Dmitry Chestnykh
- Use TIME64 by default for rv32, usage of 32-bit time leads to a lot of incompatibilities with linux kernel 6.6.x and later versions. - Add some other corrections to use proper system calls on riscv32 platform. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-03-02Add time64 support to ARC.Dmitry Chestnykh
Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-03-01libc: Remove 32bit timespec structures everywhere.Dmitry Chestnykh
With time64 enabled we use statx() system call and the appropriate routines for results conversion. There is no need in `__ts32_struct` anymore. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-02-29libc: restore correct definition of semid_ds struct.Dmitry Chestnykh
Previously the common definition of this structure was broken by a mistake. Restore it correctly for all needed architectures and all use cases. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-02-28libc: always redirect *stat() family to statx() with time64 enabled.Dmitry Chestnykh
Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-02-27Fix *stat() and *stat64() when the time is beyond year 2038.Dmitry Chestnykh
To obtain correct `st_atim`, `st_mtim` and `st_ctim` fields we need to use statx() syscall and then convert the data from the kernel to the regular stat structure. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-02-26Add time64 support for MIPS32.Dmitry Chestnykh
Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-02-25Add support for using time64 on big-endian machines.Dmitry Chestnykh
For BE architectures there is one significant difference in comparison with time64 support for little-endian architectures like ARMv7. The difference is that we strictly need to pass two 64bit values to system calls because Linux Kernel internally uses `struct __kernel_timespec` and similar, which consists of two 64bit fields. For this reason many files have been changed to convert pointers to timespec-family structures (mixed of 64bit and 32bit values) to the pointer of the similar but 64bit-only structures for using as system calls args. This is general prerequisite for any BE architecture. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-02-22Introduce time64 support.Dmitry Chestnykh
This patch introduces *time64 syscalls support for uClibc-ng. Currently the redirection of syscalls to their *time64 analogs is fully supported for 32bit ARM (ARMv5, ARMv6, ARMv7). The main changes that take effect when time64 feature is enabled are: - sizeof(time_t) is 8. - There is a possibility os setting date beyond year 2038. - some syscalls are redirected: clock_adjtime -> clock_adjtime64 clock_getres -> clock_getres_time64 clock_gettime -> clock_gettime64 clock_nanosleep -> clock_nanosleep_time64 clock_settime -> clock_settime64 futex -> futex_time64 mq_timedreceive -> mq_timedreceive_time64 mq_timedsend -> mq_timedsend_time64 ppoll -> ppoll_time64 pselect6 -> pselect6_time64 recvmmsg -> recvmmsg_time64 rt_sigtimedwait -> rt_sigtimedwait_time64 sched_rr_get_interval -> sched_rr_get_interval_time64 semtimedop -> semtimedop_time64 timer_gettime -> timer_gettime64 timer_settime -> timer_settime64 timerfd_gettime -> timerfd_gettime64 timerfd_settime -> timerfd_settime64 utimensat -> utimensat_time64. - settimeofday uses clock_settime (like in glibc/musl). - gettimeofday uses clock_gettime (like in glibc/musl). - nanosleep uses clock_nanosleep (like in glibc/musl). - There are some fixes in data structures used by libc and kernel for correct data handling both with and without enabled time64 support. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2024-02-18add newline at end of fileWaldemar Brodkorb
2023-11-10prlimit: add name redirection and fix incorrect parameters to syscallPavel Kozlov
The tst-rlimit/tst-rlimit64 tests pointed to several issueses in prlimit() function for 32-bit CPUs. This patch adds name redirection to prlimit64 in prlimit declaration to provide correct support for 64-bit offset (_FILE_OFFSET_BITS=64) on 32-bit CPUs and fixes improper field assignment and incorrect syscall paramerets in the prlimit() function. Fixes: 8c2f6218 ("setrlimit/getrlimit: fix prlimit64 syscall use for 32-bit CPUs") Signed-off-by: Pavel Kozlov <pavel.kozlov@synopsys.com>
2023-10-28Fix -Warray-parameter warning for __sigsetjmpPavel Kozlov
Fix the [-Warray-parameter=] warning for __sigsetjmp generated by GCC 11 and later GCC versions: | | warning: argument 1 of type 'struct __jmp_buf_tag *' declared as a pointer [-Warray-parameter=] | extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL; | ... | note: previously declared as an array 'struct __jmp_buf_tag[1]' | extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) | Use the same fix as in glibc. The fix is to move the struct __jmp_buf_tag definition to a separate bits/ header so it can be included in pthread.h, to allow to use an array (as in setjmp.h) rather than a pointer in the declaration. Signed-off-by: Pavel Kozlov <pavel.kozlov@synopsys.com>
2023-10-27setrlimit/getrlimit: fix prlimit64 syscall use for 32-bit CPUsPavel Kozlov
Commit 95e38b37 ("add support for systems without legacy setrlimit/getrlimit syscalls") has added use of the prlimit64 syscall in getrlimit and setrlimit functions. This change causes memory corruption on getrlimit call for 32-bit CPUs like ARC, as ARC doesn't have ugetrlimit syscall and uses prlimit64. Also, setrlimit has been broken by prlimit64 call on 32-bit CPUs like, i386, ARM, ARC. For the prlimit64 syscall the kernel expects an rlimit struct with 64-bit fields, but on 32-bit CPUs without _FILE_OFFSET_BITS=64 the struct rlimit has 32-bit fields. Add safe implementations of getrlimit, setrlimit, prlimit for 32-bit CPUs with a local struct rlimit64 variable for use in the prlimit64 syscall. For 64-bit CPUs and configurations with _FILE_OFFSET_BITS=64 use getrlimit, setrlimit, prlimit as aliases to getrlimit64, setrlimit64 and prlimit64. Add a new function prlimit64. Tested on aarch64, arm, i386, arc. Fixes: 95e38b37 ("add support for systems without legacy setrlimit/getrlimit syscalls") Signed-off-by: Pavel Kozlov <pavel.kozlov@synopsys.com>
2023-10-27depend on __UCLIBC_HAVE_STATX__Waldemar Brodkorb
Fixes compilation issues on mips64 n32.
2023-09-15fork: generate stub on no-MMU systemsBen Wolsieffer
fork() can be implemented using either the fork or clone syscalls on MMU systems. Therefore the stub is only generated if neither __NR_fork nor __NR_clone are defined. The stub code manually undefines __NR_fork on no-MMU systems in an attempt to enable the stub, but this doesn't work because __NR_clone is still defined. It is not appropriate to undefine __NR_clone because clone is available on no-MMU, it is just not capable of implementing fork. This patch directly enables the fork stub if __ARCH_USE_MMU__ is not defined. This eliminates the need to undefine __NR_fork, so this code is removed Signed-off-by: Ben Wolsieffer <ben.wolsieffer@hefring.com>
2023-09-14fstatat: add wrapper that uses statx for non-legacy archYann Sionneau
Add fstatat wrapper that uses statx for non-legacy arch. This allows non-legacy arch to opt-out from defining the old stat* syscalls by not defining __ARCH_WANT_NEW_STAT in their arch/xxx/include/asm/unistd.h Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2023-09-14add support for systems without legacy setrlimit/getrlimit syscallsYann Sionneau
Those must have the recent prlimit64 syscall which exists since Linux 3.2. This patch is necessary for non-legacy architectures that wish to remove support for legacy setrlimit/getrlimit syscalls. The non-legacy arch are those who opt-out via non defining __ARCH_WANT_SET_GET_RLIMIT in their arch/xxx/include/uapi/asm/unistd.h setrlimit and getrlimit are then emulated via the new prlimit64 syscall. Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2023-09-14fstat: add missing return value statement for the statx wrapping caseYann Sionneau
Add missing return value statement to fstat for the statx wrapping case. Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2023-09-14fstatat64: define it as a wrapper of statx if the kernel does not support ↵Yann Sionneau
fstatat64 syscall Define fstatat64 as a wrapper of statx if the kernel does not support fstatat64 syscall This is the case for non-legacy architectures that don't define __ARCH_WANT_NEW_STAT in their linux arch/xxx/include/asm/unistd.h Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2023-08-14gettimeofday() only include ldso.h if vdso support is activatedlordrasmus
2023-08-08aarch64: add hwcap header fileWaldemar Brodkorb
2023-08-02add missing wchar.h, fixes a compile error with openadkWaldemar Brodkorb
2023-07-14[PATCH] libc/sysdeps/linux/common/bits/wchar.h: resync with glibc, fix build ↵Waldemar Brodkorb
issue with gcc 12 The current definition of __WCHAR_MIN and __WCHAR_MAX are only correct when wchar_t is an int. This is not the case on ARM/AArch64 where wchar_t is an unsigned int, or some other architectures where wchar_t is a long. The current incorrect definition causes a build issue for example when building mpd, which uses boost, with gcc 12.x: In file included from /home/thomas/buildroot/aarch64/host/aarch64-buildroot-linux-uclibc/sysroot/usr/include/boost/integer.hpp:20, from /home/thomas/buildroot/aarch64/host/aarch64-buildroot-linux-uclibc/sysroot/usr/include/boost/crc.hpp:42, from ../src/storage/StorageState.cxx:43: /home/thomas/buildroot/aarch64/host/aarch64-buildroot-linux-uclibc/sysroot/usr/include/boost/integer_traits.hpp:105:69: error: narrowing conversion of ‘-2147483648’ from ‘int’ to ‘wchar_t’ [-Wnarrowing] 105 | public detail::integer_traits_base<wchar_t, WCHAR_MIN, WCHAR_MAX> | ^ This issue was fixed in glibc in 2013, see bug report https://sourceware.org/bugzilla/show_bug.cgi?id=15036, and upstream commit https://sourceware.org/git/?p=glibc.git;a=commit;h=052aff95782fefe9c63566471063e8b20836bfb8. Since the i386-specific definition of __WCHAR_MIN and __WCHAR_MAX was also removed at the same time in glibc, we do the same as part of this commit. Reported-by: Clément Ramirez <clement.ramirez@bootlin.com> With-some-useful-help-from: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-05-10gettimeofday: fix static buildWaldemar Brodkorb
2023-03-13Emulate 'futimesat' when __NR_futimesat is not available.Elliot Thomas
2023-01-22Defined MAP_FIXED_NOREPLACElinted
Added definition for MAP_FIXED_NOREPLACE which was added in kernel 4.17 Signed-off-by: linted <linted@users.noreply.github.com>
2022-12-19gettimeofday() vdso supportramin
2022-12-19sycall macro for vdso supportramin
2022-08-08resource.h: add missing RUSAGE_THREADWaldemar Brodkorb
There is a real-world usage of RUSAGE_THREAD by the pistache project, https://github.com/oktal/pistache. Reported-By: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2022-05-20define RLIMIT_RTTIME, bump RLIMIT_NLIMITSRomain Naour
This macro exists since Linux 2.6.25 [1] and is defined in glibc since 2.14 [2] for sparc and most supported architectures. RLIMIT_RTTIME has been added later for mips [3] and alpha [4]. For example, RLIMIT_RTTIME is needed to build qemu 7.0.0 with Linux user-land emulation support [5]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=78f2c7db6068fd6ef75b8c120f04a388848eacb5 [2] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=67f86a251e0d36107fe28999281d46e76941c7b9 [3] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=8969f4df1a526aa60dd0bc1c4736cf02104d4a05 [4] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=53c2cb7641bd866398156625ef672bbd2d78a0d8 [5] https://git.qemu.org/?p=qemu.git;a=commitdiff;h=244fd08323088db73590ff2317dfe86f810b51d7 Signed-off-by: Romain Naour <romain.naour@gmail.com>
2022-02-27guard prlimit, reported by Lance FredricksonWaldemar Brodkorb
2022-01-28sched.h: Add SCHED_DEADLINEPetr Vorel
Defined in kernel v3.14, commit aab03e05e8f7 ("sched/deadline: Add SCHED_DEADLINE structures & implementation") Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2022-01-21add prlimit syscall wrapper, now for realWaldemar Brodkorb
2022-01-21add prlimit syscall wrapperWaldemar Brodkorb
2021-12-24Fix some warnings due to type issuesYann Sionneau
Fixes those two warnings: In file included from <command-line>: libc/sysdeps/linux/common/openat64.c:18:33: warning: 'openat64' alias between functions of incompatible types 'int(int, const char *, int, ...)' and 'int(int, const char *, int, mode_t)' {aka 'int(int, const char *, int, unsigned int)'} [-Wattribute-alias=] 18 | strong_alias_untyped(__openat64,openat64) | ^~~~~~~~ ./include/libc-symbols.h:177:31: note: in definition of macro '_strong_alias_untyped' 177 | extern __typeof (aliasname) aliasname __attribute__ ((alias (#name))) __attribute_copy__ (name); | ^~~~~~~~~ libc/sysdeps/linux/common/openat64.c:18:1: note: in expansion of macro 'strong_alias_untyped' 18 | strong_alias_untyped(__openat64,openat64) | ^~~~~~~~~~~~~~~~~~~~ libc/sysdeps/linux/common/openat64.c:14:12: note: aliased declaration here 14 | static int __openat64(int fd, const char *file, int oflag, mode_t mode) | ^~~~~~~~~~ and CC libc/sysdeps/linux/common/stat.os libc/sysdeps/linux/common/stat.c: In function 'stat': libc/sysdeps/linux/common/stat.c:28:40: warning: passing argument 3 of 'fstatat64' from incompatible pointer type [-Wincompatible-pointer-types] 28 | return fstatat64(AT_FDCWD, file_name, buf, 0); | ^~~ | | | struct stat * In file included from libc/sysdeps/linux/common/stat.c:11: ./include/sys/stat.h:258:35: note: expected 'struct stat64 * restrict' but argument is of type 'struct stat *' 258 | struct stat64 *__restrict __buf, int __flag) | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
2021-04-09open: Add support for O_TMPFILENicolas Cavallari
Since Linux 3.11, O_TMPFILE allows to create unnamed files that can be linked later on. It is internally defined as (O_TMPFILE | O_DIRECTORY) to make it fail on old kernels. Copying definitions from glibc for O_TMPFILE is not enough to support O_TMPFILE; The open() wrapper also need to pass the mode when the flag contains O_TMPFILE, otherwise, it will pass mode 000 which will succeed but yield unexpected results. openat() is curiously not affected since it passes the mode unconditionally.. Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
2021-01-28use renameat2 syscall, when renameat isn't availableWaldemar Brodkorb
2021-01-27fix umount2 compilation for alpha on Linux 5.xWaldemar Brodkorb
2020-08-19Add {name, open}_to_handle_at() implementationPetr Vorel
copied from musl 1.2.1. Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2020-08-15sys/random.h include stddef.hWaldemar Brodkorb
Reported-By: akater <nuclearspace@gmail.com>
2020-07-02Rename __unused struct members to include a namespaceEd Wildgoose
Rename various spare fields in structs to include a namespace This should avoid accidental clashes with uses of the __unused symbol in upstream projects. eg currently it causes a compile error in dhcpcd 8.x due to their re-use of the __unused symbol as a macro This follows the style of glibc which does something equivalent
2020-04-01statx: make include conditional, fixes non-csky arch buildroot buildsWaldemar Brodkorb
2020-02-07common/bits: Fix ipc_perm and semid_ds definitions for 64-bit archesVladimir Murzin
It fixes: FAIL sem got 1 expected 0 failed: incorrect sem_nsems! semget(IPC_CREAT) = 0 semctl(k) = 0 sem_nsems = 0 for aarch64. Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>