summaryrefslogtreecommitdiff
path: root/libc/config
Commit message (Collapse)AuthorAgeFilesLines
* [libc] Enable linux directory entries syscalls in riscv64Mikhail R. Gadelha2023-05-042-0/+7
| | | | | | | | | | This patch updates the struct dirent to be on par with glibc (by adding a missing d_type member) and update the readdir call to use SYS_getdents64 instead of SYS_getdents. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D147738
* [libc] Enable running libc unit tests on AMDGPUJoseph Huber2023-05-041-11/+0
| | | | | | | | | | | The previous patches added the necessary support for global constructors used to register tests. This patch enables the AMDGPU target to build and run the unit tests on the GPU. Currently this only tests the `ctype` tests, but adding more should be straightforward from here on. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D149517
* [libc] add socket functionMichael Jones2023-05-032-0/+7
| | | | | | | | | | This patch adds the function "socket" from the header "sys/socket". It's a simple syscall wrapper, and I plan on adding the related functions in a followup patch. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D149622
* [libc] Implement `exit` for the GPU partiallyJoseph Huber2023-04-271-1/+5
| | | | | | | | | | | | This patch implements the `exit` function on the GPU. This required breaking the entrypoints calling eachother on `linux` since this doesn't work with a non-aliased target. This is only partial support because full support requires a malloc / free implementation for the exit callbacks array. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D149363
* [libc] Support the `abs` functions in the GPU libc.Joseph Huber2023-04-271-0/+3
| | | | | | | | | This patch simply enables building the integer `abs` functions for the GPU. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D149317
* [libc] Support the string conversion methods on the GPUJoseph Huber2023-04-273-0/+15
| | | | | | | | | | | | | | | This patch enables us to use the existing `libc` support for string conversion functions on the GPU. This required setting the `fenv_t` and long double configuration. As far as I am aware, long doubles are converted to doubles on the GPU and the floating point environment is just an `uint32_t`. This code is still untested as we are still working out how to run the unit tests on the GPU. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D149306
* [libc] Partially implement `atexit` on the GPUJoseph Huber2023-04-262-0/+9
| | | | | | | | | | | | | | | The `atexit` function controls registering functions to call at the end of the program. This is difficult to do in general on the GPU because of the lack of a real mutex implementation. We primarily provide this for testing where we can explicitly restrict how the `atexit` registration functions are called. So we simply create a passthrough Mutex to get past the usage of it as per @sivachandra's suggestion. Depends on D149225 Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D149226
* [libc] Enable the GPU build to build the UnitTest libraryJoseph Huber2023-04-261-0/+5
| | | | | | | | | | | | | | | The previous patch in D149216 allows us to use the internal `<stdlib.h>` include for the GPU build. However, we currently don't provide the memory functions so the header wasn't resolving them. This patch adds these as entrypoints. They don't cause any entrypoints to be emitted because they are not implemented, but they provide it in the header so that we can rely on the test's implementation of them. Depends on D149216 Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D149217
* [libc][fix] Add missing 'errno' header for the GPU libcJoseph Huber2023-04-252-0/+4
| | | | | | | | Summary: The previous GPU `libc` patch added support for `atoi`. However, it didn't also enable generating the errno header. This caused including it to use the system's header which invariably will cause compiler problems.
* [libc] Ignore 'errno' on the GPU and support 'atoi'Joseph Huber2023-04-252-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'errno' value is most likely not useful on the GPU and it prevents us from providing certain functions on the GPU that depend on it, like `atoi`. This patch makes the necessary changes to support `errno` by simple replacing it with a consumer class. Supporting `errno` on the GPU is possible in some aspects. The first approach would be to use a buffer of shared memory that has enough space for all threads. Another option would be to change code generation to support `thread_local` using `address_space(5)` memory allocated at kernel launch. The former could look like the following, which could be implemented in a later patch: ``` template <typename T> using SharedBuffer = T[gpu::MAX_THREADS] [[clang::address_space(3)]]; template <typename T> struct ErrnoSetter { constexpr ErrnoSetter(SharedBuffer<T> &storage) : storage(storage) {} SharedBuffer<T> &storage; void operator=(const T &val) { storage[gpu::get_thread_id()] = val; } }; static SharedBuffer<int> thread_local_buffer [[clang::loader_uninitialized]]; ErrnoSetter<int> __llvmlibc_internal_errno(thread_local_buffer); ``` Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D149107
* [LIBC] Implement remainder of posix 'sched.h' minus `SCHED_SPORADIC`Noah Goldstein2023-04-204-1/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | Includes macros: linux/SCHED_OTHER // posix req linux/SCHED_FIFO // posix req linux/SCHED_RR // posix req linux/SCHED_BATCH linux/SCHED_ISO linux/SCHED_IDLE linux/SCHED_DEADLINE Includes types: struct sched_param { int sched_priority; } Includes functions: sched_setparam sched_getparam sched_setscheduler sched_getscheduler sched_get_priority_max sched_get_priority_min sched_rr_get_interval Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D148069
* [libc][math] Remove placeholder implementations of asin and pow.Tue Ly2023-04-204-8/+0
| | | | | | Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D148781
* [libc] Partial revert of "[libc] Update supported riscv libs"Mikhail R. Gadelha2023-04-171-1/+0
| | | | | | | Partial revert of commit ee917996708c936dd7f275de06b7895f5e3c11ec. I can't reproduce the error locally, so let's revert it to keep the bots happy.
* [libc] Update supported riscv libsMikhail R. Gadelha2023-04-172-1/+7
| | | | | | | | This patch updates the list of supported libs according to the latest changes to x86_64 Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D147961
* [libc] Add implementation of getcharMichael Jones2023-04-143-0/+6
| | | | | | | | 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
* [LIBC] Implement `sched_yield()`Noah Goldstein2023-04-123-0/+3
| | | | | | | | | | | 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
* [libc] Add memmem implementationCaslyn Tonelli2023-04-119-0/+9
| | | | | | | | | | 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
* [libc] Fix swab placementCaslyn Tonelli2023-04-113-3/+3
| | | | | | | | 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
* Reland "[libc] Add {,r}index"Alex Brachet2023-04-114-0/+8
| | | | Differential Revision: https://reviews.llvm.org/D147464
* Revert "[libc] Add {,r}index"Alex Brachet2023-04-114-8/+0
| | | | This reverts commit a0a141fcbe1dfd35032fa5c052e6906180a37fb1.
* [libc] Add {,r}indexAlex Brachet2023-04-114-0/+8
| | | | Differential Revision: https://reviews.llvm.org/D147464
* [libc] Add swab implementationCaslyn Tonelli2023-04-103-0/+3
| | | | | | Swab implementation is added to libc/src/unistd. Differential Revision: https://reviews.llvm.org/D147970
* [libc] Add strxfrm ImplementationCaslyn Tonelli2023-04-072-0/+2
| | | | | | | | | | | | 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
* [libc] Implement strsepAlex Brachet2023-04-064-0/+4
| | | | Differential Revision: https://reviews.llvm.org/D147503
* [libc] Add strchrnul implementationCaslyn Tonelli2023-04-039-0/+9
| | | | | | | | Introduce strchrnul implementation and unit tests. Submitting on behalf of Caslyn@ Differential Revision: https://reviews.llvm.org/D147346
* [libc] Enable more headers for riscvMikhail R. Gadelha2023-03-311-0/+7
| | | | | | Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D146203
* [libc] Re-enable wctob with fixesMichael Jones2023-03-291-1/+1
| | | | | | | | | The stdio test failures were due to headers potentially not being built in the correct order. This should set up the dependencies correctly. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D146551
* [libc] Add support for setjmp and longjmp in riscvMikhail R. Gadelha2023-03-242-0/+5
| | | | | | | | | | | | | | | | | | This patch implements setjmp and longjmp in riscv using inline asm. The following changes were required: * Omit frame pointer: otherwise gcc won't allow us to use s0 * Use __attribute__((naked)): otherwise both gcc and clang will generate function prologue and epilogue in both functions. This doesn't happen in x86_64, so we guard it to only riscv Furthermore, using __attribute__((naked)) causes two problems: we can't use `return 0` (both gcc and clang) and the function arguments in the function body (clang only), so we had to use a0 and a1 directly. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D145584
* [libc] enable printf using system FILEMichael Jones2023-03-231-2/+2
| | | | | | | | | | The printf and fprintf implementations use our internal implementation to improve performance when it's available, but this patch enables using the public FILE API for overlay mode. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D146001
* [libc] temporarily disable wctob entrypointMichael Jones2023-03-201-1/+1
| | | | Differential Revision: https://reviews.llvm.org/D146484
* [libc] add basic wide char functionsMichael Jones2023-03-203-0/+12
| | | | | | | | | | This patch adds the wchar header, as well as the functions to convert to and from wide chars. The header also sets up the definitions for wint and wchar. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D145995
* [libc] Enable __llvm_libc_syscall and forkMikhail R. Gadelha2023-03-161-0/+2
| | | | | | | | | | | | | | | This patch enables the remaining calls from unistd. The test cases had to be updated to: 1. Use SYS_symlinkat if SYS_symlink is not available 2. Use SYS_readlinkat if SYS_readlink is not available 3. Use SYS_unlinkat if SYS_unlink is not available 4. Use SYS_openat if SYS_open is not available We also abort compilation if neither of the syscalls mentioned above are available. Differential Revision: https://reviews.llvm.org/D146161
* [libc] Enable spawn lib in riscvMikhail R. Gadelha2023-03-162-0/+9
| | | | | | | | | | In this patch we add support for the spawn lib in riscv. Only small changes were required, the biggest one was to use of dup3 instead of dup2, if the latter is not available. This follows our implementation of dup2. Differential Revision: https://reviews.llvm.org/D146145
* [libc] Update supported riscv libsMikhail R. Gadelha2023-03-162-4/+28
| | | | | | | This patch removes some duplicated libs added to entrypoints.txt, adds new libs supported to entrypoints.txt and updates header.txt Differential Revision: https://reviews.llvm.org/D146065
* [libc] Enable more functions on riscv64.Siva Chandra2023-03-142-5/+68
| | | | | The list of headers has also been updated. Some duplicated entrypoints have been removed.
* [libc][NFC] Add string.h header to various platform headers.txt.Siva Chandra Reddy2023-03-137-0/+7
|
* [libc] Extend the linux thread implementation for riscv64.Siva Chandra2023-03-092-1/+34
| | | | | | | | | | Also, added riscv64 startup code for static linking which is used by the integration tests. Functions from the C standard threads library have been enabled. Reviewed By: mikhail.ramalho Differential Revision: https://reviews.llvm.org/D145670
* [libc] Widen the riscv64 full build config.Siva Chandra2023-03-082-0/+58
|
* [libc] Remove log10 from the list of riscv64 entrypoints.Siva Chandra2023-03-081-4/+0
| | | | Its test is currently failing of real riscv64 hardware.
* [libc] Support more functions in riscvMikhail R. Gadelha2023-03-082-4/+113
| | | | | | Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D145444
* [libc] Add riscv64 fenv implementation and enable the fenv.h functions.Siva Chandra2023-03-081-0/+16
| | | | | | Reviewed By: mikhail.ramalho Differential Revision: https://reviews.llvm.org/D145560
* [libc] Small improvements to libc cmakeMikhail R. Gadelha2023-03-081-5/+4
| | | | | | | | | | | | This patch includes: 1. Better error message when cmake finds incompatible triple 2. Added missing header dependencies libc/include/CMakeLists.txt as per app.td 3. Removed unused $LLVM_LIBC_INCLUDE_DIRS cmake variable Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D145496
* [libc] Add riscv64 syscall implementation.Siva Chandra2023-03-071-0/+104
| | | | | | | | All syscall wrapper functions which have unit tests have been enabled. Reviewed By: kito-cheng Differential Revision: https://reviews.llvm.org/D145452
* [libc] Add fenv functions to arm32 baremetal config.Siva Chandra Reddy2023-03-073-0/+21
| | | | | | | | Also, an "arm" subfolder for baremetal config has been added. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D145476
* [libc] Move math.h and fenv.h macro definitions to llvm-libc-macros.Siva Chandra Reddy2023-03-071-63/+0
| | | | | | Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D145475
* [libc] Add a headers.txt for linux/arm config.Siva Chandra Reddy2023-03-071-0/+9
|
* [libc] Add riscv64 config.Siva Chandra2023-03-062-0/+114
| | | | | | | | | Memory functions get the basic implementation. They can be tuned as a follow up. Reviewed By: michaelrj, lntue Differential Revision: https://reviews.llvm.org/D145433
* [libc] Add arm 32 FEnvImpl.Siva Chandra Reddy2023-03-061-0/+16
| | | | | | Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D145347
* [libc][Obvious] Add errno entrypoint for macOS ARM64.Tue Ly2023-03-061-1/+4
|
* [libc] Make errno an entrypoint.Siva Chandra Reddy2023-03-034-0/+12
| | | | | | | | | | The entrypoint has been added to the various entrypoint lists. The libc code style doc has been updated with information on how errno should be set from the libc runtime code. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D145179