diff options
author | John Emmas <johne53@tiscali.co.uk> | 2019-07-29 16:56:45 +0100 |
---|---|---|
committer | John Emmas <johne53@tiscali.co.uk> | 2019-07-29 16:56:45 +0100 |
commit | bf5da033dcbbe87cb18ae1d727cb4aae6c687db0 (patch) | |
tree | 0bd7403bbbd3027e5b7efe4672843e1d57bed592 /libs/pbd/pbd/spinlock.h | |
parent | 82bdb48dabacd521f93c02b1520aec0db4996bf9 (diff) |
Another try at fixing our 'spinlock_t' compatibility
Diffstat (limited to 'libs/pbd/pbd/spinlock.h')
-rw-r--r-- | libs/pbd/pbd/spinlock.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libs/pbd/pbd/spinlock.h b/libs/pbd/pbd/spinlock.h index 2e543408df..d8706c68c9 100644 --- a/libs/pbd/pbd/spinlock.h +++ b/libs/pbd/pbd/spinlock.h @@ -20,6 +20,8 @@ #define _pbd_spinlock_h_ #include <boost/smart_ptr/detail/spinlock.hpp> +#include <cstring> + #include "pbd/libpbd_visibility.h" namespace PBD { @@ -35,10 +37,23 @@ namespace PBD { struct spinlock_t { public: - spinlock_t (); +#ifdef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED + /* C++11 non-static data member initialization, + * with non-copyable std::atomic ATOMIC_FLAG_INIT + */ + spinlock_t () : l (BOOST_DETAIL_SPINLOCK_INIT) {}; +#else + /* default C++ assign struct's first member */ + spinlock_t () + { + boost::detail::spinlock init = BOOST_DETAIL_SPINLOCK_INIT; + std::memcpy (&l, &init, sizeof (init)); + } +#endif void lock () { l.lock (); } void unlock () { l.unlock (); } bool try_lock () { return l.try_lock (); } + private: boost::detail::spinlock l; |