mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-11-15 23:09:41 +01:00
Compare commits
4 Commits
master
...
feature/is
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3de75e7f57 | ||
|
|
f48fe044f3 | ||
|
|
8a27c4de9c | ||
|
|
0caaead2ec |
@@ -226,6 +226,20 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
|||||||
"g++-15-multilib",
|
"g++-15-multilib",
|
||||||
),
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 Clang 3.5",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '11' },
|
||||||
|
"clang-3.5",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 Clang 3.6",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '11,14' },
|
||||||
|
"clang-3.6",
|
||||||
|
),
|
||||||
|
|
||||||
linux_pipeline(
|
linux_pipeline(
|
||||||
"Linux 16.04 Clang 3.7",
|
"Linux 16.04 Clang 3.7",
|
||||||
"cppalliance/droneubuntu1604:1",
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ environment:
|
|||||||
TOOLSET: msvc-14.1
|
TOOLSET: msvc-14.1
|
||||||
CXXSTD: 14,17
|
CXXSTD: 14,17
|
||||||
ADDRMD: 32,64
|
ADDRMD: 32,64
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
TOOLSET: clang-win
|
||||||
|
CXXSTD: 14,17,latest
|
||||||
|
ADDRMD: 64
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
TOOLSET: msvc-14.2
|
TOOLSET: msvc-14.2
|
||||||
CXXSTD: 14
|
CXXSTD: 14
|
||||||
|
|||||||
@@ -29,6 +29,16 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <boost/smart_ptr/detail/deprecated_macros.hpp>
|
#include <boost/smart_ptr/detail/deprecated_macros.hpp>
|
||||||
#include <boost/smart_ptr/detail/spinlock_std_atomic.hpp>
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
|
||||||
|
// Old Clang versions have trouble with ATOMIC_FLAG_INIT
|
||||||
|
# include <boost/smart_ptr/detail/spinlock_gcc_atomic.hpp>
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# include <boost/smart_ptr/detail/spinlock_std_atomic.hpp>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED
|
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_HPP_INCLUDED
|
||||||
|
|||||||
94
include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp
Normal file
94
include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ATOMIC_HPP_INCLUDED
|
||||||
|
#define BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ATOMIC_HPP_INCLUDED
|
||||||
|
|
||||||
|
// MS compatible compilers support #pragma once
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||||
|
# pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Copyright 2008, 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/smart_ptr/detail/yield_k.hpp>
|
||||||
|
|
||||||
|
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
||||||
|
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
BOOST_PRAGMA_MESSAGE("Using __atomic spinlock")
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
class spinlock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// `bool` alignment is required for Apple PPC32
|
||||||
|
// https://github.com/boostorg/smart_ptr/issues/105
|
||||||
|
// https://github.com/PurpleI2P/i2pd/issues/1726
|
||||||
|
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107590
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
unsigned char v_;
|
||||||
|
bool align_;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool try_lock()
|
||||||
|
{
|
||||||
|
return __atomic_test_and_set( &v_, __ATOMIC_ACQUIRE ) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lock()
|
||||||
|
{
|
||||||
|
for( unsigned k = 0; !try_lock(); ++k )
|
||||||
|
{
|
||||||
|
boost::detail::yield( k );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void unlock()
|
||||||
|
{
|
||||||
|
__atomic_clear( &v_, __ATOMIC_RELEASE );
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
class scoped_lock
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
spinlock & sp_;
|
||||||
|
|
||||||
|
scoped_lock( scoped_lock const & );
|
||||||
|
scoped_lock & operator=( scoped_lock const & );
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
explicit scoped_lock( spinlock & sp ): sp_( sp )
|
||||||
|
{
|
||||||
|
sp.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
~scoped_lock()
|
||||||
|
{
|
||||||
|
sp_.unlock();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#define BOOST_DETAIL_SPINLOCK_INIT {{0}}
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ATOMIC_HPP_INCLUDED
|
||||||
Reference in New Issue
Block a user