Compare commits

..

4 Commits

Author SHA1 Message Date
Peter Dimov
3de75e7f57 Remove unused spinlock implementations again 2025-11-14 16:11:10 +02:00
Peter Dimov
f48fe044f3 Switch back to spinlock_gcc_atomic.hpp under Clang; Clang 3.5, 3.6, clang-cl 9 have trouble with ATOMIC_FLAG_INIT 2025-11-14 15:35:13 +02:00
Peter Dimov
8a27c4de9c Revert "Remove unused spinlock implementations"
This reverts commit 9f5a48ab3b.
2025-11-14 15:29:06 +02:00
Peter Dimov
0caaead2ec Add back old Clangs to Appveyor and Drone 2025-11-14 15:11:39 +02:00
4 changed files with 123 additions and 1 deletions

View File

@@ -226,6 +226,20 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
"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 16.04 Clang 3.7",
"cppalliance/droneubuntu1604:1",

View File

@@ -21,6 +21,10 @@ environment:
TOOLSET: msvc-14.1
CXXSTD: 14,17
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
TOOLSET: msvc-14.2
CXXSTD: 14

View File

@@ -29,6 +29,16 @@
//
#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

View 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