Browse code

Merge pull request #248 from vjcitn/vince_M1_file

needed on M1 mac

Laurent Gatto authored on 18/06/2021 15:35:44 • GitHub committed on 18/06/2021 15:35:44
Showing1 changed files

1 1
new file mode 100644
... ...
@@ -0,0 +1,72 @@
1
+#ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED
2
+#define BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED
3
+
4
+//
5
+//  boost/detail/atomic_count_sync.hpp
6
+//
7
+//  atomic_count for g++ 4.1+
8
+//
9
+//  http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html
10
+//
11
+//  Copyright 2007 Peter Dimov
12
+//
13
+//  Distributed under the Boost Software License, Version 1.0. (See
14
+//  accompanying file LICENSE_1_0.txt or copy at
15
+//  http://www.boost.org/LICENSE_1_0.txt)
16
+//
17
+
18
+#include <boost/cstdint.hpp>
19
+
20
+#if defined( __ia64__ ) && defined( __INTEL_COMPILER )
21
+# include <ia64intrin.h>
22
+#endif
23
+
24
+#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
25
+
26
+#include <boost/config/pragma_message.hpp>
27
+BOOST_PRAGMA_MESSAGE("Using __sync atomic_count")
28
+
29
+#endif
30
+
31
+namespace boost
32
+{
33
+
34
+namespace detail
35
+{
36
+
37
+class atomic_count
38
+{
39
+public:
40
+
41
+    explicit atomic_count( long v ): value_( static_cast< boost::int_least32_t >( v ) )
42
+    {
43
+    }
44
+
45
+    long operator++()
46
+    {
47
+        return __sync_add_and_fetch( &value_, 1 );
48
+    }
49
+
50
+    long operator--()
51
+    {
52
+        return __sync_add_and_fetch( &value_, -1 );
53
+    }
54
+
55
+    operator long() const
56
+    {
57
+        return __sync_fetch_and_add( &value_, 0 );
58
+    }
59
+
60
+private:
61
+
62
+    atomic_count(atomic_count const &);
63
+    atomic_count & operator=(atomic_count const &);
64
+
65
+    mutable boost::int_least32_t value_;
66
+};
67
+
68
+} // namespace detail
69
+
70
+} // namespace boost
71
+
72
+#endif // #ifndef BOOST_SMART_PTR_DETAIL_ATOMIC_COUNT_SYNC_HPP_INCLUDED