Amy Huang
ca38027c03
Revert "Turn LIBC_COPT_STRING_UNSAFE_WIDE_READ on by default" ( #144167 )
...
Reverts llvm/llvm-project#144163 because for some reason I didn't
realize there are ASan tests.
2025-06-13 15:30:28 -07:00
Amy Huang
a591bd222b
Turn LIBC_COPT_STRING_UNSAFE_WIDE_READ on by default ( #144163 )
...
Configure strlen to use unsafe implementation because it is faster.
Because this is undefined behavior it could cause sanitizers to fail.
2025-06-13 15:09:57 -07:00
William Huynh
473dea9b0b
[libc] Output all headers with LIBC_CONF_OUTPUT_ALL_HEADERS ( #144114 )
...
Following discussion from
https://discourse.llvm.org/t/missing-declarations-in-header-files/86678 ,
we decided to add a flag to output all headers. Requires #144049 .
- Allows outputting all headers
- Minor whitespace change for alignment
---------
Co-authored-by: Michael Jones <michaelrj@google.com >
2025-06-13 14:37:25 -07:00
Amy Huang
c42912b8c9
Fix string_length function so that it always returns. ( #144148 )
...
Previously setting LIBC_COPT_STRING_UNSAFE_WIDE_READ would cause a build
error because there is a path in the ifdef that doesn't return anything.
2025-06-13 13:07:39 -07:00
Michael Jones
452276ecc0
[libc] Fix missing errno include in fuzzer ( #144132 )
...
The printf parser uses errno for setting up the %m conversion. It was
presumably getting this include indirectly until a recent change. This
patch adds a direct dependency to fix it.
2025-06-13 11:00:08 -07:00
Alexey Samsonov
92a116c4ef
Revert "Fix/reapply "[libc] Migrate stdio tests to ErrnoCheckingTest."" ( #144129 )
...
Reverts llvm/llvm-project#143972 - matcher seems to be pedantic for
fgets tests, reverting to verify and fix.
2025-06-13 10:48:34 -07:00
Michael Jones
51689c9df2
[libc][NFC] clean internal fd handling ( #143991 )
...
The previous internal fcntl implementation modified errno directly, this
patch fixes that. This patch also moves open and close into OSUtil since
they are used in multiple places. There are more places that need
similar cleanup but only got comments in this patch to keep it
relatively reviewable.
Related to: https://github.com/llvm/llvm-project/issues/143937
2025-06-13 10:31:47 -07:00
William Huynh
fd432151a6
[libc] Fix bugs found when testing with all headers ( #144049 )
...
Fixes a couple of bugs found when building. The PR to enable the headers
can be found here: #144114 .
- math.yaml: float128 guard
- wchar.yaml: __restrict keyword order
2025-06-13 10:26:40 -07:00
Alexey Samsonov
c609112a53
Fix/reapply "[libc] Migrate stdio tests to ErrnoCheckingTest." ( #143972 )
...
This reverts commit a93e55e57e and fixes
build and test failures:
* Proper include added to setvbuf_test.cpp
* fgetc/fgetc_unlocked/fgets tests are ported to ErrnoSetterMatcher and
are made more precise. This fixes inconsistencies between expectations
in regular and GPU builds - ErrnoSetterMatcher is configured to omit
errno matching on GPUs, as fgetc implementation on GPU doesn't set
errno, in contrast to Linux.
2025-06-13 10:25:26 -07:00
Uzair Nawaz
b184672ec7
[libc] Implemented wmemmove ( #142245 )
...
Implemented wmemmove and added tests
2025-06-13 16:48:24 +00:00
Michael Jones
70f44ec6fe
[libc][NFC] Accept doc fix ( #143996 )
...
Docgen updates the docs when the config options are changed. This update
has been waiting since https://github.com/llvm/llvm-project/pull/143187 .
2025-06-12 16:49:25 -07:00
Michael Jones
28c14d475f
[libc] Independent strcat/strncat/stpcpy ( #142643 )
...
The previous implementations called other entrypoints. This patch fixes
strcat, strncat, and stpcpy to be properly independent.
2025-06-12 15:57:58 -07:00
Uzair Nawaz
2ee8fdbfdd
[libc] Prevent building wchar on MacOS ( #143978 )
...
Prevent building wchar on macos as it depends on uchar.h which isn't
available
2025-06-12 22:14:28 +00:00
sribee8
f94950db89
[libc] Changed mbstate struct ( #143942 )
...
Changed the mbstate variable from bits processed to bytes processed and
implemented isComplete().
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-12 18:04:26 +00:00
Michael Jones
5a6a4b6ba6
[libc] Implement perror ( #143624 )
...
The perror function writes an error message directly to stderr. This
patch adds an implementation, tests, and header generation details.
2025-06-12 10:45:47 -07:00
Uzair Nawaz
6311f039b2
[libc] Build fixes for widechar characterconverter ( #143805 )
...
Build fixes for wchar CharacterConverter class
2025-06-12 17:34:45 +00:00
lntue
d1ca8d891f
[libc][math] Refactor expf implementation to header-only in src/__support/math folder. ( #143790 )
...
This is a step 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-06-12 13:18:30 -04:00
lntue
82f19674bf
[libc] Update size_t and ssize_t definitions to use __SIZE_TYPE__ and __PTRDIFF_TYPE__ respectively. ( #143921 )
...
The current definition of `ssize_t` does not have the same bit width as
`size_t` on 32-bit platforms.
2025-06-12 13:11:42 -04:00
Michael Jones
ae7ea6e3a2
[libc] Fix ioctl errno inclusion ( #143928 )
...
Since errno was moved in
https://github.com/llvm/llvm-project/pull/143187 the code including it
in https://github.com/llvm/llvm-project/pull/141393 was rendered
incorrect. This patch fixes the include and the cmake depends.
2025-06-12 09:38:43 -07:00
W. Turner Abney
4039fdb7ba
[libc] add ioctl ( #141393 )
...
Closes #85275
Closes #90317
Updates #97191
---------
Co-authored-by: Joseph Huber <huberjn@outlook.com >
Co-authored-by: Michael Jones <michaelrj@google.com >
2025-06-12 09:20:32 -07:00
Alexey Samsonov
a93e55e57e
Revert "[libc] Migrate stdio tests to ErrnoCheckingTest." ( #143829 )
...
Reverts llvm/llvm-project#143802 . Follow-up fix
3c7af175e5 wasn't robust enough and itself
got reverted.
2025-06-11 21:33:46 -07:00
Kewen12
a71210e5ab
Revert "[libc] Fix stdio tests after #143802 " ( #143824 )
...
Reverts llvm/llvm-project#143810
This PR breaks our buildbot:
https://lab.llvm.org/buildbot/#/builders/10/builds/7159 revert to
unblock downstream merge.
2025-06-11 23:24:56 -04:00
Michael Jones
3c7af175e5
[libc] Fix stdio tests after #143802 ( #143810 )
...
In #143802 the stdio test cleanup missed a few places where errno was
being set to a failing value, and one where the framework needed to
included.
2025-06-11 16:52:21 -07:00
Alexey Samsonov
1ecd108cb7
[libc] Migrate stdio tests to ErrnoCheckingTest. ( #143802 )
...
Reduce the direct use of libc_errno in stdio unit tests by adopting
ErrnoCheckingTest where appropriate.
Also removes the libc_errno.h inclusions from stdlib.h tests that were
accidentally added in d87eea35fa
2025-06-11 16:22:17 -07:00
Joseph Huber
dc4335a2bf
[libc] Perform bitfield zero initialization wave-parallel ( #143607 )
...
Summary:
We need to set the bitfield memory to zero because the system does not
guarantee zeroed out memory. Even if fresh pages are zero, the system
allows re-use so we would need a `kfd` level API to skip this step.
Because we can't this patch updates the logic to perform the zero
initialization wave-parallel. This reduces the amount of time it takes
to allocate a fresh by up to a tenth.
This has the unfortunate side effect that the control flow is more
convoluted and we waste some extra registers, but it's worth it to
reduce the slab allocation latency.
2025-06-11 18:22:05 -05:00
sribee8
79108da325
[libc][obvious] Changed incorrect type ( #143780 )
...
After changing mbstate_t to mbstate we forgot to change the
character_converter files to reflect it.
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-11 13:28:55 -07:00
lntue
d87eea35fa
[libc] Move libc_errno.h to libc/src/__support and make LIBC_ERRNO_MODE_SYSTEM to be header-only. ( #143187 )
...
This is the first step 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-06-11 16:25:27 -04:00
Uzair Nawaz
e389a0e7bb
[libc] Switched calls to inline_memcpy to __builtin_memcpy for wide char utilities ( #143011 )
...
Switched calls to inline_memcpy to __builtin_memcpy for wide char
utilities
Removed unnecessary wctype_utils dependencies from the cmake file
2025-06-11 13:17:35 -07:00
Uzair Nawaz
52583b3ed7
[libc] Character converter skeleton class ( #143619 )
...
Made CharacterConverter class skeleton
2025-06-11 13:11:31 -07:00
Alexey Samsonov
5dafe9dca8
[libc] Reduce direct use of errno in src/stdlib and src/__support tests. ( #143767 )
...
* Get rid of libc_errno assignments in str_to_* __support tests, since
those API have been migrated to return error in a struct instead.
* Migrate tests for atof and to strto* functions from <stdlib.h> and for
strdup from <string.h> to use ErrnoCheckingTest harness.
2025-06-11 12:23:17 -07:00
William
117e78fe50
[libc] Add NULL macro definitions to header files ( #142764 )
...
By the C standard, <locale.h>, <stddef.h> <stdio.h>, <stdlib.h>,
<string.h>, <time.h>, and <wchar.h> require NULL to be defined.
2025-06-11 09:51:34 -07:00
Joseph Huber
f1575de4c5
[libc][NFC] Remove template from GPU allocator reference counter
...
Summary:
We don't need this to be generic, precommit for
https://github.com/llvm/llvm-project/pull/143607
2025-06-11 11:37:51 -05:00
Amy Huang
1bf4702d2b
Disable prctl test when building for arm or riscv. ( #143627 )
...
I'm setting up a buildbot for arm32 using qemu and qemu doesn't support
PR_GET_THP_DISABLE.
Disable the test for now while we figure out what to do about that.
Also disable for riscv because we may do the same for riscv buildbots.
2025-06-10 16:18:53 -07:00
Michael Jones
06f6a771da
[libc] Simplify wcscmp ( #143457 )
...
The implementation of wcscmp mimicked strcmp, but was more complicated
than necessary. This patch makes it simpler.
2025-06-10 11:24:18 -07:00
Joseph Huber
0e2103ac5c
[libc][NFC] Remove unused CMake for gpu math
2025-06-07 09:25:27 -05:00
Michael Jones
3695d6cdf9
[libc][GPU] clean up includes ( #143203 )
...
The GPU stdio functions were depending on indirect inclusion for some of
their dependencies. This patch should fix all of that.
2025-06-06 14:12:07 -07:00
Joseph Huber
356dc628cb
[libc] Missing include in RPC test
2025-06-06 15:45:22 -05:00
William
a75fc765d3
[libc] Add definitions to embedded AArch32/AArch64 ( #142597 )
...
Add `CLOCKS_PER_SEC` and the older `CLK_TCK`. Allows the user to define
a `__CLK_TCK` to override if necessary.
Also add an extra column for embedded AArch64 in `time.rst`
2025-06-06 16:05:14 -04:00
Joseph Huber
5823e92749
[libc] Fix missing includes after transitive dependency changed
2025-06-06 14:34:27 -05:00
Michael Jones
59f88a8e92
[libc] clean up string_utils memory functions ( #143031 )
...
The string_utils.h file previously included both memcpy and bzero. There
were no uses of bzero, and only one use of memcpy which was replaced
with __builtin_memcpy.
Also fix strsep which was broken by this change, fix a useless assert of
"sizeof(char) == sizeof(cpp::byte)", and update the bazel.
2025-06-06 11:16:54 -07:00
Michael Jones
d8bfb4719d
[libc] clean up unused exp_utils ( #143181 )
...
This file's just left over from old code, but it doesn't compile
anymore. It's never used so this patch just removes it.
2025-06-06 11:02:55 -07:00
Joseph Huber
525726a520
[libc] Cleanup unimplemented math functions ( #143173 )
...
Summary:
This patch cleans up the leftoever files that were either implemented or
are still unimplemented stubs.
2025-06-06 12:27:13 -05:00
lntue
891a0abfc2
[libc] Correct x86_64 architecture for string(s) tests. ( #143150 )
2025-06-06 11:18:55 -04:00
Joseph Huber
59725c7486
[libc] Coalesce bitfield access in GPU malloc ( #142692 )
...
Summary:
This improves performance by reducing the amount of RMW operations we
need to do to a single slot. This improves repeated allocations without
much contention about ten percent.
2025-06-04 20:32:07 -05:00
Aly ElAshram
ff844df719
[libc] Expand usage of libc null checks. ( #116262 )
...
Fixes #111546
---------
Co-authored-by: alyyelashram <150528548+alyyelashram@users.noreply.github.com >
2025-06-04 13:08:27 -04:00
sribee8
22dd9a2483
[libc] wmemchr implementation ( #142640 )
...
Implemented wmemchr and tests.
Fixes : #121183
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-03 17:05:14 -07:00
sribee8
2ff2a076cc
[libc] wcsncpy implementation ( #142237 )
...
Implemented wcsncpy and tests for the function.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-03 16:37:14 -07:00
lntue
b994299e59
[libc] Also remove _FORTIFY_SOURCE before including <stdlib.h> in overlay mode. ( #142647 )
2025-06-03 14:25:46 -04:00
sribee8
3887c23059
[libc] wcscat implementation ( #142243 )
...
Implemented wcscat and tests.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-03 09:58:08 -07:00
Michael Jones
cc68367bb9
[libc][obvious] fix wchar yaml formatting ( #142506 )
...
The yaml ended up with a typo, possibly due to merge issues. This patch
fixes it.
2025-06-02 17:00:23 -07:00