[libcxx-commits] [libcxx] [libc++] Drop dependency on __functional/operations.h from <atomic> (PR #117302)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 22 00:35:15 PST 2024


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/117302

This should reduce the preprocessed size of the atomic header and other headers in the synchronization library.

>From f08cea6812c5b1664e4eef13f8be96a241fb1b09 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Fri, 22 Nov 2024 09:33:24 +0100
Subject: [PATCH] [libc++] Drop dependency on __functional/operations.h from
 <atomic>

This should reduce the preprocessed size of the atomic header and other
headers in the synchronization library.
---
 libcxx/include/__atomic/atomic.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libcxx/include/__atomic/atomic.h b/libcxx/include/__atomic/atomic.h
index ae0475693f22b4..d83719c8733d7e 100644
--- a/libcxx/include/__atomic/atomic.h
+++ b/libcxx/include/__atomic/atomic.h
@@ -16,7 +16,6 @@
 #include <__atomic/memory_order.h>
 #include <__config>
 #include <__cstddef/ptrdiff_t.h>
-#include <__functional/operations.h>
 #include <__memory/addressof.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/is_floating_point.h>
@@ -376,7 +375,8 @@ struct atomic<_Tp> : __atomic_base<_Tp> {
     auto __builtin_op = [](auto __a, auto __builtin_operand, auto __order) {
       return std::__cxx_atomic_fetch_add(__a, __builtin_operand, __order);
     };
-    return __rmw_op(std::forward<_This>(__self), __operand, __m, std::plus<>{}, __builtin_op);
+    auto __plus = [](auto __a, auto __b) { return __a + __b; };
+    return __rmw_op(std::forward<_This>(__self), __operand, __m, __plus, __builtin_op);
   }
 
   template <class _This>
@@ -384,7 +384,8 @@ struct atomic<_Tp> : __atomic_base<_Tp> {
     auto __builtin_op = [](auto __a, auto __builtin_operand, auto __order) {
       return std::__cxx_atomic_fetch_sub(__a, __builtin_operand, __order);
     };
-    return __rmw_op(std::forward<_This>(__self), __operand, __m, std::minus<>{}, __builtin_op);
+    auto __minus = [](auto __a, auto __b) { return __a - __b; };
+    return __rmw_op(std::forward<_This>(__self), __operand, __m, __minus, __builtin_op);
   }
 
 public:



More information about the libcxx-commits mailing list