Joseph Huber
24828c8c45
[libc] Efficiently implement aligned_alloc for AMDGPU ( #146585 )
...
Summary:
This patch uses the actual allocator interface to implement
`aligned_alloc`. We do this by simply rounding up the amount allocated.
Because of how index calculation works, any offset within an allocated
pointer will still map to the same chunk, so we can just adjust
internally and it will free all the same.
2025-07-02 09:25:57 -05:00
sribee8
47e28d9cd1
[libc] wcscspn implementation ( #146158 )
...
Implemented wcscspn and tests.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-07-01 15:56:09 +00:00
Uzair Nawaz
7a33b709b1
[libc] wcstok implementation ( #145989 )
...
Implemented wcstok and added tests
2025-06-30 10:41:00 -07:00
Joseph Huber
10445acfa6
[libc] Efficiently implement 'realloc' for AMDGPU devices ( #145960 )
...
Summary:
Now that we have `malloc` we can implement `realloc` efficiently. This
uses the known chunk sizes to avoid unnecessary allocations. We just
return nullptr for NVPTX. I'd remove the list for the entrypoint but
then the libc++ code would stop working. When someone writes the NVPTX
support this will be trivial.
2025-06-30 08:39:40 -05:00
sribee8
f58caed1bc
[libc] Changed CharacterConverter returns ( #146130 )
...
changed internal CharacterConverter returns to return errno macro when
necessary for consistency.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-27 21:50:09 +00:00
sribee8
ac7e391035
[libc] Implemented wcsnlen ( #145610 )
...
Implemented wcsnlen and tests for the function.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-27 16:51:37 +00:00
sribee8
bd86fc9252
[libc] Error fixes for mbrtowc and wcrtomb ( #145785 )
...
Invalid mbstate_t should set errno to EINVAL.
Changed Error return for the internal functions and added tests for the
public functions.
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-25 21:37:41 +00:00
Uzair Nawaz
2db0289abe
[libc] Implemented wctomb ( #145554 )
...
Implemented wctomb by calling internal wcrtomb function
Added tests
2025-06-25 13:23:47 -07:00
Uzair Nawaz
1c56d101a2
[libc] Added isValidState to CharacterConverter class to ensure a provided mbstate is valid ( #145564 )
...
Added isValidState to CharacterConverter class to ensure a provided
mbstate is valid
2025-06-25 12:06:22 -07:00
sribee8
bc5e5c0114
[libc] wcpncpy implementation ( #145430 )
...
Implemented wcpncpy and tests.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-23 23:35:28 +00:00
sribee8
10d46cf0d5
[libc] mbtowc implementation ( #145405 )
...
Implemented mbtowcs and tests for the function.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-23 23:25:13 +00:00
sribee8
b215c8e18f
[libc] wcpcpy implementation ( #144802 )
...
Implemented wcpcpy and tests.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-23 18:31:13 +00:00
Uzair Nawaz
a911543437
[libc] Implemented wcrtomb internal function and public libc function ( #144596 )
...
Implemented internal wcrtomb function using the CharacterConverter class
public libc function calls this internal function to perform the
conversion
2025-06-20 14:43:00 -07:00
sribee8
d078ce7c98
[libc] mbrtowc implementation ( #144760 )
...
implemented the internal and public mbrtowc as well as tests for the
public function.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-20 20:00:59 +00:00
Uzair Nawaz
8d6e29d0d3
[libc] Reworked CharacterConverter isComplete into isFull and isEmpty ( #144799 )
...
isComplete previously meant different things for different conversion
directions.
Refactored bytes_processed to bytes_stored which now consistently
increments on every push and decrements on pop making both directions
more consistent with each other
2025-06-20 16:59:30 +00:00
Aly ElAshram
5645d67109
Implement sigsetjmp and siglongjmp for darwin/aarch64 ( #139555 )
2025-06-19 09:15:59 -04:00
Alexey Samsonov
7ea710fafa
Fix/reapply "[libc] Migrate stdio tests to ErrnoCheckingTest. ( #144134 )
...
This reverts commit 92a116c4ef with a fix
for fgets test - convert nullptr to fgets return type (char*), since the
matcher is pedantic.
2025-06-17 10:44:21 -07:00
sribee8
e6a41399cb
Reland "[libc] utf8 to 32 CharacterConverter" ( #144450 )
...
Reverts llvm/llvm-project#144446
Figured out the issue, so creating a new pull request.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-17 16:24:01 +00:00
sribee8
6e12442354
Revert "[libc] utf8 to 32 CharacterConverter" ( #144446 )
...
Reverts llvm/llvm-project#143973
This merge broke the build and I'm currently looking into the issue to
fix it.
2025-06-16 22:33:32 +00:00
sribee8
98eee4b554
[libc] utf8 to 32 CharacterConverter ( #143973 )
...
Implemented push and pop for utf8 to 32 conversion and tests.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-16 22:20:08 +00:00
Uzair Nawaz
8adccaee2a
[libc] Implemented CharacterConverter push/pop for utf32->utf8 conversions ( #143971 )
...
Implemented CharacterConverter methods for conversion between utf32 ->
utf8
Added tests
---------
Co-authored-by: Michael Jones <michaelrj@google.com >
2025-06-16 20:06:46 +00:00
sribee8
4cd3e41bce
[libc] Removed public function calls in table.h ( #144168 )
...
Removed strcmp, strlen, and memset calls from table.h and replaced them
with internal functions.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-16 18:03:21 +00: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
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
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
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
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
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
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
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
Joseph Huber
356dc628cb
[libc] Missing include in RPC test
2025-06-06 15:45:22 -05:00
lntue
891a0abfc2
[libc] Correct x86_64 architecture for string(s) tests. ( #143150 )
2025-06-06 11:18:55 -04: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
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
Uzair Nawaz
c8741851d1
[libc] Implemented wcsncmp ( #142429 )
...
Implemented wcsncmp and added tests
2025-06-02 16:05:47 -07:00
sribee8
e3d1a33b7e
[libc] wcsstr implementation ( #142440 )
...
Implemented wcsstr and tests.
fixes #124348
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-02 16:05:12 -07:00
Uzair Nawaz
45c297428a
[libc] added nullptr checks for wcspbrk ( #142216 )
...
Added CRASH_ON_NULLPTR macro to wcspbrk function and related test
2025-06-02 15:20:53 -07:00
sribee8
9422abf9eb
[libc] wcsncat implementation ( #142431 )
...
Implemented wcsncat and tests.
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com >
2025-06-02 15:20:10 -07:00
Uzair Nawaz
dabe983e7e
[libc] Implemented wcsrchr ( #142436 )
...
fixes #124347
Implemented wcsrchr and added tests
2025-06-02 15:18:44 -07:00
Uzair Nawaz
62af2a5ae2
[libc] Implemented wcscmp ( #142423 )
...
Implemented wcscmp and added tests
2025-06-02 15:16:14 -07:00
Uzair Nawaz
c80c452525
[libc] Implemented wmempcpy ( #142067 )
...
Implemented wmempcpy and added tests
2025-06-02 15:00:46 -07:00