summaryrefslogtreecommitdiff
path: root/libc/src/pthread
AgeCommit message (Collapse)Author
2025-10-08[libc] Refactor AUXV handling with new auxv.h header library (#162326)Schrodinger ZHU Yifan
Closes https://github.com/llvm/llvm-project/issues/153666 This patch introduces a new centralized AUXV (auxiliary vector) handling mechanism for LLVM libc on Linux, replacing the previous scattered implementation across multiple files. ## Key Changes: ### New Files: - **libc/src/__support/OSUtil/linux/auxv.h**: New header library providing a clean interface for AUXV access with: - `auxv::Entry` struct for AUXV entries (type and value) - `auxv::Vector` class with iterator support for traversing AUXV - `auxv::get()` function for retrieving specific AUXV values - Thread-safe initialization with fallback mechanisms (prctl and /proc/self/auxv) ### Modified Files: 1. **libc/src/__support/OSUtil/linux/CMakeLists.txt**: - Added `auxv` header library declaration with proper dependencies: - libc.hdr.fcntl_macros - libc.src.__support.OSUtil.osutil - libc.src.__support.common - libc.src.__support.CPP.optional - libc.src.__support.threads.callonce 2. **libc/config/linux/app.h**: - Removed `AuxEntry` struct (moved to auxv.h as `auxv::Entry`) - Removed `auxv_ptr` from `AppProperties` struct - Simplified application properties structure 3. **libc/src/sys/auxv/linux/getauxval.cpp**: - Completely refactored to use new auxv.h interface - Removed ~200 lines of complex initialization code - Simplified to just call `auxv::get()` function - Removed dependencies to external symbols (mman, prctl, fcntl, read, close, open) 4. **libc/src/sys/auxv/linux/CMakeLists.txt**: - Updated dependencies to use new auxv header library - Removed dependencies to external symbols (prctl, mman, fcntl, unistd, etc.) 5. **libc/startup/linux/do_start.cpp**: - Updated to use new `auxv::Vector` interface - Changed from pointer-based to iterator-based AUXV traversal - Updated field names (`aux_entry->id` → `aux_entry.type`, `aux_entry->value` → `aux_entry.val`) - Added call to `auxv::Vector::initialize_unsafe()` for early AUXV setup 6. **libc/startup/linux/CMakeLists.txt**: - Added dependency on `libc.src.__support.OSUtil.linux.auxv`
2025-07-29[libc] Reland #148948 "Implement barriers for pthreads" (#151021)Uzair Nawaz
Fixed build dependencies for pthread_barrier_t (add __barrier_type to cmake dependencies)
2025-07-28Revert "[libc] Implement barriers for pthreads" (#151014)Uzair Nawaz
Reverts llvm/llvm-project#148948
2025-07-28[libc] Implement barriers for pthreads (#148948)Uzair Nawaz
Implemented barrier synchronization for pthreads - Uses condition variables internally for platform independence (platform-specific work is handled by the condition variable implementation) - Does NOT currently handle barrierattr pshared, this is a goal for a future patch
2025-07-23[libc][NFC] Add stdint.h proxy header to fix dependency issue with ↵lntue
<stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993
2025-06-11[libc] Move libc_errno.h to libc/src/__support and make ↵lntue
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-01-08[libc][NFC] Cleanup time.h (#122027)Michael Jones
While working on strftime I noticed some constants were being defined in unexpected places. One thing led to another, and I ended up doing a major cleanup of the time functions. What's included: All uses of <time.h> in /src and /test removed (except for LibcTest.cpp) The various time constants have been moved to time_constants.h, and the `time_constants` namespace. struct tm gets its own type indirection header now.
2024-11-26[libc] suppress more clang-cl warnings (#117718)Schrodinger ZHU Yifan
- migrate more `-O3` to `${libc_opt_high_flag}` - workaround a issue with `LLP64` in test. The overflow testing is guarded by a constexpr but the literal overflow itself will still trigger warnings. Notice that for math smoke test, for some reasons, the `${libc_opt_high_flag}` will be passed into `lld-link` which confuses the linker so there are still some warnings leftover there. I can investigate more when I have time.
2024-10-05[libc] remove errno.h includes (#110934)Job Henandez Lara
2024-08-06[libc] add spin lock family functions (#100509)Schrodinger ZHU Yifan
This PR: - add entrypoints for `pthread_spin_*` - additionally, the fixes a typo that has been disabling lock related tests
2024-07-28[libc] add pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock … ↵Eric977
(#100543)
2024-07-12[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)Petr Hosek
This is a part of #97655.
2024-07-12Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace ↵Mehdi Amini
declaration" (#98593) Reverts llvm/llvm-project#98075 bots are broken
2024-07-11[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)Petr Hosek
This is a part of #97655.
2024-06-14[libc] fix build errors (#95613)Schrodinger ZHU Yifan
2024-06-14[libc] add rwlock (#94156)Schrodinger ZHU Yifan
2024-05-31[libc] rework mutex (#92168)Schrodinger ZHU Yifan
2024-05-30Reland: [libc][POSIX][pthreads] implemented missing pthread_rwlockattr ↵Hendrik Hübner
functions (#93622) New pull request for https://github.com/llvm/llvm-project/issues/89443 The previous PR was reverted after breaking fullbuild due to a missing struct declaration, which I forgot to commit. Reverts revert and adds the missing pthread_rwlockattr_getkind_np / pthread_rwlockattr_setkind_np functions and tests respecitvely.
2024-05-13Revert "[libc][POSIX][pthreads] implemented missing pthread_rwlockattr ↵Schrodinger ZHU Yifan
functions" (#91966) Reverts llvm/llvm-project#90249 Fullbuild is broken: https://lab.llvm.org/buildbot/#/builders/163/builds/56501
2024-05-13[libc][POSIX][pthreads] implemented missing pthread_rwlockattr functions ↵Hendrik Hübner
(#90249) Closes #89443 I added the two missing functions and respective test cases. Let me know if anything needs changing.
2024-04-22[libc][POSIX][pthreads] implement pthread_rwlockattr_t functions (#89322)Nick Desaulniers
Implement: - pthread_rwlockattr_destroy - pthread_rwlockattr_getpshared - pthread_rwlockattr_init - pthread_rwlockattr_setpshared
2024-04-17[libc] set cmake dependencies for condattr test (#89103)Nick Desaulniers
The entrypoints are not yet exposed on non-x86. Express this dependency to unbreak post submit. Fixes #88987
2024-04-17[libc][POSIX][pthreads] implement pthread_condattr_t functions (#88987)Nick Desaulniers
Implement: - pthread_condattr_destroy - pthread_condattr_getclock - pthread_condattr_getpshared - pthread_condattr_init - pthread_condattr_setclock - pthread_condattr_setpshared Fixes: #88581
2023-09-26[libc] Mass replace enclosing namespace (#67032)Guillaume Chatelet
This is step 4 of https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
2023-09-21[libc][clang-tidy] Add llvm-header-guard to get consistant naming and ↵Guillaume Chatelet
prevent file copy/paste issues. (#66477)
2023-07-05[libc] Use the new style includesPetr Hosek
We should be using the standard includes. Differential Revision: https://reviews.llvm.org/D154529
2023-05-22Add some missing [[noreturn]] attributesNoah Goldstein
Missing in header for `pthread_exit` and `exit`. Missing in spec file for `pthread_exit`. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D151143
2023-05-22Support custom attributes in pthread_createNoah Goldstein
Only functional for stack growsdown (same as before), but custom `stack`, `stacksize`, `guardsize`, and `detachstate` all should be working. Differential Revision: https://reviews.llvm.org/D148290
2023-04-14[LIBC] Clarify namespace of `thread_exit` in `pthread_exit`Noah Goldstein
Just add `__llvm_libc::` to makes things clearer. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D148292
2023-03-31[libc][Obvious] Add a missing dep and fix an incorrect dep.Siva Chandra Reddy
2023-01-24[libc][NFC] Another round of replacement of static inline with LIBC_INLINE.Siva Chandra Reddy
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D142398
2022-12-12[libc] move errno out of file internalsMichael Jones
Now errno is only set by the terminal entrypoints, and not the internal implementations. This patch is part of the larger effort to not set errno in libc internal code: https://github.com/llvm/llvm-project/issues/59278 Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D139576
2022-11-11[libc] move fork into threads folderMichael Jones
Fork, as a thread function, should go in the threads folder. Additionally, it depends on the thread mutex, and it was causing build issues for targets where we don't support threads. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D137867
2022-10-10[libc] Add implementation of pthread_atfork.Siva Chandra Reddy
Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D135432
2022-09-28[libc] Add implementation of pthread_once.Siva Chandra Reddy
The existing thrd_once function has been refactored so that the implementation can be shared between thrd_once and pthread_once functions. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D134716
2022-08-22[libc][NFC] Use STL case for string_viewGuillaume Chatelet
2022-08-22[NFC][libc] Remove ArrayRef which is replaced with spanGuillaume Chatelet
2022-08-22[reland][NFC][libc] Use span instead of ArrayRefGuillaume Chatelet
2022-08-12[libc] Add implemementations of thread specific data related API.Siva Chandra Reddy
Specifically, POSIX functions pthread_key_create, pthread_key_delete, pthread_setspecific and pthread_getspecific have been added. The C standard equivalents tss_create, tss_delete, tss_set and tss_get have also been added. Reviewed By: lntue, michaelrj Differential Revision: https://reviews.llvm.org/D131647
2022-08-10[libc] Add implementation of pthread_exit and thrd_exit.Siva Chandra Reddy
Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D131451
2022-08-04[libc][NFC] Add a few compiler warning flags.Siva Chandra Reddy
A bunch of cleanup to supress the new warnings is also done. Reviewed By: abrachet Differential Revision: https://reviews.llvm.org/D130723
2022-08-02[libc] Add GNU extension functions pthread_setname_np and pthread_getname_np.Siva Chandra Reddy
Reviewed By: michaelrj, lntue Differential Revision: https://reviews.llvm.org/D130872
2022-07-14[libc] Add implementations of pthread_equal and pthread_self.Siva Chandra Reddy
Reviewed By: michaelrj, lntue Differential Revision: https://reviews.llvm.org/D129729
2022-06-24[libc][NFC] Remove the templatization from the linux implementation of thread.Siva Chandra Reddy
This enables setting up a single "self" thread object to be returned by API like thrd_self and pthread_self.
2022-06-11[libc] Add pthread_detach and thrd_detach.Siva Chandra Reddy
Tests for pthread_detach and thrd_detach have not been added. Instead, a test for the underlying implementation has been added as it makes use of an internal wait method to synchronize with detached threads. Reviewed By: lntue, michaelrj Differential Revision: https://reviews.llvm.org/D127479
2022-06-09[libc] Add compile options to pthread_create target.Siva Chandra Reddy
The compile options now match that of thrd_create. Two compile options are of importance: 1. -O3 - This is required so that stack is not used between the clone syscall and the start function in the child thread. 2. -fno-omit-frame-pointer - This is required so that we can sniff out the thread start args from the child thread's stack memory. Without these two options, pthread_create will exhibit flaky behavior. Reviewed By: lntue, michaelrj Differential Revision: https://reviews.llvm.org/D127381
2022-06-02[libc] Add pthread_create and pthread_join functions.Siva Chandra Reddy
They do not yet support all the feature/attributes in pthread_attr_t. Future changes will add such support. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D126718
2022-05-24[libc] Add the pthread_mutex_t type.Siva Chandra Reddy
Simple implementations of the functions pthread_mutex_init, pthread_mutex_destroy, pthread_mutex_lock and pthread_mutex_unlock have have also been added. Future patches will extend these functions to add features required by the POSIX specification. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D126235
2022-04-11[libc] Add a definition of pthread_attr_t and its getters and setters.Siva Chandra Reddy
Not all attributes have been added to phtread_attr_t in this patch. They will be added gradually in future patches. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D123423
2022-04-04[libc] Add pthread_mutexattr_t type and its setters and getters.Siva Chandra Reddy
A simple implementation of the getters and setters has been added. More logic can be added to them in future as required. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D122969