[libcxx-commits] [libcxx] b21405d - [libc++] Fix CI and Linux failures after landing D68480

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 24 09:00:08 PST 2020


Author: Louis Dionne
Date: 2020-02-24T11:58:25-05:00
New Revision: b21405d1cd088d7d7088479861fabd55f998bf6b

URL: https://github.com/llvm/llvm-project/commit/b21405d1cd088d7d7088479861fabd55f998bf6b
DIFF: https://github.com/llvm/llvm-project/commit/b21405d1cd088d7d7088479861fabd55f998bf6b.diff

LOG: [libc++] Fix CI and Linux failures after landing D68480

- Avoid using C++11-and-later features in <atomic>:
  Historically, we've supported <atomic> in C++03, so we can't use C++11
  features in that header. This is something we really need to change,
  since our implementation of <atomic> is starting to accumulate technical
  debt because of that.
- Mark a test as unsupported on single threaded systems
- Add missing symbols to the Linux ABI list

Added: 
    

Modified: 
    libcxx/include/__threading_support
    libcxx/include/atomic
    libcxx/lib/abi/x86_64-unknown-linux-gnu.v1.abilist
    libcxx/test/std/atomics/types.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support
index fef172c70ea7..948022554703 100644
--- a/libcxx/include/__threading_support
+++ b/libcxx/include/__threading_support
@@ -507,7 +507,7 @@ bool __libcpp_timed_backoff_policy::operator()(chrono::nanoseconds __elapsed) co
     return false;
 }
 
-static constexpr int __libcpp_polling_count = 64;
+static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64;
 
 template<class _Fn, class _BFn>
 bool __libcpp_thread_poll_with_backoff(_Fn && __f, _BFn && __bf, chrono::nanoseconds __max_elapsed)

diff  --git a/libcxx/include/atomic b/libcxx/include/atomic
index 0cbd7c0876bf..56d8026c4e4f 100644
--- a/libcxx/include/atomic
+++ b/libcxx/include/atomic
@@ -1482,9 +1482,11 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t);
 
 template <class _Atp, class _Fn>
-_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Fn && __test_fn)
-{
-    auto const __libcpp_atomic_wait_backoff = [=](chrono::nanoseconds __elapsed) -> bool {
+struct __libcpp_atomic_wait_backoff_impl {
+    _Atp* __a;
+    _Fn __test_fn;
+    _LIBCPP_INLINE_VISIBILITY bool operator()(chrono::nanoseconds __elapsed) const
+    {
         if(__elapsed > chrono::microseconds(64))
         {
             auto const __monitor = __libcpp_atomic_monitor(__a);
@@ -1497,8 +1499,14 @@ _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Fn && __test_fn)
         else
             ; // poll
         return false;
-    };
-    return __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_atomic_wait_backoff);
+    }
+};
+
+template <class _Atp, class _Fn>
+_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Fn && __test_fn)
+{
+    __libcpp_atomic_wait_backoff_impl<_Atp, typename decay<_Fn>::type> __backoff_fn = {__a, __test_fn};
+    return __libcpp_thread_poll_with_backoff(__test_fn, __backoff_fn);
 }
 
 #else // _LIBCPP_HAS_NO_PLATFORM_WAIT
@@ -1515,12 +1523,21 @@ _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp*, _Fn && __test_fn)
 
 #endif // _LIBCPP_HAS_NO_PLATFORM_WAIT
 
+template <class _Atp, class _Tp>
+struct __cxx_atomic_wait_test_fn_impl {
+    _Atp* __a;
+    _Tp __val;
+    memory_order __order;
+    _LIBCPP_INLINE_VISIBILITY bool operator()() const
+    {
+        return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__a, __order), __val);
+    }
+};
+
 template <class _Atp, class _Tp>
 _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Tp const __val, memory_order __order)
 {
-    auto const __test_fn = [=]() -> bool {
-        return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__a, __order), __val);
-    };
+    __cxx_atomic_wait_test_fn_impl<_Atp, _Tp> __test_fn = {__a, __val, __order};
     return __cxx_atomic_wait(__a, __test_fn);
 }
 

diff  --git a/libcxx/lib/abi/x86_64-unknown-linux-gnu.v1.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.v1.abilist
index 8301cbfad1bf..e646b86c1998 100644
--- a/libcxx/lib/abi/x86_64-unknown-linux-gnu.v1.abilist
+++ b/libcxx/lib/abi/x86_64-unknown-linux-gnu.v1.abilist
@@ -1917,3 +1917,14 @@
 {'is_defined': False, 'name': '__cxa_rethrow_primary_exception', 'type': 'FUNC'}
 {'is_defined': False, 'name': '__cxa_throw', 'type': 'FUNC'}
 {'is_defined': False, 'name': '__cxa_uncaught_exceptions', 'type': 'FUNC'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__132__destroy_barrier_algorithm_baseEPNS_24__barrier_algorithm_baseE'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__123__libcpp_atomic_monitorEPVKv'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__123__libcpp_atomic_monitorEPVKNS_17__cxx_atomic_implIiNS_22__cxx_atomic_base_implIiEEEE'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__123__cxx_atomic_notify_allEPVKv'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__123__cxx_atomic_notify_oneEPVKv'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__134__construct_barrier_algorithm_baseERl'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__120__libcpp_atomic_waitEPVKvi'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__123__cxx_atomic_notify_allEPVKNS_17__cxx_atomic_implIiNS_22__cxx_atomic_base_implIiEEEE'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__120__libcpp_atomic_waitEPVKNS_17__cxx_atomic_implIiNS_22__cxx_atomic_base_implIiEEEEi'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__131__arrive_barrier_algorithm_baseEPNS_24__barrier_algorithm_baseEh'}
+{'is_defined': True, 'type': 'FUNC', 'name': '_ZNSt3__123__cxx_atomic_notify_oneEPVKNS_17__cxx_atomic_implIiNS_22__cxx_atomic_base_implIiEEEE'}

diff  --git a/libcxx/test/std/atomics/types.pass.cpp b/libcxx/test/std/atomics/types.pass.cpp
index 4c225a58d0ba..ba6d6945ff9e 100644
--- a/libcxx/test/std/atomics/types.pass.cpp
+++ b/libcxx/test/std/atomics/types.pass.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// UNSUPPORTED: libcpp-has-no-threads
+
 // <atomic>
 
 // Test nested types


        


More information about the libcxx-commits mailing list