diff --git a/include/boost/atomic.hpp b/include/boost/atomic.hpp index 6db5f4b..0f5883c 100644 --- a/include/boost/atomic.hpp +++ b/include/boost/atomic.hpp @@ -7,168 +7,12 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include -#include +// This header includes all Boost.Atomic public headers -#include +#include -#include -#include -#include -#include - -namespace boost { - -#ifndef BOOST_ATOMIC_CHAR_LOCK_FREE -#define BOOST_ATOMIC_CHAR_LOCK_FREE 0 +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once #endif -#ifndef BOOST_ATOMIC_CHAR16_T_LOCK_FREE -#define BOOST_ATOMIC_CHAR16_T_LOCK_FREE 0 -#endif - -#ifndef BOOST_ATOMIC_CHAR32_T_LOCK_FREE -#define BOOST_ATOMIC_CHAR32_T_LOCK_FREE 0 -#endif - -#ifndef BOOST_ATOMIC_WCHAR_T_LOCK_FREE -#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0 -#endif - -#ifndef BOOST_ATOMIC_SHORT_LOCK_FREE -#define BOOST_ATOMIC_SHORT_LOCK_FREE 0 -#endif - -#ifndef BOOST_ATOMIC_INT_LOCK_FREE -#define BOOST_ATOMIC_INT_LOCK_FREE 0 -#endif - -#ifndef BOOST_ATOMIC_LONG_LOCK_FREE -#define BOOST_ATOMIC_LONG_LOCK_FREE 0 -#endif - -#ifndef BOOST_ATOMIC_LLONG_LOCK_FREE -#define BOOST_ATOMIC_LLONG_LOCK_FREE 0 -#endif - -#ifndef BOOST_ATOMIC_POINTER_LOCK_FREE -#define BOOST_ATOMIC_POINTER_LOCK_FREE 0 -#endif - -#define BOOST_ATOMIC_ADDRESS_LOCK_FREE BOOST_ATOMIC_POINTER_LOCK_FREE - -#ifndef BOOST_ATOMIC_BOOL_LOCK_FREE -#define BOOST_ATOMIC_BOOL_LOCK_FREE 0 -#endif - -#ifndef BOOST_ATOMIC_THREAD_FENCE -#define BOOST_ATOMIC_THREAD_FENCE 0 -static inline void -atomic_thread_fence(memory_order) -{ -} -#endif - -#ifndef BOOST_ATOMIC_SIGNAL_FENCE -#define BOOST_ATOMIC_SIGNAL_FENCE 0 -static inline void -atomic_signal_fence(memory_order order) -{ - atomic_thread_fence(order); -} -#endif - -template -class atomic : public atomics::detail::base_atomic::test, sizeof(T), boost::is_signed::value > { -private: - typedef T value_type; - typedef atomics::detail::base_atomic::test, sizeof(T), boost::is_signed::value > super; -public: - atomic(void) : super() {} - explicit atomic(const value_type & v) : super(v) {} - - atomic & operator=(value_type v) volatile - { - super::operator=(v); - return *const_cast(this); - } -private: - atomic(const atomic &) /* =delete */ ; - atomic & operator=(const atomic &) /* =delete */ ; -}; - -typedef atomic atomic_char; -typedef atomic atomic_uchar; -typedef atomic atomic_schar; -typedef atomic atomic_uint8_t; -typedef atomic atomic_int8_t; -typedef atomic atomic_ushort; -typedef atomic atomic_short; -typedef atomic atomic_uint16_t; -typedef atomic atomic_int16_t; -typedef atomic atomic_uint; -typedef atomic atomic_int; -typedef atomic atomic_uint32_t; -typedef atomic atomic_int32_t; -typedef atomic atomic_ulong; -typedef atomic atomic_long; -typedef atomic atomic_uint64_t; -typedef atomic atomic_int64_t; -#ifdef BOOST_HAS_LONG_LONG -typedef atomic atomic_ullong; -typedef atomic atomic_llong; -#endif -typedef atomic atomic_address; -typedef atomic atomic_bool; - -#ifndef BOOST_ATOMIC_FLAG_LOCK_FREE -#define BOOST_ATOMIC_FLAG_LOCK_FREE 0 -class atomic_flag { -public: - atomic_flag(void) : v_(false) {} - - bool - test_and_set(memory_order order = memory_order_seq_cst) - { - return v_.exchange(true, order); - } - - void - clear(memory_order order = memory_order_seq_cst) volatile - { - v_.store(false, order); - } -private: - atomic_flag(const atomic_flag &) /* = delete */ ; - atomic_flag & operator=(const atomic_flag &) /* = delete */ ; - atomic v_; -}; -#endif - -typedef atomic atomic_char; -typedef atomic atomic_uchar; -typedef atomic atomic_schar; -typedef atomic atomic_uint8_t; -typedef atomic atomic_int8_t; -typedef atomic atomic_ushort; -typedef atomic atomic_short; -typedef atomic atomic_uint16_t; -typedef atomic atomic_int16_t; -typedef atomic atomic_uint; -typedef atomic atomic_int; -typedef atomic atomic_uint32_t; -typedef atomic atomic_int32_t; -typedef atomic atomic_ulong; -typedef atomic atomic_long; -typedef atomic atomic_uint64_t; -typedef atomic atomic_int64_t; -#ifdef BOOST_HAS_LONG_LONG -typedef atomic atomic_ullong; -typedef atomic atomic_llong; -#endif -typedef atomic atomic_address; -typedef atomic atomic_bool; - -} - #endif diff --git a/include/boost/atomic/atomic.hpp b/include/boost/atomic/atomic.hpp new file mode 100644 index 0000000..7efa257 --- /dev/null +++ b/include/boost/atomic/atomic.hpp @@ -0,0 +1,178 @@ +#ifndef BOOST_ATOMIC_ATOMIC_HPP +#define BOOST_ATOMIC_ATOMIC_HPP + +// Copyright (c) 2011 Helge Bahmann +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +#include + +#include +#include +#include +#include + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { + +#ifndef BOOST_ATOMIC_CHAR_LOCK_FREE +#define BOOST_ATOMIC_CHAR_LOCK_FREE 0 +#endif + +#ifndef BOOST_ATOMIC_CHAR16_T_LOCK_FREE +#define BOOST_ATOMIC_CHAR16_T_LOCK_FREE 0 +#endif + +#ifndef BOOST_ATOMIC_CHAR32_T_LOCK_FREE +#define BOOST_ATOMIC_CHAR32_T_LOCK_FREE 0 +#endif + +#ifndef BOOST_ATOMIC_WCHAR_T_LOCK_FREE +#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0 +#endif + +#ifndef BOOST_ATOMIC_SHORT_LOCK_FREE +#define BOOST_ATOMIC_SHORT_LOCK_FREE 0 +#endif + +#ifndef BOOST_ATOMIC_INT_LOCK_FREE +#define BOOST_ATOMIC_INT_LOCK_FREE 0 +#endif + +#ifndef BOOST_ATOMIC_LONG_LOCK_FREE +#define BOOST_ATOMIC_LONG_LOCK_FREE 0 +#endif + +#ifndef BOOST_ATOMIC_LLONG_LOCK_FREE +#define BOOST_ATOMIC_LLONG_LOCK_FREE 0 +#endif + +#ifndef BOOST_ATOMIC_POINTER_LOCK_FREE +#define BOOST_ATOMIC_POINTER_LOCK_FREE 0 +#endif + +#define BOOST_ATOMIC_ADDRESS_LOCK_FREE BOOST_ATOMIC_POINTER_LOCK_FREE + +#ifndef BOOST_ATOMIC_BOOL_LOCK_FREE +#define BOOST_ATOMIC_BOOL_LOCK_FREE 0 +#endif + +#ifndef BOOST_ATOMIC_THREAD_FENCE +#define BOOST_ATOMIC_THREAD_FENCE 0 +static inline void +atomic_thread_fence(memory_order) +{ +} +#endif + +#ifndef BOOST_ATOMIC_SIGNAL_FENCE +#define BOOST_ATOMIC_SIGNAL_FENCE 0 +static inline void +atomic_signal_fence(memory_order order) +{ + atomic_thread_fence(order); +} +#endif + +template +class atomic : public atomics::detail::base_atomic::test, sizeof(T), boost::is_signed::value > { +private: + typedef T value_type; + typedef atomics::detail::base_atomic::test, sizeof(T), boost::is_signed::value > super; +public: + atomic(void) : super() {} + explicit atomic(const value_type & v) : super(v) {} + + atomic & operator=(value_type v) volatile + { + super::operator=(v); + return *const_cast(this); + } +private: + atomic(const atomic &) /* =delete */ ; + atomic & operator=(const atomic &) /* =delete */ ; +}; + +typedef atomic atomic_char; +typedef atomic atomic_uchar; +typedef atomic atomic_schar; +typedef atomic atomic_uint8_t; +typedef atomic atomic_int8_t; +typedef atomic atomic_ushort; +typedef atomic atomic_short; +typedef atomic atomic_uint16_t; +typedef atomic atomic_int16_t; +typedef atomic atomic_uint; +typedef atomic atomic_int; +typedef atomic atomic_uint32_t; +typedef atomic atomic_int32_t; +typedef atomic atomic_ulong; +typedef atomic atomic_long; +typedef atomic atomic_uint64_t; +typedef atomic atomic_int64_t; +#ifdef BOOST_HAS_LONG_LONG +typedef atomic atomic_ullong; +typedef atomic atomic_llong; +#endif +typedef atomic atomic_address; +typedef atomic atomic_bool; + +#ifndef BOOST_ATOMIC_FLAG_LOCK_FREE +#define BOOST_ATOMIC_FLAG_LOCK_FREE 0 +class atomic_flag { +public: + atomic_flag(void) : v_(false) {} + + bool + test_and_set(memory_order order = memory_order_seq_cst) + { + return v_.exchange(true, order); + } + + void + clear(memory_order order = memory_order_seq_cst) volatile + { + v_.store(false, order); + } +private: + atomic_flag(const atomic_flag &) /* = delete */ ; + atomic_flag & operator=(const atomic_flag &) /* = delete */ ; + atomic v_; +}; +#endif + +typedef atomic atomic_char; +typedef atomic atomic_uchar; +typedef atomic atomic_schar; +typedef atomic atomic_uint8_t; +typedef atomic atomic_int8_t; +typedef atomic atomic_ushort; +typedef atomic atomic_short; +typedef atomic atomic_uint16_t; +typedef atomic atomic_int16_t; +typedef atomic atomic_uint; +typedef atomic atomic_int; +typedef atomic atomic_uint32_t; +typedef atomic atomic_int32_t; +typedef atomic atomic_ulong; +typedef atomic atomic_long; +typedef atomic atomic_uint64_t; +typedef atomic atomic_int64_t; +#ifdef BOOST_HAS_LONG_LONG +typedef atomic atomic_ullong; +typedef atomic atomic_llong; +#endif +typedef atomic atomic_address; +typedef atomic atomic_bool; + +} + +#endif diff --git a/include/boost/atomic/detail/base.hpp b/include/boost/atomic/detail/base.hpp index 60f0c82..5e7001a 100644 --- a/include/boost/atomic/detail/base.hpp +++ b/include/boost/atomic/detail/base.hpp @@ -13,8 +13,13 @@ #include +#include #include +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + #define BOOST_ATOMIC_DECLARE_BASE_OPERATORS \ operator value_type(void) volatile const \ { \ diff --git a/include/boost/atomic/detail/cas32strong.hpp b/include/boost/atomic/detail/cas32strong.hpp index 05fd9fb..3bfa557 100644 --- a/include/boost/atomic/detail/cas32strong.hpp +++ b/include/boost/atomic/detail/cas32strong.hpp @@ -11,8 +11,13 @@ // a platform_cmpxchg32_strong primitive. #include +#include #include +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + namespace boost { namespace atomics { namespace detail { diff --git a/include/boost/atomic/detail/cas32weak.hpp b/include/boost/atomic/detail/cas32weak.hpp index c507a6d..a58cfde 100644 --- a/include/boost/atomic/detail/cas32weak.hpp +++ b/include/boost/atomic/detail/cas32weak.hpp @@ -8,8 +8,13 @@ // Copyright (c) 2011 Helge Bahmann #include +#include #include +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + namespace boost { namespace atomics { namespace detail { diff --git a/include/boost/atomic/detail/cas64strong.hpp b/include/boost/atomic/detail/cas64strong.hpp index 491e2c8..e5111b6 100644 --- a/include/boost/atomic/detail/cas64strong.hpp +++ b/include/boost/atomic/detail/cas64strong.hpp @@ -12,8 +12,13 @@ // atomic, so they are funnelled through cmpxchg as well. #include +#include #include +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + namespace boost { namespace atomics { namespace detail { diff --git a/include/boost/atomic/config.hpp b/include/boost/atomic/detail/config.hpp similarity index 72% rename from include/boost/atomic/config.hpp rename to include/boost/atomic/detail/config.hpp index c2fa603..979bdd8 100644 --- a/include/boost/atomic/config.hpp +++ b/include/boost/atomic/detail/config.hpp @@ -1,5 +1,5 @@ -#ifndef BOOST_ATOMIC_CONFIG_HPP -#define BOOST_ATOMIC_CONFIG_HPP +#ifndef BOOST_ATOMIC_DETAIL_CONFIG_HPP +#define BOOST_ATOMIC_DETAIL_CONFIG_HPP // Copyright (c) 2012 Hartmut Kaiser // @@ -9,16 +9,24 @@ #include +#if (defined(_MSC_VER) && (_MSC_VER >= 1020)) || defined(__GNUC__) || defined(BOOST_CLANG) || defined(BOOST_INTEL) || defined(__COMO__) || defined(__DMC__) +#define BOOST_ATOMIC_HAS_PRAGMA_ONCE +#endif + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + /////////////////////////////////////////////////////////////////////////////// // Set up dll import/export options #if (defined(BOOST_ATOMIC_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && \ !defined(BOOST_ATOMIC_STATIC_LINK) - + #if defined(BOOST_ATOMIC_SOURCE) -#define BOOST_ATOMIC_DECL BOOST_SYMBOL_EXPORT +#define BOOST_ATOMIC_DECL BOOST_SYMBOL_EXPORT #define BOOST_ATOMIC_BUILD_DLL #else -#define BOOST_ATOMIC_DECL BOOST_SYMBOL_IMPORT +#define BOOST_ATOMIC_DECL BOOST_SYMBOL_IMPORT #endif #endif // building a shared library diff --git a/include/boost/atomic/detail/gcc-alpha.hpp b/include/boost/atomic/detail/gcc-alpha.hpp index 80ff11a..1f465f9 100644 --- a/include/boost/atomic/detail/gcc-alpha.hpp +++ b/include/boost/atomic/detail/gcc-alpha.hpp @@ -7,9 +7,14 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include #include #include +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + /* Refer to http://h71000.www7.hp.com/doc/82final/5601/5601pro_004.html (HP OpenVMS systems documentation) and the alpha reference manual. diff --git a/include/boost/atomic/detail/gcc-armv6plus.hpp b/include/boost/atomic/detail/gcc-armv6plus.hpp index ea87a83..3c9f942 100644 --- a/include/boost/atomic/detail/gcc-armv6plus.hpp +++ b/include/boost/atomic/detail/gcc-armv6plus.hpp @@ -9,6 +9,12 @@ // Copyright (c) 2009 Phil Endecott // ARM Code by Phil Endecott, based on other architectures. +#include + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + // From the ARM Architecture Reference Manual for architecture v6: // // LDREX{} , [] diff --git a/include/boost/atomic/detail/gcc-cas.hpp b/include/boost/atomic/detail/gcc-cas.hpp index d9173c6..c220c53 100644 --- a/include/boost/atomic/detail/gcc-cas.hpp +++ b/include/boost/atomic/detail/gcc-cas.hpp @@ -10,6 +10,12 @@ #ifndef BOOST_ATOMIC_DETAIL_GENERIC_CAS_HPP #define BOOST_ATOMIC_DETAIL_GENERIC_CAS_HPP +#include + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + namespace boost { #define BOOST_ATOMIC_THREAD_FENCE 2 diff --git a/include/boost/atomic/detail/gcc-ppc.hpp b/include/boost/atomic/detail/gcc-ppc.hpp index c05ac85..f5813ae 100644 --- a/include/boost/atomic/detail/gcc-ppc.hpp +++ b/include/boost/atomic/detail/gcc-ppc.hpp @@ -7,6 +7,12 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + /* Refer to: Motorola: "Programming Environments Manual for 32-Bit Implementations of the PowerPC Architecture", Appendix E: diff --git a/include/boost/atomic/detail/gcc-sparcv9.hpp b/include/boost/atomic/detail/gcc-sparcv9.hpp index e099c18..5c47ea9 100644 --- a/include/boost/atomic/detail/gcc-sparcv9.hpp +++ b/include/boost/atomic/detail/gcc-sparcv9.hpp @@ -7,6 +7,12 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + namespace boost { namespace atomics { namespace detail { diff --git a/include/boost/atomic/detail/gcc-x86.hpp b/include/boost/atomic/detail/gcc-x86.hpp index efda24c..76080ec 100644 --- a/include/boost/atomic/detail/gcc-x86.hpp +++ b/include/boost/atomic/detail/gcc-x86.hpp @@ -8,6 +8,12 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + namespace boost { namespace atomics { namespace detail { diff --git a/include/boost/atomic/detail/generic-cas.hpp b/include/boost/atomic/detail/generic-cas.hpp index 83b90ed..f3ae701 100644 --- a/include/boost/atomic/detail/generic-cas.hpp +++ b/include/boost/atomic/detail/generic-cas.hpp @@ -10,9 +10,14 @@ #include #include +#include #include #include +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + /* fallback implementation for various compilation targets; this is *not* efficient, particularly because all operations are fully fenced (full memory barriers before and after diff --git a/include/boost/atomic/detail/interlocked.hpp b/include/boost/atomic/detail/interlocked.hpp index 1dd90d4..a1eea09 100644 --- a/include/boost/atomic/detail/interlocked.hpp +++ b/include/boost/atomic/detail/interlocked.hpp @@ -8,6 +8,11 @@ // http://www.boost.org/LICENSE_1_0.txt) #include +#include + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif namespace boost { namespace atomics { diff --git a/include/boost/atomic/detail/linux-arm.hpp b/include/boost/atomic/detail/linux-arm.hpp index 4ed6aad..80c3c7e 100644 --- a/include/boost/atomic/detail/linux-arm.hpp +++ b/include/boost/atomic/detail/linux-arm.hpp @@ -31,6 +31,11 @@ // semantics. #include +#include + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif namespace boost { namespace atomics { diff --git a/include/boost/atomic/detail/lockpool.hpp b/include/boost/atomic/detail/lockpool.hpp index 0593ecb..a0699e2 100644 --- a/include/boost/atomic/detail/lockpool.hpp +++ b/include/boost/atomic/detail/lockpool.hpp @@ -8,11 +8,15 @@ // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #ifndef BOOST_ATOMIC_FLAG_LOCK_FREE #include #endif +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + namespace boost { namespace atomics { namespace detail { diff --git a/include/boost/atomic/platform.hpp b/include/boost/atomic/detail/platform.hpp similarity index 90% rename from include/boost/atomic/platform.hpp rename to include/boost/atomic/detail/platform.hpp index 75425e8..8063435 100644 --- a/include/boost/atomic/platform.hpp +++ b/include/boost/atomic/detail/platform.hpp @@ -1,3 +1,6 @@ +#ifndef BOOST_ATOMIC_DETAIL_PLATFORM_HPP +#define BOOST_ATOMIC_DETAIL_PLATFORM_HPP + // Copyright (c) 2009 Helge Bahmann // // Distributed under the Boost Software License, Version 1.0. @@ -6,7 +9,11 @@ // Platform selection file -#include +#include + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) @@ -51,3 +58,5 @@ #include #endif + +#endif diff --git a/include/boost/atomic/detail/type-classifier.hpp b/include/boost/atomic/detail/type-classifier.hpp index 93fbe16..4028dd0 100644 --- a/include/boost/atomic/detail/type-classifier.hpp +++ b/include/boost/atomic/detail/type-classifier.hpp @@ -7,6 +7,12 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include + +#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE +#pragma once +#endif + namespace boost { namespace atomics { namespace detail {