- 09 Jan, 2022 22 commits
-
-
A. Wilcox authored
The implementation of memalign(3) uses _BSD_SOURCE, so we will too.
-
A. Wilcox authored
renameat(2) is supposed to ignore if old or new is a hardlink to the other. However, the way this is written, it also ignores if old or new are symlinks to one another. This is incorrect.
-
A. Wilcox authored
-
A. Wilcox authored
-
A. Wilcox authored
-
A. Wilcox authored
-
A. Wilcox authored
- Fail if old or new is longer than PATH_MAX with ENAMETOOLONG. - Fail if old or new is 0 bytes long. - Fail if old or new has dot or dot-dot as the last component of their path name. The Linux kernel provides none of these behaviours.
-
A. Wilcox authored
-
A. Wilcox authored
-
A. Wilcox authored
-
A. Wilcox authored
These interfaces are all scheduled for addition in Issue 8. They cannot be available if _XOPEN_SOURCE is <= 700, or _POSIX_C_SOURCE is <= 200809L.
-
A. Wilcox authored
-
A. Wilcox authored
-
A. Wilcox authored
-
A. Wilcox authored
-
As Rick stated, this isn't a clean solution because argv can be arbirtary long and overflow the stack. I post it here in case you'd find it useful anyway.
-
A. Wilcox authored
The timespec_get function, and TIME_* macros, are only in C11. Since musl is compiled with -std=c99, TIME_UTC is unavailable in the timespec_get implementation, so we use the raw value 1.
-
A. Wilcox authored
aligned_alloc, at_quick_exit, and quick_exit are new in C11 and C++11. Only make these symbols visible in those versions, to avoid polluting the namespace of C99 and POSIX 2008 sources.
-
A. Wilcox authored
This is not a POSIX function, it should not be visible there.
-
A. Wilcox authored
Right now, this is a worst-case assumption; some kernels may actually have a value of 100000 here (100 Hz timers). This is considered the easiest implementation. This is required to be present in <unistd.h>.
-
A. Wilcox authored
This is used to determine what CFLAGS/LDFLAGS are needed to enable compilation with threads on musl. We don't have any special ones, so just return an empty string. This is required to be present in <unistd.h>.
-
A. Wilcox authored
We definitely don't /support/ UUCP, so return -1 for it. But this value is required to be present in <unistd.h>.
-
- 29 Nov, 2021 2 commits
-
-
Ismael Luceno authored
This should be safer for casting and more compatible with existing code bases that wrongly assume it must be defined as a pointer.
-
Rich Felker authored
commit 7be59733 introduced the hwcap-based branches to support the SPE FPU, but wrongly coded them as bitwise tests on the computed address of __hwcap, not a value loaded from that address. replace the add with indexed load to fix it.
-
- 19 Oct, 2021 1 commit
-
-
Rich Felker authored
the snd_pcm_mmap_control struct used with SNDRV_PCM_IOCTL_SYNC_PTR was mistakenly defined in the kernel uapi with "before u32" padding both before and after the first u32 member. our conversion between the modern struct and the legacy time32 struct was written without awareness of that mistake, and assumed the time64 version of the struct was the intended form with padding to match the layout on 64-bit archs. as a result, the struct was not converted correctly when running on old kernels, with audio glitches as the likely result. this was discovered thanks to a related bug in the kernel, whereby 32-bit userspace running on a 64-bit kernel also suffered from the types mismatching. the mistaken layout is now the ABI and can't be changed -- or at least making a new ioctl to change it would just result in a worse situation. our conversion here is changed to treat the snd_pcm_mmap_control substruct as two separate substructs at locations dependent on endianness (since the displacement depends on endianness), using the existing conversion framework.
-
- 24 Sep, 2021 1 commit
-
-
Érico Nogueira authored
we make qsort a wrapper by providing a wrapper_cmp function that uses the extra argument as a function pointer. should be optimized to a tail call on most architectures, as long as it's built with -fomit-frame-pointer, so the performance impact should be minimal. to keep the git history clean, for now qsort_r is implemented in qsort.c and qsort is implemented in qsort_nr.c. qsort.c also received a few trivial cleanups, including replacing (*cmp)() calls with cmp(). qsort_nr.c contains only wrapper_cmp and qsort as a qsort_r wrapper itself.
-
- 23 Sep, 2021 1 commit
-
-
Rich Felker authored
When the soft-float ABI for PowerPC was added in commit 5a92dd95, with Freescale cpus using the alternative SPE FPU as the main use case, it was noted that we could probably support hard float on them, but that it would involve determining some difficult ABI constraints. This commit is the completion of that work. The Power-Arch-32 ABI supplement defines the ABI profiles, and indeed ATR-SPE is built on ATR-SOFT-FLOAT. But setjmp/longjmp compatibility are problematic for the same reason they're problematic on ARM, where optional float-related parts of the register file are "call-saved if present". This requires testing __hwcap, which is now done. In keeping with the existing powerpc-sf subarch definition, which did not have fenv, the fenv macros are not defined for SPE and the SPEFSCR control register is left (and assumed to start in) the default mode.
-
- 12 Sep, 2021 1 commit
-
-
Rich Felker authored
both passing a null pointer to memcpy with length 0, and adding 0 to a null pointer, are undefined. in some sense this is 'benign' UB, but having it precludes use of tooling that strictly traps on UB. there may be better ways to fix it, but conditioning the operations which are intended to be no-ops in the k==0 case on k being nonzero is a simple and safe solution.
-
- 12 Aug, 2021 1 commit
-
-
Rich Felker authored
commit 6d99ad91 introduced this regression as part of a larger change, based on an incorrect assumption that rdhwr being part of the mips r2 ISA level meant that the TLS register, known in the mips documentation as UserLocal, was unconditionally present on chips providing this ISA level and would not need trap-and-emulate. this turns out to be false. based on research by Stanislav Kljuhhin and Abilio Marques, who reported the problem as a performance regression on certain routers using OpenWRT vs older uclibc-based versions, it turns out the mips manuals document the UserLocal register as a feature that might or might not be implemented or enabled, reflected by a cpu capability bit in the CONFIG3 register, and that Linux checks for this and has to explicitly enable it on models that have it. thus, it's indeed possible that r2+ chips can lack the feature, bringing us back to the situation where Linux only has a fast trap-and-emulate path for the case where the destination register is $3. so, always read the thread pointer through $3. this may incur a gratuitous move to the desired final register on chips where it's not needed, but it really doesn't matter.
-
- 06 Aug, 2021 1 commit
-
-
Érico Nogueira authored
len is unsigned and can never be smaller than 0. though unlikely, an error in read() would have lead to an out of bounds write to name. Reported-by:
Michael Forney <mforney@mforney.org>
-
- 30 Jul, 2021 1 commit
-
-
Rich Felker authored
due to historical reasons, the mips signal set has 128 bits rather than 64 like on every other arch. this was special-cased correctly, at least for 32-bit mips, at one time, but was inadvertently broken in commit 7c440977, and seems never to have been right on mips64/n32. as consequenct of this bug, applications making use of high realtime signal numbers on mips may have been able to execute application code in contexts where doing so was unsafe.
-
- 07 Jul, 2021 1 commit
-
-
Rich Felker authored
the kernel structure has padding of the shm_segsz member up to 64 bits, as well as 2 unused longs at the end. somehow that was overlooked when the powerpc port was added, and it has been broken ever since; applications compiled with the wrong definition do not correctly see the shm_segsz, shm_cpid, and shm_lpid members. fixing the definition just by adding the missing padding would break the ABI size of the structure as well as the position of the time64 shm_atime and shm_dtime members we added at the end. instead, just move one of the unused padding members from the original end (before time64) of the structure to the position of the missing padding. this preserves size and preserves correct behavior of any compiled code that was already working. programs affected by the wrong definition need to be recompiled with the correct one.
-
- 06 Jul, 2021 1 commit
-
-
Szabolcs Nagy authored
-
- 23 Jun, 2021 1 commit
-
-
Rich Felker authored
previously, the contents of the TZ variable were considered a candidate for a file/path name only if they began with a colon or contained a slash before any comma. the latter was very sloppy logic to avoid treating any valid POSIX TZ string as a file name, but it also triggered on values that are not valid POSIX TZ strings, including 3-letter timezone names without any offset. instead, only treat the TZ variable as POSIX form if it begins with a nonzero standard time name followed by +, -, or a digit. also, special case GMT and UTC to always be treated as POSIX form (with implicit zero offset) so that a stray file by the same name cannot break software that depends on setting TZ=GMT or TZ=UTC.
-
- 05 Jun, 2021 1 commit
-
-
Khem Raj authored
on riscv64 this syscall is called __NR_newfstatat this helps the name match kernel UAPI for external programs
-
- 27 Apr, 2021 1 commit
-
-
Michael Forney authored
-
- 20 Apr, 2021 4 commits
-
-
Érico Nogueira authored
the function already returns (void *)
-
Érico Rolim authored
based on the pthread_setname_np implementation
-
Rich Felker authored
POSIX places an obscure requirement on popen which is like a limited version of close-on-exec: "The popen() function shall ensure that any streams from previous popen() calls that remain open in the parent process are closed in the new child process." if the POSIX-future 'e' mode flag is passed, producing a pipe FILE with FD_CLOEXEC on the underlying pipe, this requirement is automatically satisfied. however, for applications which use multiple concurrent popen pipes but don't request close-on-exec, fd leaks from earlier popen calls to later ones could produce deadlock situations where processes are waiting for a pipe EOF that will never happen. to fix this, iterate through all open FILEs and add close actions for those obtained from popen. this requires holding a lock on the open file list across the posix_spawn call so that additional popen FILEs are not created after the list is traversed. note that it's still possible for another popen call to start and create its pipe while the lock is held, but such pipes are created with O_CLOEXEC and only drop close-on-exec status (when 'e' flag is omitted) under control of the lock.
-
Rich Felker authored
the newly allocated FILE * has not yet leaked to the application and is only visible to stdio internals until popen returns. since we do not change any fields of the structure observed by libc internals, only the pipe_pid member, locking is not necessary.
-