[all-commits] [llvm/llvm-project] 1f613b: [libc++] refactor `cxx_atomic_wait` to make it reu...

Hui via All-commits all-commits at lists.llvm.org
Sat Mar 2 06:51:04 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1f613bce19ea78789934b2a47be8c6a13925f0fa
      https://github.com/llvm/llvm-project/commit/1f613bce19ea78789934b2a47be8c6a13925f0fa
  Author: Hui <hui.xie1990 at gmail.com>
  Date:   2024-03-02 (Sat, 02 Mar 2024)

  Changed paths:
    M libcxx/include/__atomic/atomic_base.h
    M libcxx/include/__atomic/atomic_flag.h
    M libcxx/include/__atomic/atomic_sync.h
    M libcxx/include/latch
    M libcxx/include/semaphore

  Log Message:
  -----------
  [libc++] refactor `cxx_atomic_wait` to make it reusable for atomic_ref (#81427)

The goal of this patch is to make `atomic`'s wait functions to be
reusable by `atomic_ref`.
https://github.com/llvm/llvm-project/pull/76647

First, this patch is built on top of
https://github.com/llvm/llvm-project/pull/80596 , to reduce the future
merge conflicts.

This patch made the following functions as "API"s to be used by
`atomic`, `atomic_flag`, `semaphore`, `latch`, `atomic_ref`

```
__atomic_wait
__atomic_wait_unless
__atomic_notify_one
__atomic_notify_all
```

These functions are made generic to support `atomic` type and
`atomic_ref`. There are two customisation points.

```
// How to load the value from the given type (with a memory order)
__atomic_load
```


```
// what is the contention address that the platform `wait` function is going to monitor
__atomic_contention_address
```


For `atomic_ref` (not implemented in this patch), the `load` and
`address` function will be different, because
- it does not use the "atomic abstraction layer" so the `load` operation
will be some gcc builtin
- the contention address will be the user's actual type that the
`atomic_ref` is pointing to



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