diff --git a/libcxx/include/functional b/libcxx/include/functional index 3e9425320fc32b..9a0ca96c4611be 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -508,10 +508,6 @@ POLICY: For non-variadic implementations, the number of arguments is limited #include <__functional_base> -#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC) -#include -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -2257,6 +2253,9 @@ template class __policy_func<_Rp(_ArgTypes...)> #if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC) +extern "C" void *_Block_copy(const void *); +extern "C" void _Block_release(const void *); + template class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> @@ -2267,14 +2266,14 @@ class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> public: _LIBCPP_INLINE_VISIBILITY explicit __func(__block_type const& __f) - : __f_(__f ? Block_copy(__f) : (__block_type)0) + : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) { } // [TODO] add && to save on a retain _LIBCPP_INLINE_VISIBILITY explicit __func(__block_type __f, const _Alloc& /* unused */) - : __f_(__f ? Block_copy(__f) : (__block_type)0) + : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) { } virtual __base<_Rp(_ArgTypes...)>* __clone() const { @@ -2291,7 +2290,7 @@ public: virtual void destroy() _NOEXCEPT { if (__f_) - Block_release(__f_); + _Block_release(__f_); __f_ = 0; } diff --git a/libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp b/libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp index 33c11651f12f5c..9a8e9389426a46 100644 --- a/libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp +++ b/libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp @@ -21,6 +21,8 @@ #include #include +#include + #include "test_macros.h" #include "count_new.h"