aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd
AgeCommit message (Collapse)AuthorFilesLines
3 daysstdlib: Implement C2Y uabs, ulabs, ullabs and uimaxabsLenard Mollenkopf2-0/+8
C2Y adds unsigned versions of the abs functions (see C2Y draft N3467 and proposal N3349). Tested for x86_64. Signed-off-by: Lenard Mollenkopf <glibc@lenardmollenkopf.de>
9 daysstdlib: Fix qsort memory leak if callback throws (BZ 32058)Adhemerval Zanella1-0/+3
If the input buffer exceeds the stack auxiliary buffer, qsort will malloc a temporary one to call mergesort. Since C++ standard does allow the callback comparison function to throw [1], the glibc implementation can potentially leak memory. The fixes uses a pthread_cleanup_combined_push and pthread_cleanup_combined_pop, so it can work with and without exception enables. The qsort code path that calls malloc now requires some extra setup and a call to __pthread_cleanup_push anmd __pthread_cleanup_pop (which should be ok since they just setup some buffer state). Checked on x86_64-linux-gnu. [1] https://timsong-cpp.github.io/cppwp/n4950/alg.c.library#4 Reviewed-by: DJ Delorie <dj@redhat.com>
2025-03-27Implement C23 pownJoseph Myers2-0/+16
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the pown functions, which are like pow but with an integer exponent. That exponent has type long long int in C23; it was intmax_t in TS 18661-4, and as with other interfaces changed after their initial appearance in the TS, I don't think we need to support the original version of the interface. The test inputs are based on the subset of test inputs for pow that use integer exponents that fit in long long. As the first such template implementation that saves and restores the rounding mode internally (to avoid possible issues with directed rounding and intermediate overflows or underflows in the wrong rounding mode), support also needed to be added for using SET_RESTORE_ROUND* in such template function implementations. This required math-type-macros-float128.h to include <fenv_private.h>, so it can tell whether SET_RESTORE_ROUNDF128 is defined. In turn, the include order with <fenv_private.h> included before <math_private.h> broke loongarch builds, showing up that sysdeps/loongarch/math_private.h is really a fenv_private.h file (maybe implemented internally before the consistent split of those headers in 2018?) and needed to be renamed to fenv_private.h to avoid errors with duplicate macro definitions if <math_private.h> is included after <fenv_private.h>. The underlying implementation uses __ieee754_pow functions (called more than once in some cases, where the exponent does not fit in the floating type). I expect a custom implementation for a given format, that only handles integer exponents but handles larger exponents directly, could be faster and more accurate in some cases. I encourage searching for worst cases for ulps error for these implementations (necessarily non-exhaustively, given the size of the input space). Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-03-24Add _FORTIFY_SOURCE support for inet_ptonAaron Merey2-0/+2
Add function __inet_pton_chk which calls __chk_fail when the size of argument dst is too small. inet_pton is redirected to __inet_pton_chk or __inet_pton_warn when _FORTIFY_SOURCE is > 0. Also add tests to debug/tst-fortify.c, update the abilist with __inet_pton_chk and mention inet_pton fortification in maint.texi. Co-authored-by: Frédéric Bérat <fberat@redhat.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-21Remove eloop-threshold.hAdhemerval Zanella2-11/+7
On both Linux and Hurd the __eloop_threshold() is always a constant (40 and 32 respectively), so there is no need to always call __sysconf (_SC_SYMLOOP_MAX) for Linux case (!SYMLOOP_MAX). To avoid a name clash with gnulib, rename the new file min-eloop-threshold.h. Checked on x86_64-linux-gnu and with a build for x86_64-gnu. Reviewed-by: DJ Delorie <dj@redhat.com>
2025-03-21Add _FORTIFY_SOURCE support for inet_ntopFrédéric Bérat2-0/+2
- Create the __inet_ntop_chk routine that verifies that the builtin size of the destination buffer is at least as big as the size given by the user. - Redirect calls from inet_ntop to __inet_ntop_chk or __inet_ntop_warn - Update the abilist for this new routine - Update the manual to mention the new fortification Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-14Implement C23 powrJoseph Myers2-0/+16
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the powr functions, which are like pow, but with simpler handling of special cases (based on exp(y*log(x)), so negative x and 0^0 are domain errors, powers of -0 are always +0 or +Inf never -0 or -Inf, and 1^+-Inf and Inf^0 are also domain errors, while NaN^0 and 1^NaN are NaN). The test inputs are taken from those for pow, with appropriate adjustments (including removing all tests that would be domain errors from those in auto-libm-test-in and adding some more such tests in libm-test-powr.inc). The underlying implementation uses __ieee754_pow functions after dealing with all special cases that need to be handled differently. It might be a little faster (avoiding a wrapper and redundant checks for special cases) to have an underlying implementation built separately for both pow and powr with compile-time conditionals for special-case handling, but I expect the benefit of that would be limited given that both functions will end up needing to use the same logic for computing pow outside of special cases. My understanding is that powr(negative, qNaN) should raise "invalid": that the rule on "invalid" for an argument outside the domain of the function takes precedence over a quiet NaN argument producing a quiet NaN result with no exceptions raised (for rootn it's explicit that the 0th root of qNaN raises "invalid"). I've raised this on the WG14 reflector to confirm the intent. Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-03-13elf: Canonicalize $ORIGIN in an explicit ld.so invocation [BZ 25263]Adhemerval Zanella1-0/+2
When an executable is invoked directly, we calculate $ORIGIN by calling readlink on /proc/self/exe, which the Linux kernel resolves to the target of any symlinks. However, if an executable is run through ld.so, we cannot use /proc/self/exe and instead use the path given as an argument. This leads to a different calculation of $ORIGIN, which is most notable in that it causes ldd to behave differently (e.g., by not finding a library) from directly running the program. To make the behavior consistent, take advantage of the fact that the kernel also resolves /proc/self/fd/ symlinks to the target of any symlinks in the same manner, so once we have opened the main executable in order to load it, replace the user-provided path with the result of calling readlink("/proc/self/fd/N"). (On non-Linux platforms this resolution does not happen and so no behavior change is needed.) The __fd_to_filename requires _fitoa_word and _itoa_word, which for 32-bits pulls a lot of definitions from _itoa.c (due _ITOA_NEEDED being defined). To simplify the build move the required function to a new file, _fitoa_word.c. Checked on x86_64-linux-gnu and i686-linux-gnu. Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com> Reviewed-by: Geoffrey Thomas <geofft@ldpreload.com> Tested-by: Geoffrey Thomas <geofft@ldpreload.com>
2025-03-07Implement C23 rsqrtJoseph Myers2-0/+16
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the rsqrt functions (1/sqrt(x)). The test inputs are taken from those for sqrt. Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-03-06htl: Make __pthread_sigmask directly call __sigthreadmaskSamuel Thibault1-0/+2
If no thread was created yet, __pthread_sigstate will not find our ss because self->kernel_thread is still nul, and then change the global sigstate instead of our sigstate! We can directly call __sigthreadmask and skip the (bogus) lookup step.
2025-03-06hurd: Consolidate signal mask changeSamuel Thibault3-103/+87
__pthread_sigstate and __sigprocmask were already the same, except for clear_pending.
2025-03-05Remove dl-procinfo.hAdhemerval Zanella1-1/+0
powerpc was the only architecture with arch-specific hooks for LD_SHOW_AUXV, and with the information moved to ld diagnostics there is no need to keep the _dl_procinfo hook. Checked with a build for all affected ABIs. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2025-03-02htl: move pthread_once into libcSamuel Thibault4-2/+4
2025-02-16htl: move pthread_rwlock_init into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-10-gfleury@disroot.org>
2025-02-16htl: move pthread_rwlock_destroy into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-9-gfleury@disroot.org>
2025-02-16htl: move pthread_rwlock_{rdlock, timedrdlock, timedwrlock, wrlock, ↵gfleury4-12/+24
clockrdlock, clockwrlock} into libc. Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-8-gfleury@disroot.org>
2025-02-16htl: move pthread_rwlock_unlock into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-7-gfleury@disroot.org>
2025-02-16htl: move pthread_rwlock_tryrdlock, pthread_rwlock_trywrlock into libc.gfleury4-4/+8
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-6-gfleury@disroot.org>
2025-02-16htl: move pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared into ↵gfleury4-4/+8
libc. Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-5-gfleury@disroot.org>
2025-02-16htl: move pthread_rwlockattr_destroy into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-4-gfleury@disroot.org>
2025-02-16htl: move pthread_rwlockattr_init into libc.gfleury4-2/+4
Signed-off-by: gfleury <gfleury@disroot.org> Message-ID: <20250216145434.7089-3-gfleury@disroot.org>
2025-02-10hurd: Replace char foo[1024] with string_tSamuel Thibault7-7/+7
Like already done in various other places and advised by Roland in https://lists.gnu.org/archive/html/bug-hurd/2012-04/msg00124.html
2025-02-10hurd: Drop useless buffer initialization in ttyname*Samuel Thibault2-2/+0
The RPC stub will write a string anyway.
2025-02-10htl: move pthread_barrier_wait into libc.gfleury4-2/+4
Message-ID: <20250209200108.865599-8-gfleury@disroot.org>
2025-02-10htl: move pthread_barrier_init into libc.gfleury4-2/+4
Message-ID: <20250209200108.865599-7-gfleury@disroot.org>
2025-02-10htl: move pthread_barrier_destroy into libc.gfleury4-2/+4
Message-ID: <20250209200108.865599-6-gfleury@disroot.org>
2025-02-10htl: move pthread_barrierattr_getpshared, pthread_barrierattr_setpshared ↵gfleury4-4/+8
into libc. Message-ID: <20250209200108.865599-5-gfleury@disroot.org>
2025-02-10htl: move pthread_barrierattr_init into libc.gfleury4-2/+4
Message-ID: <20250209200108.865599-4-gfleury@disroot.org>
2025-02-10htl: move pthread_barrierattr_destroy into libc.gfleury4-2/+4
Message-ID: <20250209200108.865599-3-gfleury@disroot.org>
2025-02-01hurd: Use the new __proc_reauthenticate_complete protocolSergey Bugaev1-5/+23
2025-02-01htl: move pthread_setcancelstate into libc.gfleury3-2/+1
sysdeps/pthread/sem_open.c: call pthread_setcancelstate directely since forward declaration is gone on hurd too Message-ID: <20250201080202.494671-1-gfleury@disroot.org>
2025-01-29htl: move pthread_setcanceltype into libc.gfleury3-2/+1
Message-ID: <20250103103750.870897-7-gfleury@disroot.org>
2025-01-29htl: move pthread_mutex_consistent, pthread_mutex_consistent_np into libc.gfleury5-8/+19
Message-ID: <20250103103750.870897-6-gfleury@disroot.org>
2025-01-29htl: move pthread_mutex_destroy into libc.gfleury4-4/+7
Message-ID: <20250103103750.870897-5-gfleury@disroot.org>
2025-01-29htl: move pthread_mutex_getprioceiling, pthread_mutex_setprioceiling into libcgfleury6-8/+24
Message-ID: <20250103103750.870897-4-gfleury@disroot.org>
2025-01-29htl: move pthread_mutex_{lock, unlock, trylock, timedlock, clocklock}gfleury8-24/+34
I haven't exposed _pthread_mutex_lock, _pthread_mutex_trylock and _pthread_mutex_unlock in GLIBC_PRIVATE since there aren't used in any code in libpthread Message-ID: <20250103103750.870897-3-gfleury@disroot.org>
2025-01-29htl: move pthread_mutex_init into libc.gfleury4-4/+7
Message-ID: <20250103103750.870897-2-gfleury@disroot.org>
2025-01-19hurd: Fix EINVAL error on linking to a slash-trailing path [BZ #32569]Samuel Thibault4-7/+23
When the target path finishes with a slash, __file_name_split_at returns an empty file name. We can test for this to refuse doing the link.
2025-01-12hurd: Set _POSIX_MONOTONIC_CLOCK to 200809LSamuel Thibault1-1/+1
Now that CLOCK_MONOTONIC is supported.
2025-01-12hurd: Mark more memory-hungry tests as unsupportedSamuel Thibault1-0/+1
until RLIMIT_AS support gets commited in gnumach.
2025-01-12hurd: Mark more memory-hungry tests as unsupportedSamuel Thibault1-0/+5
until RLIMIT_AS support gets commited in gnumach.
2025-01-12hurd: Mark tst-tls-allocation-failure-static-patched as supportedSamuel Thibault1-3/+0
The failure was not due to RLIMIT_AS but unsupported intentional early abort.
2025-01-12hurd: Cope with signals sent to ourself earlySamuel Thibault1-0/+10
Typically when aborting during initialization, before signals are set up.
2025-01-11hurd: Mark more memory-hungry tests as unsupportedSamuel Thibault1-0/+22
until RLIMIT_AS support gets commited in gnumach.
2025-01-07hurd: Accept null arguments for utimensat pathnameSamuel Thibault1-5/+11
This follows Linux' behavior, making it a replacement for the futimens interface.
2025-01-06hurd: Fix shutdown() errno on non-sockSamuel Thibault1-0/+5
2025-01-02htl: move pthread_mutexattr_setprioceiling, pthread_mutexattr_getprioceiling ↵gfleury6-8/+24
into libc. Message-ID: <20241231134909.1166440-9-gfleury@disroot.org>
2025-01-02htl: move pthread_mutexattr_{setrobust, setrobust_np}, ↵gfleury6-14/+36
pthread_mutexattr_{getrobust, getrobust_np} into libc. Message-ID: <20241231134909.1166440-8-gfleury@disroot.org>
2025-01-02htl: move pthread_mutexattr_setpshared, pthread_mutexattr_getpshared into libc.gfleury6-8/+29
Message-ID: <20241231134909.1166440-7-gfleury@disroot.org>
2025-01-02htl: move pthread_mutexattr_settype, pthread_mutexattr_gettype into libc.gfleury6-7/+22
Message-ID: <20241231134909.1166440-6-gfleury@disroot.org>