1937 Commits

Author SHA1 Message Date
Michael Jones
d2b2d6ff10
[libc] Fix missing close at the end of file test (#154392)
The test added by #150802 was missing a close at the end.
2025-08-19 10:26:05 -07:00
codefaber
fd7f69bfe7
[libc] Fix copy/paste error in file.cpp (#150802)
Fix using wrong variable due to copy/paste error.

---------

Co-authored-by: codefaber <codefaber>
2025-08-19 10:05:38 -07:00
Krishna Pandey
550dbec03a
[libc][math][c++23] Add {,u}fromfp{,x}bf16 math functions (#153992)
This PR adds the following basic math functions for BFloat16 type along
with the tests:
- fromfpbf16
- fromfpxbf16
- ufromfpbf16
- ufromfpxbf16

---------

Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-19 22:19:03 +05:30
Muhammad Bassiouni
2c79dc1082
[libc][math] Refactor coshf16 implementation to header-only in src/__support/math folder. (#153582)
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
2025-08-19 02:08:07 +03:00
Mohamed Emad
40833eea21
Reland "[libc][math][c23] Implement C23 math function asinpif16" (#152690)
#146226 with fixing asinpi MPFR number function and make it work when
mpfr < `4.2.0`
2025-08-18 00:04:47 +03:00
Mikhail R. Gadelha
d7199544af
[libc] Fix mbrtowc test (#153721)
Previously, we were trying to memset a pointer that wasn't being
initialized, and the test would randomly fail.

This PR replaces the pointers with actual objects.
2025-08-15 11:44:33 -03:00
Muhammad Bassiouni
9ddc85f6d5
[libc][math] Refactor coshf implementation to header-only in src/__support/math folder. (#153427)
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
2025-08-14 17:19:47 +03:00
Krishna Pandey
41c9510d72
[libc][math][c++23] Add bf16fma{,f,l,f128} math functions (#153231)
This PR adds the following basic math functions for BFloat16 type along
with the tests:
- bf16fma
- bf16fmaf
- bf16fmal
- bf16fmaf128

---------

Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-13 23:26:15 +05:30
Muhammad Bassiouni
0f6d3ad0fe
[libc][math] Refactor cosf16 implementation to header-only in src/__support/math folder. (#152871)
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
2025-08-13 18:04:35 +03:00
Krishna Pandey
c819c246f3
[libc][math][c++23] Add bf16div{,f,l,f128} math functions (#153191)
This PR adds the following basic math functions for BFloat16 type along
with the tests:
- bf16div
- bf16divf
- bf16divl
- bf16divf128

---------

Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-12 21:46:22 +05:30
Krishna Pandey
8c5e9399f6
[libc][math][c++23] Add f{max,min}imum{,_mag,_mag_num,_num}bf16 math functions (#152881)
This PR adds the following basic math functions for BFloat16 type along
with the tests:
- fmaximumbf16
- fmaximum_magbf16
- fmaximum_mag_numbf16
- fmaximum_numbf16
- fminimumbf16
- fminimum_magbf16
- fminimum_mag_numbf16
- fminimum_numbf16

---------

Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-12 20:37:31 +05:30
William Huynh
33fe6353ef
Revert "[libc] Add -Wextra for libc tests" (#153169)
Reverts llvm/llvm-project#133643
2025-08-12 11:40:14 +00:00
Vinay Deshmukh
e617dc80bf
[libc] Add -Wextra for libc tests (#133643)
* Relates to: https://github.com/llvm/llvm-project/issues/119281
2025-08-12 12:27:13 +01:00
Muhammad Bassiouni
200a99073f
[libc][math] Refactor cosf implementation to header-only in src/__support/math folder. (#152069)
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
2025-08-11 21:08:21 +03:00
William Huynh
0adcbc0228
[libc] Disable LlvmLibcTimespecGet.Monotonic for baremetal targets (#152290)
This test was caught by our hermetic testing downstream. The baremetal
implementation does not support monotonic, so we disable it.
2025-08-11 14:48:11 +01:00
Krishna Pandey
628c0e33e4
[libc][math][c++23] Add bf16mul{,f,l,f128} math functions (#152847)
This PR adds the following basic math functions for BFloat16 type along
with the tests:
- bf16mul
- bf16mulf
- bf16mull
- bf16mulf128

---------

Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-10 21:38:27 -04:00
Muhammad Bassiouni
e86c9b6b1b
[libc][math] Refactor cos implementation to header-only in src/__support/math folder. (#151883)
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
2025-08-09 18:51:54 +03:00
Krishna Pandey
246f92324f
[libc][math][c++23] Add f{max,min}bf16 math functions (#152782)
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-08 17:54:02 -04:00
Joseph Huber
ca006898b3
[libc] Cache old slabs when allocating GPU memory (#151866)
Summary:
This patch introduces a lock-free stack used to store a fixed number of
slabs. Instead of going directly through RPC memory, we instead can
consult the cache and use that. Currently, this means that ~64 MiB of
memory will remain in-use if the user completely fills the cache.
However, because we always fully destroy the object, the chunk size can
be reset so they can be fully reused.

This greatly improves performance in cases where the user has previously
accessed malloc, lowering the difference between an implementation that
does not free slabs at all and one that does.

We can also skip the expensive zeroing step if the old chunk size was
smaller than the previous one. Smaller chunk sizes need a larger
bitfield, and because we know for a fact that the number of users
remaining in this slab is zero thanks to the reference counting we can
guarantee that the bitfield is all zero like when it was initialized.
2025-08-08 14:28:41 -05:00
Krishna Pandey
1ffb99520d
[libc][math][c++23] Add bf16{add,sub}{,f,l,f128} math functions (#152774)
This PR adds implements following basic math functions for BFloat16 type
along with the tests:
- bf16add
- bf16addf
- bf16addl
- bf16addf128
- bf16sub
- bf16subf
- bf16subl
- bf16subf128

---------

Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-08 15:20:24 -04:00
Muhammad Bassiouni
66734f4c3c
[libc][math] Refactor cbrtf implementation to header-only in src/__support/math folder. (#151846)
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
2025-08-08 18:28:50 +03:00
Alexey Samsonov
2422972eea
[libc] Migrate FEnvSafeTest and FPTest to ErrnoCheckingTest. (#152633)
This would ensure that errno value is cleared out before test execution
and tests pass even when LIBC_ERRNO_MODE_SYSTEM_INLINE is specified (and
errno may be clobbered before test execution).

A lot of the tests would fail, however, since errno would end up getting
set to EDOM or ERANGE during test execution and never validated before
the end of the test. This should be fixed - and errno should be
explicitly checked or ignored in all of those cases, but for now add a
TODO to address it later (see open issue #135320) and clear out errno in
test fixture to avoid test failures.
2025-08-07 21:49:57 -07:00
Krishna Pandey
15a705dc93
[libc][math][c++23] Add {ceil,floor,round,roundeven,trunc}bf16 math functions (#152352)
This PR implements the following basic math functions for BFloat16 type
along with the tests:
- ceilbf16
- floorbf16
- roundbf16
- roundevenbf16
- truncbf16

---------

Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-08 00:15:22 -04:00
Uzair Nawaz
e83abd774a
[libc] Template StringConverter pop function to avoid duplicate code (#152204)
Addressed TODO to template the StringConverter pop functions to have a
single implementation (combine popUTF8 and popUTF32 into a single
templated pop function)
2025-08-06 15:46:41 -07:00
lntue
80cf436a27
[libc] Fix undefined behavior in BitsFxTest.h (#152347) 2025-08-06 15:01:28 -04:00
Michael Jones
503c0908c3
[libc] fix iswalpha signiture and test (#152343)
The iswalpha function is only working for characters in the ascii range
right now, which isn't ideal. Also it was returning a bool when the
function is supposed to return an int.
2025-08-06 11:05:08 -07:00
Schrodinger ZHU Yifan
df0325a3e5
[libc] add getrandom vDSO symbol (#151630) 2025-08-06 10:55:41 -04:00
Krishna Pandey
a4ff76e819
[libc][math][c++23] Implement basic arithmetic operations for BFloat16 (#151228)
This PR implements addition, subtraction, multiplication and division
operations for BFloat16.

---------

Signed-off-by: krishna2803 <kpandey81930@gmail.com>
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
Co-authored-by: OverMighty <its.overmighty@gmail.com>
2025-08-06 10:42:55 -04:00
Joseph Huber
79253cfe6b
[libc] Fix integration tests on w64 amdgpu targets (#152303)
Summary:
We need `malloc` to return a larger size now that it's aligned properly
and we use a bunch of threads. Also the `match_any` test was wrong
because it assumed a 32-bit lanemask.
2025-08-06 08:36:06 -05:00
Schrodinger ZHU Yifan
e797c71609
Reland "[libc] make integration test malloc work properly when threaded" (#152236)
Reverts llvm/llvm-project#152096
2025-08-05 23:12:19 -04:00
Krishna Pandey
52b7b22cfa
[libc][math] Fix division by infinity in fputil::div (#152092)
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-05 07:39:03 -04:00
Jan Patrick Lehr
6393a9edde
Revert "[libc] make integration test malloc work properly when threaded" (#152096)
Reverts llvm/llvm-project#151622

This broke our libc on GPU bot:
https://lab.llvm.org/buildbot/#/builders/10/builds/10864
2025-08-05 09:26:59 +02:00
Schrodinger ZHU Yifan
8eab158396
[libc] make integration test malloc work properly when threaded (#151622)
Make the simple bump allocation backed by atomic operations.
2025-08-04 23:49:51 -04:00
Krishna Pandey
771d9ab701
[libc][math] Fix subtraction of infinity in fputil::add_or_sub (#152017)
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-04 18:15:40 -04:00
Muhammad Bassiouni
003f6ada15
[libc][math] Refactor cbrt implementation to header-only in src/__support/math folder. (#151837)
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
2025-08-03 21:02:53 +03:00
Muhammad Bassiouni
bb3cd6221b
[libc][math] Refactor atanhf16 implementation to header-only in src/__support/math folder. (#151779)
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
2025-08-02 23:04:02 +03:00
Muhammad Bassiouni
99cd1d8aef
[libc][math] Refactor atanhf implementation to header-only in src/__support/math folder. (#151399)
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
2025-08-02 02:54:13 +03:00
Muhammad Bassiouni
920079b793
[libc][math] Refactor atan2f128 implementation to header-only in src/__support/math folder. (#151012)
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
2025-08-02 00:18:57 +03:00
Aiden Grossman
605f652cba
[libc] Add struct_sched_param proxy header (#151722)
This enables cleaning up the remaining sched.h includes littered around
the code base.
2025-08-01 11:34:06 -07:00
enh-google
b36f05ce48
[libc] Fix wcstok() "subsequent searches" behavior. (#151589)
POSIX says "If no such wide-character code is found, the current token
extends to the end of the wide-character string pointed to by ws1, and
subsequent searches for a token shall return a null pointer", but the
current implementation only returns nullptr the first time. This failed
an existing bionic test when I tried to switch over to llvm-libc
wcstok().
2025-08-01 14:15:34 -04:00
Muhammad Bassiouni
9af2c21be4
[libc][math] Refactor atan2f implementation to header-only in src/__support/math folder. (#150993)
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
2025-08-01 16:06:09 +03:00
Aiden Grossman
5906ff67ae
[libc] Remove some sched.h includes (#151425)
This patch removes some sched.h includes, preferring the proxy headers.
This patch does not clean them all up as some proxy type headers need to
be added, like for `struct sched_param`.
2025-07-30 18:20:55 -07:00
Muhammad Bassiouni
c8b6ddf3a3
[libc][math] Refactor atan2 implementation to header-only in src/__support/math folder. (#150968)
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
2025-07-31 01:07:55 +03:00
Muhammad Bassiouni
729b0d1b61
[libc][math] Refactor atanf16 implementation to header-only in src/__support/math folder. (#150868)
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
2025-07-30 23:31:07 +03:00
Aiden Grossman
fc5976118d
[libc] Add implementation of getcpu syscall wrapper (#150871)
This patch adds the getcpu syscall wrapper. This has been supported in
glibc since v2.29.
2025-07-30 09:45:19 -07:00
Muhammad Bassiouni
f2a476d79a
[libc][math] Refactor atanf implementation to header-only in src/__support/math folder. (#150854)
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
2025-07-30 07:24:49 +03:00
Krishna Pandey
616cef0883
[libc][math] Make BFloat16 comparison tests constexpr (#151211)
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-07-29 16:51:57 -04:00
Muhammad Bassiouni
551dcc3e82
[libc][math] Refactor atan implementation to header-only in src/__support/math folder. (#150852)
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
2025-07-29 21:16:57 +03:00
Muhammad Bassiouni
efbbc0b319
[libc][math] Refactor asinhf16 implementation to header-only in src/__support/math folder. (#150849)
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
2025-07-29 20:19:01 +03:00
Uzair Nawaz
a1aba84c2b
[libc] Reland #148948 "Implement barriers for pthreads" (#151021)
Fixed build dependencies for pthread_barrier_t (add __barrier_type to
cmake dependencies)
2025-07-29 16:39:40 +00:00