<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/libcxx/src/atomic.cpp, branch users/koachan/spr/main.sparcias-enable-parseforallfeatures-in-matchoperandparserimpl</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[libc++] Mark a few functions in the dylib as noexcept (#94098)</title>
<updated>2024-06-12T02:18:51+00:00</updated>
<author>
<name>Nikolas Klauser</name>
<email>nikolasklauser@berlin.de</email>
</author>
<published>2024-06-12T02:18:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=4748b494e1aa47a8f9d6ea00a80d3f24f419f18a'/>
<id>4748b494e1aa47a8f9d6ea00a80d3f24f419f18a</id>
<content type='text'>
This avoids generating landing pads in some of the `atomic` functions
that will never be used, since these functions never throw exceptions.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This avoids generating landing pads in some of the `atomic` functions
that will never be used, since these functions never throw exceptions.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Fix `std::atomic::wait` ulock wait UL_COMPARE_AND_WAIT64 (#92783)</title>
<updated>2024-06-01T20:12:04+00:00</updated>
<author>
<name>Hui</name>
<email>hui.xie1990@gmail.com</email>
</author>
<published>2024-06-01T20:12:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6e22b538da4b09efb10a59582a3f43d8128ae7d1'/>
<id>6e22b538da4b09efb10a59582a3f43d8128ae7d1</id>
<content type='text'>
in `atomic::wait`, when we call the platform wait ulock_wait , we are
using UL_COMPARE_AND_WAIT. But we should use UL_COMPARE_AND_WAIT64
instead as the address we are waiting for is a 64 bit integer.

fixes https://github.com/llvm/llvm-project/issues/85107

It is rather hard to test directly because in `atomic::wait`, before
calling into the platform wait, our c++ code has some poll logic which
checks the value not changing. Thus in this patch, the test is using the
internal function.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
in `atomic::wait`, when we call the platform wait ulock_wait , we are
using UL_COMPARE_AND_WAIT. But we should use UL_COMPARE_AND_WAIT64
instead as the address we are waiting for is a 64 bit integer.

fixes https://github.com/llvm/llvm-project/issues/85107

It is rather hard to test directly because in `atomic::wait`, before
calling into the platform wait, our c++ code has some poll logic which
checks the value not changing. Thus in this patch, the test is using the
internal function.</pre>
</div>
</content>
</entry>
<entry>
<title>[libcxx][libcxxabi] Fix build for OpenBSD (#92186)</title>
<updated>2024-05-17T20:49:04+00:00</updated>
<author>
<name>John Ericson</name>
<email>John.Ericson@Obsidian.Systems</email>
</author>
<published>2024-05-17T20:49:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=af7467ce9f447d6fe977b73db1f03a18d6bbd511'/>
<id>af7467ce9f447d6fe977b73db1f03a18d6bbd511</id>
<content type='text'>
- No indirect syscalls on OpenBSD. Instead there is a `futex` function
which issues a direct syscall.

- Monotonic clock is available despite the full POSIX suite of timers
not being available in its entirety.

  See https://lists.boost.org/boost-bugs/2015/07/41690.php and
  https://github.com/boostorg/log/commit/c98b1f459add14d5ce3e9e63e2469064601d7f71
  for a description of an analogous problem and fix for Boost.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- No indirect syscalls on OpenBSD. Instead there is a `futex` function
which issues a direct syscall.

- Monotonic clock is available despite the full POSIX suite of timers
not being available in its entirety.

  See https://lists.boost.org/boost-bugs/2015/07/41690.php and
  https://github.com/boostorg/log/commit/c98b1f459add14d5ce3e9e63e2469064601d7f71
  for a description of an analogous problem and fix for Boost.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Refactor the predicate taking variant of `__cxx_atomic_wait` (#80596)</title>
<updated>2024-02-19T14:28:51+00:00</updated>
<author>
<name>Jan Kokemüller</name>
<email>jan.kokemueller@gmail.com</email>
</author>
<published>2024-02-19T14:28:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=95ebf2be0e6600465a4d0f4e7d81c7ded0559fba'/>
<id>95ebf2be0e6600465a4d0f4e7d81c7ded0559fba</id>
<content type='text'>
This is a follow-up PR to
&lt;https://github.com/llvm/llvm-project/pull/79265&gt;. It aims to be a
gentle refactoring of the `__cxx_atomic_wait` function that takes a
predicate.

The key idea here is that this function's signature is changed to look
like this (`std::function` used just for clarity):

```c++
__cxx_atomic_wait_fn(Atp*, std::function&lt;bool(Tp &amp;)&gt; poll, memory_order __order);
```

...where `Tp` is the corresponding `value_type` to the atomic variable
type `Atp`. The function's semantics are similar to `atomic`s `.wait()`,
but instead of having a hardcoded predicate (is the loaded value unequal
to `old`?) the predicate is specified explicitly.

The `poll` function may change its argument, and it is very important
that if it returns `false`, it leaves its current understanding of the
atomic's value in the argument. Internally, `__cxx_atomic_wait_fn`
dispatches to two waiting mechanisms, depending on the type of the
atomic variable:

1. If the atomic variable can be waited on directly (for example,
Linux's futex mechanism only supports waiting on 32 bit long variables),
the value of the atomic variable (which `poll` made its decision on) is
then given to the underlying system wait function (e.g. futex).
2. If the atomic variable can not be waited on directly, there is a
global pool of atomics that are used for this task. The ["eventcount"
pattern](&lt;https://gist.github.com/mratsim/04a29bdd98d6295acda4d0677c4d0041&gt;)
is employed to make this possible.

The eventcount pattern needs a "monitor" variable which is read before
the condition is checked another time. libcxx has the
`__libcpp_atomic_monitor` function for this. However, this function only
has to be called in case "2", i.e. when the eventcount is actually used.
In case "1", the futex is used directly, so the monitor must be the
value of the atomic variable that the `poll` function made its decision
on to continue blocking. Previously, `__libcpp_atomic_monitor` was
_also_ used in case "1". This was the source of the ABA style bug that
PR#79265 fixed.

However, the solution in PR#79265 has some disadvantages:

- It exposes internals such as `cxx_contention_t` or the fact that
`__libcpp_thread_poll_with_backoff` needs two functions to higher level
constructs such as `semaphore`.
- It doesn't prevent consumers calling `__cxx_atomic_wait` in an error
prone way, i.e. by providing to it a predicate that doesn't take an
argument. This makes ABA style issues more likely to appear.

Now, `__cxx_atomic_wait_fn` takes just _one_ function, which is then
transformed into the `poll` and `backoff` callables needed by
`__libcpp_thread_poll_with_backoff`.

Aside from the `__cxx_atomic_wait` changes, the only other change is the
weakening of the initial atomic load of `semaphore`'s `try_acquire` into
`memory_order_relaxed` and the CAS inside the loop is changed from
`strong` to `weak`. Both weakenings should be fine, since the CAS is
called in a loop, and the "acquire" semantics of `try_acquire` come from
the CAS, not from the initial load.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a follow-up PR to
&lt;https://github.com/llvm/llvm-project/pull/79265&gt;. It aims to be a
gentle refactoring of the `__cxx_atomic_wait` function that takes a
predicate.

The key idea here is that this function's signature is changed to look
like this (`std::function` used just for clarity):

```c++
__cxx_atomic_wait_fn(Atp*, std::function&lt;bool(Tp &amp;)&gt; poll, memory_order __order);
```

...where `Tp` is the corresponding `value_type` to the atomic variable
type `Atp`. The function's semantics are similar to `atomic`s `.wait()`,
but instead of having a hardcoded predicate (is the loaded value unequal
to `old`?) the predicate is specified explicitly.

The `poll` function may change its argument, and it is very important
that if it returns `false`, it leaves its current understanding of the
atomic's value in the argument. Internally, `__cxx_atomic_wait_fn`
dispatches to two waiting mechanisms, depending on the type of the
atomic variable:

1. If the atomic variable can be waited on directly (for example,
Linux's futex mechanism only supports waiting on 32 bit long variables),
the value of the atomic variable (which `poll` made its decision on) is
then given to the underlying system wait function (e.g. futex).
2. If the atomic variable can not be waited on directly, there is a
global pool of atomics that are used for this task. The ["eventcount"
pattern](&lt;https://gist.github.com/mratsim/04a29bdd98d6295acda4d0677c4d0041&gt;)
is employed to make this possible.

The eventcount pattern needs a "monitor" variable which is read before
the condition is checked another time. libcxx has the
`__libcpp_atomic_monitor` function for this. However, this function only
has to be called in case "2", i.e. when the eventcount is actually used.
In case "1", the futex is used directly, so the monitor must be the
value of the atomic variable that the `poll` function made its decision
on to continue blocking. Previously, `__libcpp_atomic_monitor` was
_also_ used in case "1". This was the source of the ABA style bug that
PR#79265 fixed.

However, the solution in PR#79265 has some disadvantages:

- It exposes internals such as `cxx_contention_t` or the fact that
`__libcpp_thread_poll_with_backoff` needs two functions to higher level
constructs such as `semaphore`.
- It doesn't prevent consumers calling `__cxx_atomic_wait` in an error
prone way, i.e. by providing to it a predicate that doesn't take an
argument. This makes ABA style issues more likely to appear.

Now, `__cxx_atomic_wait_fn` takes just _one_ function, which is then
transformed into the `poll` and `backoff` callables needed by
`__libcpp_thread_poll_with_backoff`.

Aside from the `__cxx_atomic_wait` changes, the only other change is the
weakening of the initial atomic load of `semaphore`'s `try_acquire` into
`memory_order_relaxed` and the CAS inside the loop is changed from
`strong` to `weak`. Both weakenings should be fine, since the CAS is
called in a loop, and the "acquire" semantics of `try_acquire` come from
the CAS, not from the initial load.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Format the code base (#74334)</title>
<updated>2023-12-18T19:01:33+00:00</updated>
<author>
<name>Louis Dionne</name>
<email>ldionne.2@gmail.com</email>
</author>
<published>2023-12-18T19:01:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7'/>
<id>9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7</id>
<content type='text'>
This patch runs clang-format on all of libcxx/include and libcxx/src, in
accordance with the RFC discussed at [1]. Follow-up patches will format
the benchmarks, the test suite and remaining parts of the code. I'm
splitting this one into its own patch so the diff is a bit easier to
review.

This patch was generated with:

   find libcxx/include libcxx/src -type f \
      | grep -v 'module.modulemap.in' \
      | grep -v 'CMakeLists.txt' \
      | grep -v 'README.txt' \
      | grep -v 'libcxx.imp' \
      | grep -v '__config_site.in' \
      | xargs clang-format -i

A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh
to help resolve merge and rebase issues across these formatting changes.

[1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch runs clang-format on all of libcxx/include and libcxx/src, in
accordance with the RFC discussed at [1]. Follow-up patches will format
the benchmarks, the test suite and remaining parts of the code. I'm
splitting this one into its own patch so the diff is a bit easier to
review.

This patch was generated with:

   find libcxx/include libcxx/src -type f \
      | grep -v 'module.modulemap.in' \
      | grep -v 'CMakeLists.txt' \
      | grep -v 'README.txt' \
      | grep -v 'libcxx.imp' \
      | grep -v '__config_site.in' \
      | xargs clang-format -i

A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh
to help resolve merge and rebase issues across these formatting changes.

[1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Handle threads-related .cpp files like we do all other source files (#71100)</title>
<updated>2023-11-06T00:08:24+00:00</updated>
<author>
<name>Louis Dionne</name>
<email>ldionne.2@gmail.com</email>
</author>
<published>2023-11-06T00:08:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=cf7d4f543c73c2707e0c53bae1e7b8419e12b871'/>
<id>cf7d4f543c73c2707e0c53bae1e7b8419e12b871</id>
<content type='text'>
Source files in libc++ are added to the CMake targets only if they are
required by the configuration. We do this pretty consistently for all
configurations like no-filesystem, no-random-device, etc. but we didn't
do it for no-threads. This patch makes this consistent for no-threads,
which is helpful in reducing the amount of work required to port libc++
to some platforms without threads.

Indeed, with the previous approach, several threads-related source files
would end up including headers that might fail to compile properly on
some platforms. This issue is sidestepped entirely by making the
approach for no-threads consistent with the other configurations.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Source files in libc++ are added to the CMake targets only if they are
required by the configuration. We do this pretty consistently for all
configurations like no-filesystem, no-random-device, etc. but we didn't
do it for no-threads. This patch makes this consistent for no-threads,
which is helpful in reducing the amount of work required to port libc++
to some platforms without threads.

Indeed, with the previous approach, several threads-related source files
would end up including headers that might fail to compile properly on
some platforms. This issue is sidestepped entirely by making the
approach for no-threads consistent with the other configurations.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Fix warnings when compiling libc++ for Windows with clang-cl /W4</title>
<updated>2023-09-08T15:51:20+00:00</updated>
<author>
<name>Colin Finck</name>
<email>colin@reactos.org</email>
</author>
<published>2023-09-08T15:50:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=5f29ed16548159a575068214ca95cae6f0ad24e7'/>
<id>5f29ed16548159a575068214ca95cae6f0ad24e7</id>
<content type='text'>
Differential Revision: https://reviews.llvm.org/D96408
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Differential Revision: https://reviews.llvm.org/D96408
</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Make sure we use __ulock on Apple platforms</title>
<updated>2023-07-07T21:15:22+00:00</updated>
<author>
<name>Louis Dionne</name>
<email>ldionne.2@gmail.com</email>
</author>
<published>2023-07-07T12:57:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b5a9f9f6dc06095c399701de2c6ca976b40bb09c'/>
<id>b5a9f9f6dc06095c399701de2c6ca976b40bb09c</id>
<content type='text'>
We forgot to include the header, which means that _LIBCPP_USE_ULOCK was
always undefined and we'd always use the fallback. Note that this doesn't
seem to fix https://github.com/llvm/llvm-project/issues/63737.

Differential Revision: https://reviews.llvm.org/D154718
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We forgot to include the header, which means that _LIBCPP_USE_ULOCK was
always undefined and we'd always use the fallback. Note that this doesn't
seem to fix https://github.com/llvm/llvm-project/issues/63737.

Differential Revision: https://reviews.llvm.org/D154718
</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++][NFC] Granularise &lt;thread&gt; header</title>
<updated>2023-06-17T11:28:52+00:00</updated>
<author>
<name>Hui</name>
<email>hui.xie0621@gmail.com</email>
</author>
<published>2023-05-31T09:49:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=cea4285949b53acd1457be4f503f4b26e096132c'/>
<id>cea4285949b53acd1457be4f503f4b26e096132c</id>
<content type='text'>
- This was to make implementing jthread easier and requested in https://reviews.llvm.org/D151559

Differential Revision: https://reviews.llvm.org/D151792
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- This was to make implementing jthread easier and requested in https://reviews.llvm.org/D151559

Differential Revision: https://reviews.llvm.org/D151792
</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] [FreeBSD] correct 64-bit test</title>
<updated>2023-03-02T02:21:31+00:00</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2023-03-01T23:39:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0fe1012f8ee2f05c7890dced58a4f700de44ec19'/>
<id>0fe1012f8ee2f05c7890dced58a4f700de44ec19</id>
<content type='text'>
Using __SIZEOF_LONG__ == 8 rather than __LP64__ is needed so we use umtx
on CHERI.  I accidentally landed an older diff.

Fixes: 17ecbb3ea6ff0ae716dd524c0e2bf75a4815c95b
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Using __SIZEOF_LONG__ == 8 rather than __LP64__ is needed so we use umtx
on CHERI.  I accidentally landed an older diff.

Fixes: 17ecbb3ea6ff0ae716dd524c0e2bf75a4815c95b
</pre>
</div>
</content>
</entry>
</feed>
