1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00
Commit Graph

1781 Commits

Author SHA1 Message Date
Collin Funk
4900f993c8 manual: Remove '.info' suffix in manual names passed to @ref [BZ #32962].
Texinfo 7.2 began warning about the '.info' suffix in the manual names
passed to @ref and similar commands.  They eventually plan to stop
stripping the '.info' suffix internally which will lead to broken links
in the manuals without this change.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-07-03 05:19:42 +01:00
Jitka Obselkova
53ea6db9fd manual: Clarify renameat documentation
Clarify the meaning of renameat arguments.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2025-06-26 14:24:40 +02:00
Florian Weimer
1149b4f64f Revert "manual: Clarify renameat documentation"
This reverts commit abc2e954af.
Reason for revert: Wrong version of the patch.
2025-06-26 14:22:58 +02:00
Ravina Jain
b2a8d19f4a manual: Add missing free to open_memstream example [BZ #27866]
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2025-06-25 14:26:32 +02:00
Jitka Obselkova
abc2e954af manual: Clarify renameat documentation
Clarify the meaning of renameat arguments.

Signed-off-by: Jitka Obselkova <jobselko@redhat.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2025-06-18 16:03:20 -03:00
H. Peter Anvin (Intel)
5f138519eb termios: add new baud_t interface, defined to be explicitly numeric
Add an explicitly numeric interface for baudrate setting. For glibc,
this only announces what is a fair accompli, but this is a plausible
way forward for standardization, and may be possible to infill on
non-compliant systems. The POSIX committee has stated:

[https://www.austingroupbugs.net/view.php?id=1916#c7135]

	A future version of this standard is expected to add at least
	the following symbolic constants for use as values of objects
	of type speed_t: B57600, B115200, B230400, B460800, and
	B921600.

	Implementations are encouraged to propose additional
	interfaces which will make it possible to set and query a
	wider range of speeds than just those enumerated by the
	constants beginning with B. If a set of common interfaces
	emerges between several implementations, a future version of
	this standard will likely add those interfaces.

This is exactly that interface.

The use of the term "baud" is due to the need to have a term
contrasting "speed", and it is already well established as a legacy
term -- including in the names of the legacy Bxxx
constants. Futhermore, it *is* valid from the point of view that the
termios interface fundamentally emulates an RS-232 serial port as far
as the application software is concerned.

The documentation states that for the current version of glibc,
speed_t == baud_t, but explicitly declares that this may not be the
case in the future.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-06-17 09:11:38 -03:00
H. Peter Anvin (Intel)
98aeca349a manual: document all the termios Bxxx constants in the manual
Add all the Bxxx constants defined in the now-generic
<bits/termios-baud.h> in the manual.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-06-17 09:11:38 -03:00
Maciej W. Rozycki
62fba6d980 manual: Add a comparative example of 'clock_nanosleep' use
Add an illustrative example of how to express 'nanosleep' in terms of
'clock_nanosleep'.
2025-06-06 18:14:34 +01:00
Arjun Shankar
25f1d94576 manual: Document futimens and utimensat
Document futimens and utimensat.  Also document the EINVAL error
condition for futimes.  It is inherited by futimens and utimensat as
well.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-06-04 20:17:04 +02:00
Arjun Shankar
75b725717f manual: Document unlinkat
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-06-04 20:17:04 +02:00
Arjun Shankar
60f86c9cd0 manual: Document renameat
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-06-04 20:17:04 +02:00
Arjun Shankar
49766eb1a5 manual: Document mkdirat
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-06-04 20:17:04 +02:00
Arjun Shankar
941157dbcd manual: Document faccessat
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-06-04 20:17:04 +02:00
Arjun Shankar
3b21166c4d manual: Expand Descriptor-Relative Access section
Improve the clarity of the paragraphs describing common flags and add a
list of common error conditions for descriptor-relative functions.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-06-04 20:17:04 +02:00
Maciej W. Rozycki
140b20e971 manual: Document error codes missing for 'inet_pton'
Add documentation for EAFNOSUPPORT error code returned, and the possible
return values on non-success.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-06-04 16:27:20 +01:00
Maciej W. Rozycki
5a9020eeb2 manual: Document error codes missing for 'if_nametoindex'
Add documentation for ENODEV error code returned and refer to 'socket'
for further possible codes from the underlying function call.

While changing the text clarify the description by mentioning 'ifname'.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-06-04 16:27:20 +01:00
Maciej W. Rozycki
46acdf46cc manual: Document error codes missing for 'if_indextoname'
Add documentation for ENXIO error code returned and refer to 'socket'
for further possible codes from the underlying function call.

While changing the text clarify the description by mentioning 'ifname'
and replace @code tags with @var ones where referring to a function
parameter.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-06-04 16:27:20 +01:00
Arjun Shankar
591283a689 manual: Correct return value description of 'clock_nanosleep'
Commit 1a3d8f2201 incorrectly described
'clock_nanosleep' as having the same return values as 'nanosleep'.  Fix
this, clarifying that 'clock_nanosleep' returns a positive error number
upon failure instead of setting 'errno'.  Also clarify that 'nanosleep'
returns '-1' upon error.

Fixes: 1a3d8f2201
Reported-by: Mark Harris <mark.hsj@gmail.com>
Reviewed-by: Mark Harris <mark.hsj@gmail.com>
2025-06-02 16:06:11 +02:00
Arjun Shankar
1a3d8f2201 manual: Document clock_nanosleep
Make minor clarifications in the documentation for 'nanosleep' and add
an entry for 'clock_nanosleep' as a generalized variant of the former
function that allows clock selection.
Reviewed-by: Maciej W. Rozycki <macro@redhat.com>
2025-05-30 18:16:57 +02:00
Maciej W. Rozycki
9a743032cd manual: Fix invalid 'illegal' usage with 'nanosleep'
The GNU Coding Standards demand that 'illegal' only be used to refer to
activities prohibited by law.  Replace it with 'invalid' accordingly in
the description of the EINVAL error condition for 'nanosleep'.
2025-05-30 15:01:51 +01:00
Maciej W. Rozycki
bc4202521c manual: Fix duplicate 'consult' erratum
Remove 'consult' duplication appearing in Extensible Scheduling section.
2025-05-30 15:01:50 +01:00
Maciej W. Rozycki
79b5febd76 manual: Document error codes missing for 'inet_ntop'
Add documentation for EAFNOSUPPORT and ENOSPC error codes returned, and
the return value on failure.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-29 22:11:38 +01:00
Maciej W. Rozycki
43afae31e0 manual: Document error codes missing for 'socket'
Add missing EAFNOSUPPORT, ESOCKTNOSUPPORT, EPROTOTYPE, EINVAL, EPERM,
and ENOMEM error codes, and adjust existing descriptions accordingly.

On Linux either ENOBUFS or ENOMEM is returned in the case of a memory
allocation failure, depending on the namespace requested, e.g. AF_INET
returns ENOMEM while AF_INET6 returns ENOBUFS, so document these codes
as alternatives.

Similarly EPERM is returned rather than EACCES on Linux, so document
these codes as alternatives as well.  We might want to convert EPERM to
EACCES for POSIX compliance, but it is beyond the scope of this change,
and software has to expect either anyway, owing to the long-established
practice.

Finally ESOCKTNOSUPPORT is returned rather than EPROTONOSUPPORT for an
unsupported style except for the AF_QIPCRTR namespace where EPROTOTYPE
is used, so document these codes as alternatives too.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-29 22:11:38 +01:00
Yury Khrustalev
ea30c67030 manual: mention PKEY_UNRESTRICTED macro in the manual
Also use this macro in one of the examples.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-28 11:00:02 +01:00
Jonathan Wakely
a484b76cd7 doc: Add missing space in documentation of __TIMESIZE 2025-05-27 11:42:50 +01:00
Jonathan Wakely
b4784d61b3 doc: Fix typos in documentation of _TIME_BITS 2025-05-27 11:42:49 +01:00
Tomas Volf
99c70ae6e9 manual: Document getopt_long_only with single letter options (bug 32980)
Signed-off-by: Tomas Volf <~@wolfsden.cz>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-26 15:53:54 +02:00
Carlos O'Donell
4052d99ead manual: Use more inclusive language in comments.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-21 12:48:25 -04:00
DJ Delorie
579f866881 manual: add sched_getcpu()
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2025-05-16 13:16:08 -04:00
Florian Weimer
6c9bb270d6 manual: Clarifications for listing directories
Support for seeking is limited.  Using the d_off and d_reclen members
of struct dirent is discouraged, especially with readdir.  Concurrent
modification of directories during iteration may result in duplicate
or missing etnries.
2025-05-16 16:47:02 +02:00
DJ Delorie
21e54f160f manual: add remaining CPU_* macros
Adds remaining CPU_* macros, including the CPU_*_S macros
for dynamic-sized cpu sets.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2025-05-15 16:25:17 -04:00
Joseph Myers
06caf53adf Implement C23 rootn.
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the rootn functions, which compute the Yth root of X for
integer Y (with a domain error if Y is 0, even if X is a NaN).  The
integer 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.

As with pown and compoundn, I strongly encourage searching for worst
cases for ulps error for these implementations (necessarily
non-exhaustively, given the size of the input space).  I also expect a
custom implementation for a given format could be much faster as well
as more accurate, although the implementation is simpler than those
for pown and compoundn.

This completes adding to glibc those TS 18661-4 functions (ignoring
DFP) that are included in C23.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118592 regarding the C23
mathematical functions (not just the TS 18661-4 ones) missing built-in
functions in GCC, where such functions might usefully be added.

Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-05-14 10:51:46 +00:00
Stefan Liebler
4b1ffb828c powerpc64le: Remove configure check for objcopy >= 2.26.
Due to raising the minimum binutils version to >= 2.26, the configure
check for testing support of --update-section is not needed anymore.
Reviewed-by: Peter Bergner <bergner@tenstorrent.com>
2025-05-14 10:35:55 +02:00
Stefan Liebler
e53ab20892 Raise the minimum binutils version to 2.39
The recent commit 27b96e069a raises the minimum
GCC version to 12.1 which was released in 2022.

The current minimum bintuils version 2.25 was released end of 2014.  This patch
now raises the minimum binutils version to 2.39 which was also released in 2022.

The hint for ARC is not needed anymore.

In sysdeps/[alpha|hppa|csky]/configure.ac, PIE is unsupported with this comment:
PIE builds fail on binutils 2.37 and earlier, see:
https://sourceware.org/bugzilla/show_bug.cgi?id=28672
This patch keeps PIE unsupported and let the machine maintainers test and
enable it later.

In sysdeps/arm/configure.ac, there is a check whether TPOFF relocs with addends
are assembled correctly, which is known to be broken in binutils 2.24 and 2.25.
See: https://sourceware.org/bugzilla/show_bug.cgi?id=18383
This patch keeps the check as is and let the machine maintainers check if it
still required.

According to Florian Weimer:
Having at least binutils 2.38 will allow us to assume that this linker
bug is fixed:
Bug 28743 - -z relro creats holes in the process image on GNU/Linux
<https://sourceware.org/bugzilla/show_bug.cgi?id=28743>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-14 10:35:55 +02:00
DJ Delorie
f176bf2a06 manual: fix typo for sched_[sg]etattr
Originally added in 41a90f3f5f which says it's adding sched_getattr
and sched_setattr.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2025-05-12 17:07:23 -04:00
Joseph Myers
f451a02a8c Document all CLOCK_* values
The manual documents CLOCK_REALTIME and CLOCK_MONOTONIC but not other
CLOCK_* values.  Add documentation of the POSIX clocks
CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID, along with a
reference to the Linux man pages for the semantics of the
Linux-specific clocks supported (as with some other functionality
coming direct from the Linux kernel where the man pages can be
considered the main documentation).

Note: CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE and
CLOCK_MONOTONIC_COARSE are also defined in the toplevel bits/time.h,
as used for Hurd.  Nevertheless, I see no sign that the Hurd code in
glibc actually has any support for those clocks, so I think it is
correct to document them as Linux-specific (and to refer only to the
Linux man pages for their semantics).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-05-12 14:56:07 +00:00
Joseph Myers
ae31254432 Implement C23 compoundn
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the compoundn functions, which compute (1+X) to the
power Y for integer Y (and X at least -1).  The integer 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.

Note that these functions are "compoundn" with a trailing "n", *not*
"compound" (CORE-MATH has the wrong name, for example).

As with pown, I strongly encourage searching for worst cases for ulps
error for these implementations (necessarily non-exhaustively, given
the size of the input space).  I also expect a custom implementation
for a given format could be much faster as well as more accurate (I
haven't tested or benchmarked the CORE-MATH implementation for
binary32); this is one of the more complicated and less efficient
functions to implement in a type-generic way.

As with exp2m1 and exp10m1, this showed up places where the
powerpc64le IFUNC setup is not as self-contained as one might hope (in
this case, without the changes specific to powerpc64le, there were
undefined references to __GI___expf128).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-05-09 15:17:27 +00:00
DJ Delorie
3270c50e48 manual: add more pthread functions
Add stubs and partial docs for many undocumented pthreads functions.
While neither exhaustive nor complete, gives minimal usage docs
for many functions and expands the pthreads chapters, making it
easier to continue improving this section in the future.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2025-05-05 22:42:26 -04:00
Aurelien Jarno
9df92958c1 manual/tunables: fix a trivial typo
Fixes: 12a497c716 ("elf: Extend glibc.rtld.execstack tunable to force executable stack (BZ 32653)"
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-04-14 10:24:55 -03:00
Collin Funk
363bbdbd2a manual: Mention POSIX-1.2024 requires time_t to be 64 bit or wider.
* manual/time.texi (Time Types): Mention POSIX-1.2024 requires 64 bit
time_t.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-04-14 10:10:17 -03:00
Collin Funk
93623c03d5 manual: Update standardization of getline and getdelim [BZ #32830]
* manual/stdio.texi (Line Input): Document that getline and getdelim
where GNU extensions until standardized in POSIX.1-2008.  Add restrict
to function prototypes.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-04-14 10:10:12 -03:00
Adhemerval Zanella
12a497c716 elf: Extend glibc.rtld.execstack tunable to force executable stack (BZ 32653)
From the bug report [1], multiple programs still require to dlopen
shared libraries with either missing PT_GNU_STACK or with the executable
bit set.  Although, in some cases, it seems to be a hard-craft assembly
source without the required .note.GNU-stack marking (so the static linker
is forced to set the stack executable if the ABI requires it), other
cases seem that the library uses trampolines [2].

Unfortunately, READ_IMPLIES_EXEC is not an option since on some ABIs
(x86_64), the kernel clears the bit, making it unsupported.  To avoid
reinstating the broken code that changes stack permission on dlopen
(0ca8785a28), this patch extends the glibc.rtld.execstack tunable to
allow an option to force an executable stack at the program startup.

The tunable is a security issue because it defeats the PT_GNU_STACK
hardening.  It has the slight advantage of making it explicit by the
caller, and, as for other tunables, this is disabled for setuid binaries.
A tunable also allows us to eventually remove it, but from previous
experiences, it would require some time.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=32653
[2] https://github.com/conda-forge/ctng-compiler-activation-feedstock/issues/143
Reviewed-by: Sam James <sam@gentoo.org>
2025-04-08 16:19:49 -03:00
Lenard Mollenkopf
5b132ec2b7 stdlib: Implement C2Y uabs, ulabs, ullabs and uimaxabs
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>
2025-04-08 12:51:51 +00:00
H.J. Lu
27b96e069a Raise the minimum GCC version to 12.1 [BZ #32539]
For all Linux distros with glibc 2.40 which I can find, GCC 14.2 is used
to compile glibc 2.40:

OS                    GCC      URL
AOSC                  14.2.0   https://aosc.io/
Arch Linux            14.2.0   https://archlinux.org/
ArchPOWER             14.2.0   https://archlinuxpower.org/
Artix                 14.2.0   https://artixlinux.org/
Debian                14.2.0   https://www.debian.org/
Devuan                14.2.0   https://www.devuan.org/
Exherbo               14.2.0   https://www.exherbolinux.org/
Fedora                14.2.1   https://fedoraproject.org/
Gentoo                14.2.1   https://gentoo.org/
Kali Linux            14.2.0   https://www.kali.org/
KaOS                  14.2.0   https://kaosx.us/
LiGurOS               14.2.0   https://liguros.gitlab.io/
Mageia                14.2.0   https://www.mageia.org/en/
Manjaro               14.2.0   https://manjaro.org/
NixOS                 14.2.0   https://nixos.org/
openmamba             14.2.0   https://openmamba.org/
OpenMandriva          14.2.0   https://openmandriva.org/
openSUSE              14.2.0   https://www.opensuse.org/
Parabola              14.2.0   https://www.parabola.nu/
PLD Linux             14.2.0   https://pld-linux.org/
PureOS                14.2.0   https://pureos.net/
Raspbian              14.2.0   http://raspbian.org/
Slackware             14.2.0   http://www.slackware.com/
Solus                 14.2.0   https://getsol.us/
T2 SDE                14.2.0   http://t2sde.org/
Ubuntu                14.2.0   https://www.ubuntu.com/
Wikidata              14.2.0   https://wikidata.org/

Support older versions of GCC to build glibc 2.42:

1. Need to work around bugs in older versions of GCC.
2. Can't use the new features in newer versions of GCC, which may be
required for new features, like _Float16 which requires GCC 12.1 or
above, in glibc,

The main benefit of supporting older versions of GCC is easier backport
of bug fixes to the older releases of glibc, which can be mitigated by
avoiding incompatible features in newer versions of GCC for critical bug
fixes.  Require GCC 12.1 or newer to build.  Remove GCC version check for
PowerPC and s390x.

TEST_CC and TEST_CXX can be used to test the glibc build with the older
versions of GCC.

For glibc developers who are using Linux OSes which don't come with GCC
12.1 or newer, they should build and install GCC 12.1 or newer to work
on glibc.

This fixes BZ #32539.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2025-03-31 08:04:29 -07:00
Samuel Zeter
87b5a759f4 manual: tidy the longopt.c example
- Change longopt.c's backticks to single quotes
- puts() does not use format specifiers

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-03-31 10:34:51 -03:00
Collin Funk
ee33752b5d manual: Document functions adopted by POSIX.1-2024.
Here is a patch updating the documentation to mention GNU and BSD
extensions that were adopted by POSIX.1-2024.

* manual/llio.texi (Memory-mapped I/O): Add that MAP_ANON and
MAP_ANONYMOUS were added by POSIX.1-2024.
* manual/memory.texi (Changing Block Size): Mention that reallocarray
was added by POSIX.1-2024.
* manual/message.texi (Message Translation): Adjust wording to match
standardization.
(Translation with gettext): Mention the gettext family of functions were
added by POSIX.1-2024.
* manual/pattern.texi (Wildcard Matching): Mention that FNM_CASEFOLD was
added by POSIX.1-2024.
* manual/process.texi (Creating a Process): Mention that _Fork and
WCOREDUMP were added by POSIX.1-2024.
* manual/signal.texi (Miscellaneous Signals): Mention that SIGWINCH was
added by POSIX-1.2024.
* manual/startup.texi (Environment Access): Mention that secure_getenv
was added by POSIX.1-2024.
* manual/string.texi (Truncating Strings): Mention that strlcpy,
strlcat, wcslcpy, and wslcat were added by POSIX-1.2024.
(Search Functions): Document that memmem was added by POSIX-1.2024.
* manual/terminal.texi (Allocation): Mention that ptsname_r was added by
POSIX-1.2024.
* manual/threads.texi (Waiting with Explicit Clocks): Move node under
POSIX Threads.  Mention pthread_cond_clockwait,
pthread_rwlock_clockrdlock, and pthread_rwlock_clockwrlock were added by
POSIX-1.2024.
(Joining Threads): New node under Non-POSIX Extensions.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Signed-off-by: Collin Funk <collin.funk1@gmail.com>
2025-03-31 10:34:42 -03:00
Joseph Myers
75ad83f564 Implement C23 pown
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-27 10:44:44 +00:00
Aaron Merey
e3a6e85d67 Add _FORTIFY_SOURCE support for inet_pton
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-24 14:43:03 -04:00
Frédéric Bérat
090dfa40a5 Add _FORTIFY_SOURCE support for inet_ntop
- 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-21 09:35:42 +01:00
Joseph Myers
409668f6e8 Implement C23 powr
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-14 15:58:11 +00:00