aboutsummaryrefslogtreecommitdiff
path: root/libc
AgeCommit message (Collapse)AuthorFilesLines
2023-04-15Revert "Revert "[CMake] Bumps minimum version to 3.20.0.""Mark de Wever2-2/+2
This reverts commit 92523a35a827539db8557bbc3ecab7f9ea3f6ade. Reland to see whether CIs are updated.
2023-04-14[libc] Add implementation of getcharMichael Jones11-1/+135
added getchar and getchar_unlocked which are just wrappers getc and getc_unlocked respectively. Reviewed By: sivachandra, lntue, michaelrj Differential Revision: https://reviews.llvm.org/D147919
2023-04-14[libc] Remove duplicate architecture from the detected listJoseph Huber1-0/+1
Summary: When we detect the architectures via `native` we can have systems with multiple of the same GPU. We need to remove duplicates or else we will try to build the same target multiple times.
2023-04-14[LIBC] Actually assert no errors in `pthread_call_once` in its test; NFCNoah Goldstein1-1/+1
Just seemed to be missing an assertion. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D148289
2023-04-14[LIBC] Clarify namespace of `thread_exit` in `pthread_exit`Noah Goldstein1-1/+1
Just add `__llvm_libc::` to makes things clearer. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D148292
2023-04-12[LIBC] Fix comments / name of __sched_cpu_count testsNoah Goldstein1-2/+2
Test was incorrectly named/commented after the sched_{set|get}affinity functions. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D148044
2023-04-12[LIBC] Fix `getrandom` success return valueNoah Goldstein2-1/+10
`getrandom` should return the number of bytes successfully set on success, not `0`. Reviewed By: sivachandra, michaelrj Differential Revision: https://reviews.llvm.org/D147981
2023-04-12[LIBC] Implement `sched_yield()`Noah Goldstein11-2/+116
Implements: https://linux.die.net/man/2/sched_yield Possibly we don't need the return value check / errno as according to both the manpage (and current linux source) `sched_yield` cannot fail. Reviewed By: sivachandra, michaelrj Differential Revision: https://reviews.llvm.org/D147985
2023-04-12[libc] Fix strtod exponent overflow bugMichael Jones2-5/+33
String to float has a condition to prevent overflowing the exponent with the E notation. To do this it checks if adding that exponent to the exponent found by parsing the number is greater than the maximum exponent for the given size of float. The if statements had a gap on exactly the maximum exponent value that caused it to be treated as the minimum exponent value. This patch fixes those conditions. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D148152
2023-04-11[libc] Fix typo in gnu_ext.tdCaslyn Tonelli1-1/+1
Differential Revision: https://reviews.llvm.org/D148052
2023-04-11[libc] Add memmem implementationCaslyn Tonelli18-12/+265
Introduce the `memmem` libc string function. `memmem_implementation` performs shared logic for `strstr`, `strcasestr`, and `memmem`; essentially reconfiguring what was the `strstr_implementation` to support length parameters. Differential Revision: https://reviews.llvm.org/D147822
2023-04-11[libc] Fix swab placementCaslyn Tonelli6-18/+14
Per https://reviews.llvm.org/D147970#4256889, swab.cpp is moved out of the /linux subdirectory and cmake specifications are amended to reflect that swab is not OS-specific. Differential Revision: https://reviews.llvm.org/D147988
2023-04-11[libc][math] Update range reduction step for log2f and improve its performance.Tue Ly2-72/+68
Simplify the range reduction steps by choosing the reduction constants carefully so that the reduced arguments v = r*m_x - 1 and v^2 are exact in double precision, even without FMA instructions, and -2^-8 <= v < 2^-7. Reviewed By: zimmermann6 Differential Revision: https://reviews.llvm.org/D147759
2023-04-11[libc] remove unsupported GCC attributeGuillaume Chatelet1-2/+2
This is ok as we build the libraries with `-ffreestanding` which implies `-fno-builtin` on all functions.
2023-04-11[libc][NFC] Use new approach based on types to code memmoveGuillaume Chatelet2-83/+54
2023-04-11[libc][NFC] Use new approach based on types to code memsetGuillaume Chatelet4-91/+86
2023-04-11[libc] Correctly add new filesAlex Brachet6-0/+104
2023-04-11Reland "[libc] Add {,r}index"Alex Brachet7-6/+66
Differential Revision: https://reviews.llvm.org/D147464
2023-04-11Revert "[libc] Add {,r}index"Alex Brachet13-170/+6
This reverts commit a0a141fcbe1dfd35032fa5c052e6906180a37fb1.
2023-04-11[libc] Add {,r}indexAlex Brachet13-6/+170
Differential Revision: https://reviews.llvm.org/D147464
2023-04-11[libc] Move str{,r}chr implementation to headersAlex Brachet9-155/+243
Differential Revision: https://reviews.llvm.org/D147463
2023-04-10[libc] Add swab implementationCaslyn Tonelli10-0/+162
Swab implementation is added to libc/src/unistd. Differential Revision: https://reviews.llvm.org/D147970
2023-04-10[libc][obvious] fix new assert typoMichael Jones1-1/+1
2023-04-10[libc][math] Update range reduction step for logf and reduce its latency.Tue Ly4-63/+169
Simplify the range reduction steps by choosing the reduction constants carefully so that the reduced arguments v = r*m_x - 1 and v^2 are exact in double precision, even without FMA instructions, and -2^-8 <= v < 2^-7. This allows the polynomial evaluations to be parallelized more efficiently. Reviewed By: santoshn, zimmermann6 Differential Revision: https://reviews.llvm.org/D147755
2023-04-10[libc] clean up ctype negative handlingMichael Jones19-37/+36
The ctype functions will sometimes be passed negative numbers, such as EOF. Some of the previous implementations didn't handle these properly. Additionally, the tests did not check any negative numbers. These problems have been fixed. This patch fixes https://github.com/llvm/llvm-project/issues/62000 Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D147813
2023-04-07[libc] Add baremetal abortAlex Brachet2-0/+24
Differential Revision: https://reviews.llvm.org/D147795
2023-04-07[libc][obvious] fix phrasing in assert commentMichael Jones1-5/+6
2023-04-07[libc][math] Update range reduction step for log10f and reduce its latency.Tue Ly5-150/+209
Simplify the range reduction steps by choosing the reduction constants carefully so that the reduced arguments v = r*m_x - 1 and v^2 are exact in double precision, even without FMA instructions, and -2^-8 <= v < 2^-7. This allows the polynomial evaluations to be parallelized more efficiently. Reviewed By: zimmermann6 Differential Revision: https://reviews.llvm.org/D147676
2023-04-07[libc][NFC] Simplify op_genericGuillaume Chatelet1-123/+121
2023-04-07[libc] Use SFINAE to implement is_signed/is_unsignedGuillaume Chatelet1-2/+12
This allows to use the type traits with types that are non constructible from integers.
2023-04-07[libc] Add value_type to cpp::arrayGuillaume Chatelet1-1/+1
2023-04-07[libc][NFC] Simplify type_traitsGuillaume Chatelet1-59/+44
2023-04-07[libc] Add strxfrm ImplementationCaslyn Tonelli7-0/+114
Introduce `strxfrm` and unit tests. The current implementation is introduced without locale support. The simplified function performs a `memcpy` if the `n` value is large enough to store the source len + '\0', otherwise `dest` is unmodified. Ticket: https://fxbug.dev/124217 Differential Revision: https://reviews.llvm.org/D147478
2023-04-06[libc] Implement strsepAlex Brachet11-2/+125
Differential Revision: https://reviews.llvm.org/D147503
2023-04-06[libc][RISCV] Let RISCV64 targets test implementations with and without FMA.Tue Ly3-5/+11
Let RISCV64 targets math implementations with and without FMA automatically. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D146730
2023-04-06[libc] Remove dead codeGuillaume Chatelet1-6/+0
2023-04-05[libc] Only add extra runtime dependencies if the target existsJoseph Huber1-1/+0
Summary: If the target for these tools doesn't exist we should simply assume that they will be provided externally. This allows building `libc` standalone with an external installation of `clang`.
2023-04-05[libc] Search for the CUDA patch explicitly when testingJoseph Huber5-1/+15
The packaged version of the `libc` library does not depend on the CUDA installation because it only uses `clang` and emits LLVM-IR. However, for testing we directly need the CUDA toolkit to emit and execute the files. This patch explicitly passes `--cuda-path` to the relevant compilations for NVPTX testing. Reviewed By: tra Differential Revision: https://reviews.llvm.org/D147653
2023-04-05[libc][NFC] Rework generic memory operationsGuillaume Chatelet1-197/+239
2023-04-05[libc] fix strtofloat on large exponentsMichael Jones2-11/+383
Previously if you specified an exponent of more than 10000 in string to float (e.g. "1e10001") it would treat it as 10000. A bug was discovered where by having more than 10000 zeroes after a decimal point and an exponent of more than 10000 this would cause the code to return the incorrect value. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D147474
2023-04-03[libc] Add strchrnul implementationCaslyn Tonelli16-1/+172
Introduce strchrnul implementation and unit tests. Submitting on behalf of Caslyn@ Differential Revision: https://reviews.llvm.org/D147346
2023-04-03[libc] Free the GPU memory allocated in the device loadersJoseph Huber2-0/+28
Summary: This part was ignored and we just hoped that shutting down the runtime freed these correctly. But it's best to be specific and free the memory we've allocated.
2023-04-03[libc] Improve copying system vectors to the GPUJoseph Huber1-8/+15
Summary: This implementation was buggy and inefficient. Fine-grained memory can only be allocated on a page-level granularity. Which means that each allocated string used about 4096 bytes. This is wasteful in general, and also allowed for buggy behaviour. The previous copying of the environment vector only worked because the large buffer size meant that we would typically have a null byte after the allocated memory. However this would break if the vector was larger than a page. This patch allocates everything into a single buffer. It makes it easier to free, use, and it more correct.
2023-04-03[re-reland][libc] Adds string and TestLogger classes, use them in LibcTestGuillaume Chatelet9-77/+631
This is an implementation of https://discourse.llvm.org/t/rfc-running-libc-unit-tests-as-integration-tests/69461. Differential Revision: https://reviews.llvm.org/D147231
2023-04-03Revert D147231 "[reland][libc] Adds string and TestLogger classes, use them ↵Guillaume Chatelet9-623/+77
in LibcTest" Build bot detected a memory leak. This reverts commit b82d04ea4b4f26037be369f101ae7011975df486.
2023-04-03[reland][libc] Adds string and TestLogger classes, use them in LibcTestGuillaume Chatelet9-77/+623
This is an implementation of https://discourse.llvm.org/t/rfc-running-libc-unit-tests-as-integration-tests/69461. Differential Revision: https://reviews.llvm.org/D147231
2023-04-02Revert D147231 "[libc] Adds string and TestLogger classes, use them in LibcTest"Guillaume Chatelet9-623/+77
Does not build with gcc. This reverts commit fc5ae0a7a45bdb5251f3dad3fc07047f987ca447.
2023-04-02[libc] Adds string and TestLogger classes, use them in LibcTestGuillaume Chatelet9-77/+623
This is an implementation of https://discourse.llvm.org/t/rfc-running-libc-unit-tests-as-integration-tests/69461. Differential Revision: https://reviews.llvm.org/D147231
2023-04-02[libc] Fix missing include for pthread testsGuillaume Chatelet5-0/+5
2023-04-02[libc] Use string_view for write_to_stderrGuillaume Chatelet5-17/+43
This patch makes use of `cpp::string_view` instead of `const char*` for `write_to_stderr`. This helps sending non null-terminated buffers such as a single character, `cpp::string_view` or `cpp::string`. It also fizes the gpu version that had several bugs (See https://reviews.llvm.org/D145913#4236641). Differential Revision: https://reviews.llvm.org/D147375