<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/libcxx/src/thread.cpp, branch main</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++][Windows] Enable thread::hardware_concurrency to support more than 64 processors (#168229)</title>
<updated>2025-11-21T10:43:35+00:00</updated>
<author>
<name>Yexuan Xiao</name>
<email>bizwen@nykz.org</email>
</author>
<published>2025-11-21T10:43:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=5a3c2573a9644efe3384c4144b119148088b48ef'/>
<id>5a3c2573a9644efe3384c4144b119148088b48ef</id>
<content type='text'>
Starting with Windows 11, processes can utilize more than 64 processors
by default, but GetSystemInfo can only report a maximum of 64. Starting
with Windows Vista, GetActiveProcessorCount accurately retrieves the
total number of processors on the current system. I’ve implemented
similar improvements to Microsoft STL. The following links contain
additional background information:
https://github.com/microsoft/STL/issues/5453,
https://github.com/microsoft/STL/pull/5459 (note: Reason STL uses the
more complex GetLogicalProcessorInformationEx:
https://github.com/microsoft/STL/pull/5459#discussion_r2072242241.).</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Starting with Windows 11, processes can utilize more than 64 processors
by default, but GetSystemInfo can only report a maximum of 64. Starting
with Windows Vista, GetActiveProcessorCount accurately retrieves the
total number of processors on the current system. I’ve implemented
similar improvements to Microsoft STL. The following links contain
additional background information:
https://github.com/microsoft/STL/issues/5453,
https://github.com/microsoft/STL/pull/5459 (note: Reason STL uses the
more complex GetLogicalProcessorInformationEx:
https://github.com/microsoft/STL/pull/5459#discussion_r2072242241.).</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[libc++] Introduce ABI sensitive areas to avoid requiring _LIBCPP_HIDE_FROM_ABI everywhere (#131156)" (#141756)</title>
<updated>2025-05-28T16:04:51+00:00</updated>
<author>
<name>James Y Knight</name>
<email>jyknight@google.com</email>
</author>
<published>2025-05-28T16:04:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c3656afdf111901977792c1d9589cb32ee1b6015'/>
<id>c3656afdf111901977792c1d9589cb32ee1b6015</id>
<content type='text'>
This reverts commit c861fe8a71e64f3d2108c58147e7375cd9314521.

Unfortunately, this use of hidden visibility attributes causes
user-defined specializations of standard-library types to also be marked
hidden by default, which is incorrect. See discussion thread on #131156.

...and also reverts the follow-up commits:

Revert "[libc++] Add explicit ABI annotations to functions from the block runtime declared in &lt;__functional/function.h&gt; (#140592)"
This reverts commit 3e4c9dc299c35155934688184319d391b298fff7.

Revert "[libc++] Make ABI annotations explicit for windows-specific code (#140507)"
This reverts commit f73287e623a6c2e4a3485832bc3e10860cd26eb5.

Revert "[libc++][NFC] Replace a few "namespace std" with the correct macro (#140510)"
This reverts commit 1d411f27c769a32cb22ce50b9dc4421e34fd40dd.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit c861fe8a71e64f3d2108c58147e7375cd9314521.

Unfortunately, this use of hidden visibility attributes causes
user-defined specializations of standard-library types to also be marked
hidden by default, which is incorrect. See discussion thread on #131156.

...and also reverts the follow-up commits:

Revert "[libc++] Add explicit ABI annotations to functions from the block runtime declared in &lt;__functional/function.h&gt; (#140592)"
This reverts commit 3e4c9dc299c35155934688184319d391b298fff7.

Revert "[libc++] Make ABI annotations explicit for windows-specific code (#140507)"
This reverts commit f73287e623a6c2e4a3485832bc3e10860cd26eb5.

Revert "[libc++][NFC] Replace a few "namespace std" with the correct macro (#140510)"
This reverts commit 1d411f27c769a32cb22ce50b9dc4421e34fd40dd.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Introduce ABI sensitive areas to avoid requiring _LIBCPP_HIDE_FROM_ABI everywhere (#131156)</title>
<updated>2025-05-18T13:47:05+00:00</updated>
<author>
<name>Nikolas Klauser</name>
<email>nikolasklauser@berlin.de</email>
</author>
<published>2025-05-18T13:47:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c861fe8a71e64f3d2108c58147e7375cd9314521'/>
<id>c861fe8a71e64f3d2108c58147e7375cd9314521</id>
<content type='text'>
This patch introduces `_LIBCPP_{BEGIN,END}_EXPLICIT_ABI_ANNOTATIONS`,
which allow us to have implicit annotations for most functions, and just
where it's not "hide_from_abi everything" we add explicit annotations.
This allows us to drop the `_LIBCPP_HIDE_FROM_ABI` macro from most
functions in libc++.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch introduces `_LIBCPP_{BEGIN,END}_EXPLICIT_ABI_ANNOTATIONS`,
which allow us to have implicit annotations for most functions, and just
where it's not "hide_from_abi everything" we add explicit annotations.
This allows us to drop the `_LIBCPP_HIDE_FROM_ABI` macro from most
functions in libc++.</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Fix missing #includes (#130536)</title>
<updated>2025-05-12T20:36:10+00:00</updated>
<author>
<name>Matt</name>
<email>mattstark75@gmail.com</email>
</author>
<published>2025-05-12T20:36:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=769c6a95aee701f09f60c6f887b16093c94786e7'/>
<id>769c6a95aee701f09f60c6f887b16093c94786e7</id>
<content type='text'>
Adds missing includes that were detected when I tried to build libc++ as
a module.

Working towards #127012</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Adds missing includes that were detected when I tried to build libc++ as
a module.

Working towards #127012</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Qualify calls to nullary functions like __throw_foo (#122465)</title>
<updated>2025-02-21T12:59:46+00:00</updated>
<author>
<name>Louis Dionne</name>
<email>ldionne.2@gmail.com</email>
</author>
<published>2025-02-21T12:59:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=5e26fb169936ca1e24da6698ce895fec99af06c2'/>
<id>5e26fb169936ca1e24da6698ce895fec99af06c2</id>
<content type='text'>
This is technically not necessary in most cases to prevent issues with ADL,
but let's be consistent. This allows us to remove the libcpp-qualify-declval
clang-tidy check, which is now enforced by the robust-against-adl clang-tidy check.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is technically not necessary in most cases to prevent issues with ADL,
but let's be consistent. This allows us to remove the libcpp-qualify-declval
clang-tidy check, which is now enforced by the robust-against-adl clang-tidy check.</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++][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++] Hold mutex lock while notify_all is called at notify_all_at_thread_exit</title>
<updated>2023-01-11T22:01:21+00:00</updated>
<author>
<name>Arthur O'Dwyer</name>
<email>arthur.j.odwyer@gmail.com</email>
</author>
<published>2023-01-10T18:29:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=64fc3cd55d586498dd21c5b3cfaa755793913772'/>
<id>64fc3cd55d586498dd21c5b3cfaa755793913772</id>
<content type='text'>
Releasing the mutex before the call to notify_all is an optimization.
This optimization cannot be used here. The thread waiting on the
condition might destroy the associated resources — mutex + condition
variable — and the notifier thread will access an destroyed variable
— the condition variable. In fact, notify_all_at_thread_exit is meant
exactly to join on detached threads, and the waiting thread doesn't
expect for the notifier thread to access any further shared resources,
making this scenario very likely to happen. The waiting thread might
awake spuriously on the release of the mutex lock. The reorder is
necessary to prevent this race.

Further details can be found at https://cplusplus.github.io/LWG/issue3343.

Differential Revision: https://reviews.llvm.org/D105758
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Releasing the mutex before the call to notify_all is an optimization.
This optimization cannot be used here. The thread waiting on the
condition might destroy the associated resources — mutex + condition
variable — and the notifier thread will access an destroyed variable
— the condition variable. In fact, notify_all_at_thread_exit is meant
exactly to join on detached threads, and the waiting thread doesn't
expect for the notifier thread to access any further shared resources,
making this scenario very likely to happen. The waiting thread might
awake spuriously on the release of the mutex lock. The reorder is
necessary to prevent this race.

Further details can be found at https://cplusplus.github.io/LWG/issue3343.

Differential Revision: https://reviews.llvm.org/D105758
</pre>
</div>
</content>
</entry>
<entry>
<title>[libc++] Avoid lifetime UB in __thread_local_data()</title>
<updated>2022-04-25T21:56:44+00:00</updated>
<author>
<name>Vitaly Buka</name>
<email>vitalybuka@google.com</email>
</author>
<published>2022-04-01T04:58:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0c99575df4a9395e32bf1121c103616ba812accb'/>
<id>0c99575df4a9395e32bf1121c103616ba812accb</id>
<content type='text'>
Detected on many lld tests with -fsanitize-memory-use-after-dtor.
Also https://lab.llvm.org/buildbot/#/builders/sanitizer-x86_64-linux-fast after D122869 will report a lot of them.

Threads may outlive static variables. Even if ~__thread_specific_ptr() does nothing, lifetime of members ends with ~ and accessing the value is UB https://eel.is/c++draft/basic.life#1

```
==9214==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x557e1cec4539 in __libcpp_tls_set ../include/c++/v1/__threading_support:428:12
    #1 0x557e1cec4539 in set_pointer ../include/c++/v1/thread:196:5
    #2 0x557e1cec4539 in void* std::__msan::__thread_proxy&lt;
      std::__msan::tuple&lt;...&gt;, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()&gt; &gt;(void*) ../include/c++/v1/thread:285:27

  Memory was marked as uninitialized
    #0 0x557e10a0759d in __sanitizer_dtor_callback compiler-rt/lib/msan/msan_interceptors.cpp:940:5
    #1 0x557e1d8c478d in std::__msan::__thread_specific_ptr&lt;std::__msan::__thread_struct&gt;::~__thread_specific_ptr() libcxx/include/thread:188:1
    #2 0x557e10a07dc0 in MSanCxaAtExitWrapper(void*) compiler-rt/lib/msan/msan_interceptors.cpp:1151:3
```

The test needs D123979 or  -fsanitize-memory-param-retval enabled by default.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122864
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Detected on many lld tests with -fsanitize-memory-use-after-dtor.
Also https://lab.llvm.org/buildbot/#/builders/sanitizer-x86_64-linux-fast after D122869 will report a lot of them.

Threads may outlive static variables. Even if ~__thread_specific_ptr() does nothing, lifetime of members ends with ~ and accessing the value is UB https://eel.is/c++draft/basic.life#1

```
==9214==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x557e1cec4539 in __libcpp_tls_set ../include/c++/v1/__threading_support:428:12
    #1 0x557e1cec4539 in set_pointer ../include/c++/v1/thread:196:5
    #2 0x557e1cec4539 in void* std::__msan::__thread_proxy&lt;
      std::__msan::tuple&lt;...&gt;, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()&gt; &gt;(void*) ../include/c++/v1/thread:285:27

  Memory was marked as uninitialized
    #0 0x557e10a0759d in __sanitizer_dtor_callback compiler-rt/lib/msan/msan_interceptors.cpp:940:5
    #1 0x557e1d8c478d in std::__msan::__thread_specific_ptr&lt;std::__msan::__thread_struct&gt;::~__thread_specific_ptr() libcxx/include/thread:188:1
    #2 0x557e10a07dc0 in MSanCxaAtExitWrapper(void*) compiler-rt/lib/msan/msan_interceptors.cpp:1151:3
```

The test needs D123979 or  -fsanitize-memory-param-retval enabled by default.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D122864
</pre>
</div>
</content>
</entry>
</feed>
