[libc++] Fix CI and Linux failures after landing D68480
authorLouis Dionne <ldionne@apple.com>
Mon, 24 Feb 2020 16:39:48 +0000 (11:39 -0500)
committerLouis Dionne <ldionne@apple.com>
Mon, 24 Feb 2020 16:58:25 +0000 (11:58 -0500)
- 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

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

index fef172c..9480225 100644 (file)
@@ -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)
index 0cbd7c0..56d8026 100644 (file)
@@ -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
@@ -1516,11 +1524,20 @@ _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);
 }
 
index 8301cbf..e646b86 100644 (file)
 {'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'}
index 4c225a5..ba6d694 100644 (file)
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// UNSUPPORTED: libcpp-has-no-threads
+
 // <atomic>
 
 // Test nested types