5094 Commits

Author SHA1 Message Date
Zorojuro
aa62224a73
[libc][math] Refactor sqrtbf16 function header-only (#187849) 2026-03-22 00:51:40 +02:00
Muhammad Bassiouni
eea589f951
[libc][math] Qualify log with constant evaluation support (#184745)
Lay the ground for C++26 `constexpr` math functions:
- Introduce `LIBC_ENABLE_CONSTEXPR` macro switch to specify the desire
of `constexpr`-only code route.
- Introduce `LIBC_HAS_CONSTANT_EVALUATION` to indicate that we are using
`constexpr`-only code in all dependent functions.
- Introduce `LIBC_CONSTEXPR` macro qualifier to aid in altering the
signature of non-`constexpr` functions.

Note that non-`constexpr` qualified functions are caused by the
exploitation of non-`constexpr` compatible utils, resulting in
non-qualified dependent function, but it can be modified to be qualified
using other code routes.

If the function is `constexpr` compatible, then it's prohibited to use
`LIBC_CONSTEXPR` as a function qualifier. We only qualify it with
`constexpr` as usual.

`LIBC_CONSTEXPR` may or may not evaluate to `constexpr` depending on the
environment configurations, thus it's only used to modify the function
signature in constant evaluation context and remove the qualifier if
it's not desired (depending on provided configurations).

Possible side effects:
- Current qualified routes may or may not produce the desired ULP, this
is implementation dependent (function by function basis) and needs
further testing of the chosen code route.
- The shared tests in the current configuration can still compile with
unsupported compiler. I didn't want to raise compilation error with
unsupported compilers now, but we need to push compiler support with
newer versions for this one to work as intended.
2026-03-21 23:55:05 +02:00
Zorojuro
7d7cd745af
[libc][math][c23] Add atanbf16 function (#184019)
This PR intends to add atanbf16 higher math function for BFloat16 type
along with the tests.
2026-03-21 11:09:11 -04:00
Jeff Bailey
2b47497f6e
[libc][docs][NFC] Restructure Getting Started guide and update Build Concepts. (#187701)
Restructured the Getting Started guide into a numbered step-by-step path
for easier readability. Added a Hello World verification step to confirm
build integrity after build completion.

Additionally, updated build_concepts.rst and the Getting Started guide
to clarify that Overlay Mode is intended for augmenting the system's C
library rather than incremental adoption.
2026-03-21 00:56:38 +00:00
Alexey Samsonov
a60b3a83cf
[libc] Fix function prototypes for <threads.h> C11 header. (#187808)
Fix return types and/or function arguments of several functions:
* mtx_destroy
* tss_delete
* thrd_exit
2026-03-20 16:17:29 -07:00
Muhammad Bassiouni
a2615482d1
[libc][annex_k] Add constraint_handler_t. (#163239)
RFC https://discourse.llvm.org/t/rfc-bounds-checking-interfaces-for-llvm-libc/87685

Add `constraint_handler_t` type required by Annex K interface in LLVM libc.
2026-03-21 00:19:21 +02:00
Ilya Tokar
bb369f1c30
[libc][x86] Add Non-temporal code path for large memcpy (#187108)
Large memcopies are pretty rare, but are more common in ML workloads
(copying large matrixes/tensors, often to/from CPU host).

For large copies NTA stores can provide performance advantages for both
memcpy itself and the rest of the workload (by reducing cache
pollution). Other runtimes already have NTA path for large copies, so
add 1 to the llvm-libc.

Internal whole-program loadtests shows small, but statistically
significant improvement of 0.1%. ML specific bencahmrks showed 10-20%
performance gain, and fleetbench (https://github.com/google/fleetbench,
which has more up-to-date version of libc benchmarks) shows ~3% gain
(ns/byte for distributions taken from various applications).

```
[Memcpy_0]_L1      0.01950n ± 3%   0.01900n ± 5%       ~ (p=0.390 n=20)
[Memcpy_0]_L2      0.02300n ± 0%   0.02300n ± 0%       ~ (p=0.256 n=20)
[Memcpy_0]_LLC     0.1335n ± 1%    0.1310n ± 1%   -1.87% (p=0.000 n=20)
[Memcpy_0]_Cold    0.1540n ± 2%    0.1520n ± 1%   -1.30% (p=0.021 n=20)
[Memcpy_1]_L1      0.04300n ± 5%   0.04200n ± 2%  -2.33% (p=0.000 n=20)
[Memcpy_1]_L2      0.05000n ± 2%   0.04800n ± 0%  -4.00% (p=0.000 n=20)
[Memcpy_1]_LLC     0.2500n ± 2%    0.2390n ± 1%   -4.40% (p=0.000 n=20)
[Memcpy_1]_Cold    0.2750n ± 1%    0.2640n ± 1%   -4.00% (p=0.000 n=20)
[Memcpy_2]_L1      0.03800n ± 3%   0.03800n ± 3%       ~ (p=0.420 n=20)
[Memcpy_2]_L2      0.04400n ± 2%   0.04300n ± 0%  -2.27% (p=0.000 n=20)
[Memcpy_2]_LLC     0.2320n ± 1%    0.2220n ± 1%   -4.31% (p=0.000 n=20)
[Memcpy_2]_Cold    0.2565n ± 1%    0.2460n ± 1%   -4.09% (p=0.000 n=20)
[Memcpy_3]_L1      0.1380n ± 1%    0.1355n ± 2%        ~ (p=0.095 n=20)
[Memcpy_3]_L2      0.1490n ± 1%    0.1430n ± 1%   -4.03% (p=0.000 n=20)
[Memcpy_3]_LLC     0.7955n ± 1%    0.7450n ± 0%   -6.35% (p=0.000 n=20)
[Memcpy_3]_Cold    0.8495n ± 1%    0.7935n ± 0%   -6.59% (p=0.000 n=20)
[Memcpy_4]_L1      0.04000n ± 3%   0.03900n ± 3%       ~ (p=0.466 n=20)
[Memcpy_4]_L2      0.04500n ± 2%   0.04400n ± 2%       ~ (p=0.130 n=20)
[Memcpy_4]_LLC     0.2040n ± 1%    0.1950n ± 1%   -4.41% (p=0.000 n=20)
[Memcpy_4]_Cold    0.2240n ± 1%    0.2150n ± 1%   -4.02% (p=0.000 n=20)
[Memcpy_5]_L1      0.05800n ± 3%   0.06050n ± 1%  +4.31% (p=0.000 n=20)
[Memcpy_5]_L2      0.06400n ± 0%   0.06400n ± 2%   0.00% (p=0.004 n=20)
[Memcpy_5]_LLC     0.3320n ± 1%    0.3140n ± 1%   -5.42% (p=0.000 n=20)
[Memcpy_5]_Cold    0.3620n ± 1%    0.3430n ± 0%   -5.25% (p=0.000 n=20)
[Memcpy_6]_L1      0.05700n ± 2%   0.05750n ± 3%       ~ (p=0.403 n=20)
[Memcpy_6]_L2      0.06500n ± 0%   0.06250n ± 1%  -3.85% (p=0.000 n=20)
[Memcpy_6]_LLC     0.3410n ± 1%    0.3205n ± 1%   -6.01% (p=0.000 n=20)
[Memcpy_6]_Cold    0.3670n ± 1%    0.3470n ± 1%   -5.45% (p=0.000 n=20)
[Memcpy_7]_L1      0.05900n ± 2%   0.05900n ± 2%       ~ (p=0.296 n=20)
[Memcpy_7]_L2      0.06400n ± 2%   0.06400n ± 0%       ~ (p=0.327 n=20)
[Memcpy_7]_LLC     0.3145n ± 1%    0.2965n ± 1%   -5.72% (p=0.000 n=20)
[Memcpy_7]_Cold    0.3410n ± 1%    0.3220n ± 0%   -5.57% (p=0.000 n=20)
[Memcpy_8]_L1      0.03600n ± 3%   0.03600n ± 3%       ~ (p=0.804 n=20)
[Memcpy_8]_L2      0.04200n ± 0%   0.04100n ± 2%  -2.38% (p=0.000 n=20)
[Memcpy_8]_LLC     0.2210n ± 1%    0.2090n ± 1%   -5.43% (p=0.000 n=20)
[Memcpy_8]_Cold    0.2415n ± 1%    0.2300n ± 1%   -4.76% (p=0.000 n=20)
geomean            0.1184n         0.1148n        -3.03%
```
2026-03-20 15:36:08 -04:00
Jeff Bailey
2600c723e1
[libc][NFC] Fix typo in file.cpp (#91192) (#187688)
Corrected language and spelling errors in a comment within file.cpp.

Credit GH user @iBlanket for identifying this typo.
2026-03-20 12:27:28 +00:00
Jeff Bailey
df85f45bf1
[libc][docs][NFC] Add Build Concepts and consolidate patterns (#187490)
[libc][docs][NFC] Add Build Concepts page with five build scenarios

Added build_concepts.rst defining the five ways to build LLVM-libc:

overlay, full build, bootstrap, cross-compiler, and bootstrap
cross-compiler. Updated full_host_build.rst to cross-reference the new
concepts page for both the runtimes and bootstrap build sections, and
removed a duplicate GWP_ASAN flag from the sysroot CMake recipe. Added
the new page to index.rst.
2026-03-19 23:41:29 +00:00
Daniel Thornburgh
7efcd6198c
[libc] Modular printf option (float only) (#147426)
This adds LIBC_CONF_PRINTF_MODULAR, which causes floating point support
(later, others) to be weakly linked into the implementation.
__printf_modular becomes the main entry point of the implementaiton, an
printf itself wraps __printf_modular. printf it also contains a
BFD_RELOC_NONE relocation to bring in the float aspect.

See issue #146159 for context.
2026-03-19 14:22:03 -07:00
lntue
2632ffeab1
[libc][stdio] Fix standard streams in overlay mode. (#187522)
https://github.com/llvm/llvm-project/pull/184669 changed the behavior of
standard streams in overlay mode, bringing in some symbols that are only
available in full build mode.
2026-03-19 15:42:12 -04:00
neonetizen
adbb122717
[libc] Implement iswprint entrypoint (#185251)
Implemented the iswprint entrypoint and tests for issue #185136
2026-03-19 12:36:56 -07:00
Pengxiang Huang
bed9fa2de5
[libc][sys/sem] Add sys v sem headers and syscall wrapper implementation (#185914)
Fix #182161
Based on the last PR #182700 implementing sys/ipc.
2026-03-19 10:12:06 -04:00
Mohamed Emad
4db2ce4d54
[libc][math] Refactor dadd family to header-only (#182142)
Closes https://github.com/llvm/llvm-project/issues/182141
2026-03-19 06:37:35 +02:00
Muhammad Bassiouni
80034dd582
[libc][annex_k] Add rsize_t (#163238)
RFC
https://discourse.llvm.org/t/rfc-bounds-checking-interfaces-for-llvm-libc/87685

Add `rsize_t` type required by Annex K interface in LLVM libc.
2026-03-19 01:59:30 +02:00
Manthan Singla
42b75ed85f
[libc][math] Refactor bf16divf128 to Header Only (#186641)
closes #181024
2026-03-19 01:47:22 +02:00
Muhammad Bassiouni
8e06210559
[libc][annex_k] Add errno_t (#163094)
RFC
https://discourse.llvm.org/t/rfc-bounds-checking-interfaces-for-llvm-libc/87685

Add `errno_t` type required by Annex K interface in LLVM libc.
2026-03-18 23:58:27 +02:00
Jeff Bailey
89657f726f
[libc][docs][NFC] Documentation consolidation and de-duplication (#187385)
Summary:
Integrated a series of quick documentation cleanups for LLVM-libc. This
update focuses on de-duplicating core conventions (naming and
namespaces) across multiple developer and contribution guides, and
addresses empty platform stubs for UEFI.

Changes:

* libc/docs/contributing.rst: Removed duplicated code style rules and
provided a link to dev/code_style.rst.
* libc/docs/dev/clang_tidy_checks.rst: Removed redundant namespace
explanations and linked to dev/code_style.rst.
* libc/docs/dev/implementation_standard.rst: Removed repetitive notes
about LIBC_NAMESPACE_DECL and linked to the authoritative reference.
* libc/docs/uefi/support.rst & libc/docs/uefi/using.rst: Added
early-stage bring-up warnings and pointed to the config directory for
the source of truth.
2026-03-18 21:50:08 +00:00
Jeff Bailey
253616de7e
[libc][docs] Generate configure.rst in the build directory (#187266)
generate_config_doc() was writing configure.rst directly into the source
tree, which fails when building from a read-only source directory (e.g.
when the source is on a read-only filesystem or in a packaging
environment).

The Sphinx build in libc/docs/CMakeLists.txt already copies static .rst
files from the source tree into the build tree so that generated docs
don't pollute the source directory. Move configure.rst generation to
follow this same pattern by writing to LIBC_BUILD_DIR/docs/ instead of
LIBC_SOURCE_DIR/docs/.

This also removes configure.rst from the checked-in source tree, since
it was fully generated content that was being regenerated on every CMake
configure anyway.
2026-03-18 16:51:13 +00:00
Anonmiraj
c0064f744c
[libc][math] Fix missing underflow exception in DyadicFloat::generic_as (#186734)
The `generic_as` function in `dyadic_float.h` had a missing `underflow =
true` at the exact boundary where `unbiased_exp == -EXP_BIAS -
FRACTION_LEN`.
At this boundary, the mantissa MSB maps exactly to the round bit, so
out_mantissa is 0 and the result can only be 0 or min_subnormal. The
value is at most min_subnormal / 2, so it is always tiny and always
inexact `underflow` must be signaled. The < case and the general
subnormal range both already set underflow = true this boundary case was
the only gap.

this specifically fix this error in the erfcf16 function 
```
Extracted erfcf16.cpp.o from archive for linking
Running exhaustive check in --rndn mode...
Missing underflow exception for x=0x1.eacp+1 (y=0x1p-24)
```

this fix may also apply to other bfloat16 missing exceptions
(@Sukumarsawant)

part of: #186483 

CC: @lntue
2026-03-18 10:02:36 -04:00
lntue
1db8096555
[libc][math] Improve hypotf performance. (#186627)
Update the check for when a more careful rounding is needed, and remove
the redundant clear exception step.
2026-03-18 09:34:54 -04:00
Michael Jones
838b1ccdd9
[libc] Add a smaller b36_char_to_int (#180841)
For ASCII systems, b36_char_to_int gets compiled into a jump table. That
jump table ends up being pretty large because it covers the range from
'0' (48) to 'z' (122). On size-constrained systems that can assume
ASCII, this patch provides a new flag: LIBC_CONF_CTYPE_SMALLER_ASCII
that forces a smaller implementation that doesn't compile into a jump
table.
2026-03-17 15:36:41 -07:00
kubikusik
6b2e347ae1
[libc]: implement 'iswpunct' entrypoint (#186968)
Added entrypoints:
- baremetal/arm
- baremetal/aarch64
- baremetal/riscv
- darwin/aarch64
- linux/aarch64
- linux/arm
- linux/riscv
- linux/x86_64
- windows

Also added the unit test for iswpunct.

Part of the issue: #185136
2026-03-17 12:53:03 -07:00
Muhammad Bassiouni
bed5e7dc20
[libc][math] Refactor fmaf16 implementation to header-only in src/__support/math folder. (#163977) 2026-03-17 21:35:08 +02:00
Muhammad Bassiouni
e6f0ec8343
[libc][math] Refactor fmaf implementation to header-only in src/__support/math folder. (#163970)
Part of #147386

in preparation for:
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2026-03-17 21:33:06 +02:00
Muhammad Bassiouni
d0d1f0b7af
[libc][math] Refactor fma implementation to header-only in src/__support/math folder. (#163968)
Part of #147386

in preparation for:
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2026-03-17 21:24:27 +02:00
Jeff Bailey
ebb3309975
[libc] Refactor core Linux syscalls to use syscall_wrappers (#185983)
This patch initiates the refactoring of Linux syscalls as described in
the RFC (https://discourse.llvm.org/t/rfc-linux-syscall-cleanup/87248/).

It introduces a new infrastructure in
`src/__support/OSUtil/linux/syscall_wrappers/` to house header-only
syscall wrappers. These wrappers utilize `ErrorOr` to provide a
consistent, type-safe interface for error handling across the library,
standardizing how syscall return values are converted into
errno-compatible Error objects.

Summary of changes:
- Created the `syscall_wrappers` directory and added `close.h`,
`read.h`, `write.h`, and `open.h`.
- Moved the existing `getrandom.h` into the new `syscall_wrappers`
directory and updated its callers (including HashTable/randomness.h).
- Refactored core entrypoints (`close`, `read`, `write`, `open`) to use
the new wrappers, removing direct `syscall_impl` logic and manual errno
setting.
- Updated `shm_open.cpp` to use the new `open` wrapper.
- Cleaned up `OSUtil/linux/fcntl.cpp` by removing redundant internal
implementations of `open` and `close`.
- Added a developer guide in `docs/dev/syscall_wrapper_refactor.rst`
outlining the established pattern for future migrations.

---------

Co-authored-by: Michael Jones <michaelrj@google.com>
2026-03-17 18:27:32 +00:00
Alexey Samsonov
4b9693a423
Revert "[libc] Avoid host header collisions in full builds (-nostdinc)" (#187079)
Reverts llvm/llvm-project#187025

Fails on openmp bot:
https://lab.llvm.org/buildbot/#/builders/10/builds/24743
('INT64_MIN' macro redefined when used Clang-provided <stdint.h> is
used)
fails on RISC-V-32 bot:
https://lab.llvm.org/buildbot/#/builders/196/builds/17067
due to MPFRNumber constructor not picking the right overload for
uint32_t argument.
2026-03-17 11:25:53 -07:00
Jeff Bailey
bed77a1d9b
[libc] Avoid host header collisions in full builds (-nostdinc) (#187025)
When building the full library with -nostdinc, directly including
<stdint.h> may pull in host or compiler-provided headers that collide
with LLVM-libc's local macro definitions. Switch to using our internal
stdint-macros.h when LIBC_FULL_BUILD is enabled.

Additionally, declare aligned_alloc with noexcept in C++ to match common
C library declarations and avoid fatal type specification mismatches
during sysroot builds.
2026-03-17 16:12:05 +00:00
Jeff Bailey
c91a9b8d10
[libc] Add Jeff Bailey to Maintainers.rst (#186662)
Add Jeff Bailey as a maintainer for General Maintenance and
Documentation. Jeff has been contributing to LLVM-libc since January
2022. This addition was discussed at the most recent LLVM-libc meeting
with no objections raised.
2026-03-17 15:08:25 +00:00
Petter Berntsson
7887ac6e7f
[libc][docs] Update clang-tidy checks page (#185923)
Document layered .clang-tidy config, update llvmlibc-* check names, and
drop stale TODO
2026-03-17 09:07:38 +00:00
Muhammad Bassiouni
b955eb72bd
[libc] Add myself as maintainer for Math, Threading and Runtime Safety (#186595) 2026-03-16 20:39:48 +02:00
Zorojuro
0a3384b969
[libc][math] Refactor log_bf16 to Header (#186618) 2026-03-16 17:13:19 +00:00
Anirudh Mathur
6e224cede2
[libc][math] Refactor bf16fma to Header Only (#182572)
Fixes #181625
2026-03-16 17:05:54 +00:00
Abhijeet
cf979d5a96
[libc][math] Refactored atanpif16 to header only (#184316)
Fixes #178105
2026-03-16 18:57:29 +02:00
Victor Campos
6c2b155f4f
[libc] Fix build failures in fuzzing tests (#185017)
The tests:
 - __support/freelist_heap_fuzz.cpp
 - fuzzing/string/strlen_fuzz.cpp

had build failures for different reasons. This patch fixes these
failures.

freelist_heap_fuzz.cpp had this error:

```
llvm-project/libc/fuzzing/__support/freelist_heap_fuzz.cpp:150:26: error: use of undeclared identifier 'Block'; did you mean '__llvm_libc_23_0_0_git::Block'?
  150 |       size_t alignment = Block::MIN_ALIGN;
      |                          ^~~~~
      |                          __llvm_libc_23_0_0_git::Block
```

The issue stems from the fact that Block was not available in scope. It
needs to be referenced via LIBC_NAMESPACE.

strlen_fuzz.cpp had this error:

```
In file included from Workspace/llvm-project/libc/fuzzing/string/strlen_fuzz.cpp:14:
In file included from /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/cstdint:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/x86_64-linux-gnu/c++/13/bits/c++config.h:679:
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/x86_64-linux-gnu/c++/13/bits/os_defines.h:44:5: error: function-like macro '__GLIBC_PREREQ' is not defined
   44 | #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE)

```

This issue is more cryptic to me, but I managed to fix it by changing
the includes from cstdint and cstring to stdint.h and string.h.
2026-03-16 11:14:57 +00:00
Joseph Huber
5e6a6d7445 [libc] Reference the proper namespaced variables in the GPU header
Summary:
These linked to the extern "C" versions which did not exist in test
builds.
2026-03-13 18:28:17 -05:00
Shubh Pachchigar
b7c4615e13
[libc] Support ls in printf (#178841)
Add support for %ls in printf by calling internal string converter and
add relevant end-to-end sprintf test. Additionally, modified printf
parser for recognizing length modifier. This also disables wide string
support on windows
and other unsupported platforms.

Co-authored-by: shubhe25p <shubhp@mbm3a24.local>
2026-03-13 14:57:54 -07:00
Xinlong Chen
458096d5f8
[libc][math][c23] Add atan2f16 function (#183531)
Add atan2f16 function

closes https://github.com/llvm/llvm-project/issues/180969
Part of https://github.com/llvm/llvm-project/issues/95250.

also refactor to header only, it's a part of
https://github.com/llvm/llvm-project/issues/147386
2026-03-13 22:12:44 +02:00
sid
bc108761e9
[libc][math] Refactor bf16div to be header-only (#181400)
Closes #181022
Part of #147386
2026-03-13 20:08:00 +00:00
Chinmay Ingle
4fdf089073
[libc][math] Move hypot to shared/math and make it constexpr (#177588)
Closes #175339
2026-03-13 19:57:05 +00:00
Petr Hosek
1bebb02109
[libc] Fix GPU stderr include path (#186481)
This issue was accidentally introduced in #184669.
2026-03-13 11:25:56 -07:00
Petr Hosek
04fea76f78
[libc] Make standard streams entrypoints (#184669)
The standard streams should be defined the same as other public symbols,
even though they're variables rather than functions: we should have
public and private symbol which are aliases, and all internal uses
should use the private symbol to avoid GOT relocations.

This change introduces a new macro `LLVM_LIBC_VARIABLE` which is the
equivalent of `LLVM_LIBC_FUNCTION` and it refactors the existing
definitions of standard streams for BareMetal, Linux and GPU to use this
macro.
2026-03-13 11:05:30 -07:00
Zorojuro
63c219b8a8
[libc][math] Fixed Hypotbf16 build failure. (#186415)
Ref from the build failure in hypotbf16
```CPP
project/libc/src/__support/math/hypotbf16.h:22:33:   required from here
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/FPUtil/Hypot.h:221:44: error: conversion from ‘int’ to ‘StorageType’ {aka ‘short unsigned int’} may change value [-Werror=conversion]
  221 |     r = static_cast<StorageType>((r << 1)) +
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
  222 |         ((tail_bits & current_bit) ? 1 : 0);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
cc1plus: all warnings being treated as errors
```

This PR intends to fix that by adding static_cast
2026-03-13 12:10:31 -04:00
csxplorer
c5e305c66b
[libc] Implement entrypoint and test of iswupper function (#185215)
Implement entrypoint and test of iswupper function (#185136)
2026-03-13 07:23:06 -07:00
Anonmiraj
785581213c
[libc][math] Implement C23 half precision erf function (#179251)
The implementation reuses the approach in `erff`


Closes #133112
2026-03-13 10:16:59 -04:00
Zorojuro
ad054822eb
[libc][math][c23] Add hypotbf16 function (#183460)
This PR intends to add hypotbf16 higher math function for BFloat16 type
along with the tests.
2026-03-13 10:11:33 -04:00
Mikhail R. Gadelha
c7655664a2
[libc] Add support for chown on platforms that don't define SYS_chown (#186167)
Some platforms don't define SYS_chown (like risc-v), so this PR adds a
fallback to calling SYS_fchownat.
2026-03-13 11:04:37 -03:00
Shikhar Soni
a7d1a87b30
[libc][math][c23] Add log10p1f16 C23 math function (#184739)
Closes #133202

---------

Signed-off-by: Shikhar Soni <shikharish05@gmail.com>
2026-03-13 09:59:26 -04:00
Simon Tatham
317972681c
[libc] Fix load_aligned big-endian handling. (#185937)
The variadic template helper `load_aligned` performs a specific case of
an unaligned integer load, by loading a sequence of integers from memory
at addresses expected to be aligned, and glues the results back together
with shifts and ORs into an output.

The implementation works by performing the first load, recursing on a
shorter parameter type list for the rest, and recombining via

  first | (rest << size_of_first)           // if little-endian
  (first << size_of_first) | rest           // if big-endian

But the big-endian case is wrong: it should shift left by the size of
the _rest_ of the types, not the size of the first. In the case where
you load 8, 16 and 8 bits from an odd address, you want

  (first_byte << 24) | (middle_halfword << 8) | (last_byte)

but in fact we were calculating

  (first_byte << 8) | (middle_halfword << 16) | (last_byte)

leading to three out of every four bytes being permuted in a memcpy from
an odd to an even address.
2026-03-13 08:59:55 +00:00