[all-commits] [llvm/llvm-project] ab3a9e: [libc] clean up futex usage (#91163)
Schrodinger ZHU Yifan via All-commits
all-commits at lists.llvm.org
Tue May 7 07:48:03 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ab3a9e724d87a4272782f76b90fb0872a6a86939
https://github.com/llvm/llvm-project/commit/ab3a9e724d87a4272782f76b90fb0872a6a86939
Author: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: 2024-05-07 (Tue, 07 May 2024)
Changed paths:
M libc/src/__support/threads/linux/CMakeLists.txt
M libc/src/__support/threads/linux/callonce.cpp
A libc/src/__support/threads/linux/futex_utils.h
M libc/src/__support/threads/linux/futex_word.h
M libc/src/__support/threads/linux/mutex.h
M libc/src/__support/threads/linux/thread.cpp
M libc/src/__support/threads/mutex.h
M libc/src/__support/threads/thread.cpp
M libc/src/threads/linux/CMakeLists.txt
M libc/src/threads/linux/CndVar.h
Log Message:
-----------
[libc] clean up futex usage (#91163)
# 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)
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list