[PATCH 2/2] libstdc++: Simplify use_proxy_wait function

Jonathan Wakely jwakely@redhat.com
Thu Jan 8 21:44:18 GMT 2026


The __wait_args::_M_setup_proxy_wait function must only be called when
_M_obj == addr is true, so it's redundant for _M_setup_proxy_wait to
pass addr to use_proxy_wait. That address is already passed as
args._M_old anyway.

libstdc++-v3/ChangeLog:

	* src/c++20/atomic.cc (use_proxy_wait): Remove unused second
	parameter.
	(__wait_args::_M_setup_proxy_wait): Remove second argument.
	(__notify_impl): Likewise.
---

Tested x86_64-linux and x86_64-freebsd14 (just the parts that use atomic
waits).

 libstdc++-v3/src/c++20/atomic.cc | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/src/c++20/atomic.cc b/libstdc++-v3/src/c++20/atomic.cc
index 2d5842df30c3..e1a900ffdaed 100644
--- a/libstdc++-v3/src/c++20/atomic.cc
+++ b/libstdc++-v3/src/c++20/atomic.cc
@@ -280,8 +280,7 @@ namespace
 
   [[gnu::always_inline]]
   inline bool
-  use_proxy_wait([[maybe_unused]] const __wait_args_base& args,
-		 [[maybe_unused]] const void* /* addr */)
+  use_proxy_wait([[maybe_unused]] const __wait_args_base& args)
   {
 #ifdef _GLIBCXX_HAVE_PLATFORM_WAIT
     if constexpr (__platform_wait_uses_type<uint32_t>)
@@ -317,7 +316,7 @@ namespace
 bool
 __wait_args::_M_setup_proxy_wait(const void* addr)
 {
-  if (!use_proxy_wait(*this, addr)) // We can wait on this address directly.
+  if (!use_proxy_wait(*this)) // We can wait on this address directly.
     {
       // Ensure the caller set _M_obj correctly, as that's what we'll wait on:
       __glibcxx_assert(_M_obj == addr);
@@ -378,7 +377,7 @@ __notify_impl([[maybe_unused]] const void* __addr, [[maybe_unused]] bool __all,
 	      const __wait_args_base& __args)
 {
   const bool __track_contention = __args & __wait_flags::__track_contention;
-  const bool proxy_wait = use_proxy_wait(__args, __addr);
+  const bool proxy_wait = use_proxy_wait(__args);
 
   [[maybe_unused]] auto* __wait_addr
     = static_cast<const __platform_wait_t*>(__addr);
-- 
2.52.0



More information about the Libstdc++ mailing list