summaryrefslogtreecommitdiff
path: root/libc/src/__support/threads/thread.cpp
AgeCommit message (Collapse)Author
2025-01-08[libc] Fix return value of __cxa_thread_atexit_impl function. (#122171)Alexey Samsonov
This has been added in 0071a79532e8d664b734956a431d8c8c942cc25e to support TLS destructors. Return value of __cxa_thread_atexit is supposed to be the same as std::atexit - zero on success, non-zero on failure. Update the code to do just that (also be consistent with llvm-libc's existing atexit / at_quick_exit implementations).
2024-08-02[libc] inline thread self (#101739)Schrodinger ZHU Yifan
The codegen for non-inlined version is "quite ugly" as it emits some checks to make sure the initialization routine is properly executed because the compiler does not see how the TLS object is initialized. This leads to some `callq 0x0` junk in the final outputs. For codegen details, see https://godbolt.org/z/rb5qYj3vY.
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-05-31[libc] rework mutex (#92168)Schrodinger ZHU Yifan
2024-05-09[libc] Replace `MutexLock` with `cpp::lock_guard` (#89340)Vlad Mishel
This PR address issue #89002. #### Changes in this PR * Added a simple implementation of `cpp::lock_guard` (an equivalent of `std::lock_guard`) in libc/src/__support/CPP inspired by the libstdc++ implementation * Added tests for `cpp::lock_guard` in /libc/test/src/__support/CPP/mutex_test.cpp * Replaced all references to `MutexLock` with `cpp::lock_guard` --------- Co-authored-by: Guillaume Chatelet <gchatelet@google.com>
2024-05-07[libc] clean up futex usage (#91163)Schrodinger ZHU Yifan
# Motivation Futex syscalls are widely used in our codebase as synchronization mechanism. Hence, it may be worthy to abstract out the most common routines (wait and wake). On the other hand, C++20 also provides `std::atomic_notify_one/std::atomic_wait/std::atomic_notify_all` which align with such functionalities. This PR introduces `Futex` as a subtype of `cpp::Atomic<FutexWordType>` with additional `notify_one/notify_all/wait` operations. Providing such wrappers also make future porting easier. For example, FreeBSD's `_umtx_op` and Darwin's `ulock` can be wrapped in a similar manner. ### Similar Examples 1. [bionic futex](https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/bionic/bionic_futex.cpp) 2. [futex in Rust's std](https://github.com/rust-lang/rust/blob/8cef37dbb67e9c80702925f19cf298c4203991e4/library/std/src/sys/pal/unix/futex.rs#L21)
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-08-07[libc][cleanup] Fix most conversion warningsMichael Jones
This patch is large, but is almost entirely just adding casts to calls to syscall_impl. Much of the work was done programatically, with human checking when the syntax or types got confusing. Reviewed By: mcgrathr Differential Revision: https://reviews.llvm.org/D156950
2023-05-25[libc] Add macro LIBC_THREAD_LOCAL.Siva Chandra Reddy
It resolves to thread_local on all platform except for the GPUs on which it resolves to nothing. The use of thread_local in the source code has been replaced with the new macro. Reviewed By: jhuber6 Differential Revision: https://reviews.llvm.org/D151486
2023-04-19[LIBC] Fix incorrect behavior with pthread_key_t when value was nullptrNoah Goldstein
We should not call destructor if value is nullptr. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D148291
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-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-07-09[libc][NFC] Remove the now used thread_attrib target.Siva Chandra Reddy