the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#ifndef BOOST_ATOMIC_ATOMIC_HPP
2#define BOOST_ATOMIC_ATOMIC_HPP
3
4// Copyright (c) 2011 Helge Bahmann
5//
6// Distributed under the Boost Software License, Version 1.0.
7// See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
10#include <cstddef>
11#include <boost/cstdint.hpp>
12
13#include <boost/memory_order.hpp>
14
15#include <boost/atomic/detail/config.hpp>
16#include <boost/atomic/detail/platform.hpp>
17#include <boost/atomic/detail/type-classification.hpp>
18#include <boost/type_traits/is_signed.hpp>
19
20#ifdef BOOST_ATOMIC_HAS_PRAGMA_ONCE
21#pragma once
22#endif
23
24namespace boost {
25
26#ifndef BOOST_ATOMIC_CHAR_LOCK_FREE
27#define BOOST_ATOMIC_CHAR_LOCK_FREE 0
28#endif
29
30#ifndef BOOST_ATOMIC_CHAR16_T_LOCK_FREE
31#define BOOST_ATOMIC_CHAR16_T_LOCK_FREE 0
32#endif
33
34#ifndef BOOST_ATOMIC_CHAR32_T_LOCK_FREE
35#define BOOST_ATOMIC_CHAR32_T_LOCK_FREE 0
36#endif
37
38#ifndef BOOST_ATOMIC_WCHAR_T_LOCK_FREE
39#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0
40#endif
41
42#ifndef BOOST_ATOMIC_SHORT_LOCK_FREE
43#define BOOST_ATOMIC_SHORT_LOCK_FREE 0
44#endif
45
46#ifndef BOOST_ATOMIC_INT_LOCK_FREE
47#define BOOST_ATOMIC_INT_LOCK_FREE 0
48#endif
49
50#ifndef BOOST_ATOMIC_LONG_LOCK_FREE
51#define BOOST_ATOMIC_LONG_LOCK_FREE 0
52#endif
53
54#ifndef BOOST_ATOMIC_LLONG_LOCK_FREE
55#define BOOST_ATOMIC_LLONG_LOCK_FREE 0
56#endif
57
58#ifndef BOOST_ATOMIC_POINTER_LOCK_FREE
59#define BOOST_ATOMIC_POINTER_LOCK_FREE 0
60#endif
61
62#define BOOST_ATOMIC_ADDRESS_LOCK_FREE BOOST_ATOMIC_POINTER_LOCK_FREE
63
64#ifndef BOOST_ATOMIC_BOOL_LOCK_FREE
65#define BOOST_ATOMIC_BOOL_LOCK_FREE 0
66#endif
67
68#ifndef BOOST_ATOMIC_THREAD_FENCE
69#define BOOST_ATOMIC_THREAD_FENCE 0
70inline void atomic_thread_fence(memory_order)
71{
72}
73#endif
74
75#ifndef BOOST_ATOMIC_SIGNAL_FENCE
76#define BOOST_ATOMIC_SIGNAL_FENCE 0
77inline void atomic_signal_fence(memory_order order)
78{
79 atomic_thread_fence(order);
80}
81#endif
82
83template<typename T>
84class atomic :
85 public atomics::detail::base_atomic<T, typename atomics::detail::classify<T>::type, atomics::detail::storage_size_of<T>::value, boost::is_signed<T>::value >
86{
87private:
88 typedef T value_type;
89 typedef atomics::detail::base_atomic<T, typename atomics::detail::classify<T>::type, atomics::detail::storage_size_of<T>::value, boost::is_signed<T>::value > super;
90public:
91 atomic(void) : super() {}
92 explicit atomic(const value_type & v) : super(v) {}
93
94 atomic & operator=(value_type v) volatile
95 {
96 super::operator=(v);
97 return *const_cast<atomic *>(this);
98 }
99private:
100 atomic(const atomic &) /* =delete */ ;
101 atomic & operator=(const atomic &) /* =delete */ ;
102};
103
104typedef atomic<char> atomic_char;
105typedef atomic<unsigned char> atomic_uchar;
106typedef atomic<signed char> atomic_schar;
107typedef atomic<uint8_t> atomic_uint8_t;
108typedef atomic<int8_t> atomic_int8_t;
109typedef atomic<unsigned short> atomic_ushort;
110typedef atomic<short> atomic_short;
111typedef atomic<uint16_t> atomic_uint16_t;
112typedef atomic<int16_t> atomic_int16_t;
113typedef atomic<unsigned int> atomic_uint;
114typedef atomic<int> atomic_int;
115typedef atomic<uint32_t> atomic_uint32_t;
116typedef atomic<int32_t> atomic_int32_t;
117typedef atomic<unsigned long> atomic_ulong;
118typedef atomic<long> atomic_long;
119typedef atomic<uint64_t> atomic_uint64_t;
120typedef atomic<int64_t> atomic_int64_t;
121#ifdef BOOST_HAS_LONG_LONG
122typedef atomic<boost::ulong_long_type> atomic_ullong;
123typedef atomic<boost::long_long_type> atomic_llong;
124#endif
125typedef atomic<void*> atomic_address;
126typedef atomic<bool> atomic_bool;
127typedef atomic<wchar_t> atomic_wchar_t;
128#if !defined(BOOST_NO_CXX11_CHAR16_T)
129typedef atomic<char16_t> atomic_char16_t;
130#endif
131#if !defined(BOOST_NO_CXX11_CHAR32_T)
132typedef atomic<char32_t> atomic_char32_t;
133#endif
134
135typedef atomic<int_least8_t> atomic_int_least8_t;
136typedef atomic<uint_least8_t> atomic_uint_least8_t;
137typedef atomic<int_least16_t> atomic_int_least16_t;
138typedef atomic<uint_least16_t> atomic_uint_least16_t;
139typedef atomic<int_least32_t> atomic_int_least32_t;
140typedef atomic<uint_least32_t> atomic_uint_least32_t;
141typedef atomic<int_least64_t> atomic_int_least64_t;
142typedef atomic<uint_least64_t> atomic_uint_least64_t;
143typedef atomic<int_fast8_t> atomic_int_fast8_t;
144typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
145typedef atomic<int_fast16_t> atomic_int_fast16_t;
146typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
147typedef atomic<int_fast32_t> atomic_int_fast32_t;
148typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
149typedef atomic<int_fast64_t> atomic_int_fast64_t;
150typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
151typedef atomic<intmax_t> atomic_intmax_t;
152typedef atomic<uintmax_t> atomic_uintmax_t;
153
154typedef atomic<std::size_t> atomic_size_t;
155typedef atomic<std::ptrdiff_t> atomic_ptrdiff_t;
156
157// PGI seems to not support intptr_t/uintptr_t properly. BOOST_HAS_STDINT_H is not defined for this compiler by Boost.Config.
158#if !defined(__PGIC__)
159
160#if (defined(BOOST_WINDOWS) && !defined(_WIN32_WCE)) \
161 || (defined(_XOPEN_UNIX) && (_XOPEN_UNIX+0 > 0)) \
162 || defined(__CYGWIN__) \
163 || defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) \
164 || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
165typedef atomic<intptr_t> atomic_intptr_t;
166typedef atomic<uintptr_t> atomic_uintptr_t;
167#elif defined(__GNUC__) || defined(__clang__)
168#if defined(__INTPTR_TYPE__)
169typedef atomic< __INTPTR_TYPE__ > atomic_intptr_t;
170#endif
171#if defined(__UINTPTR_TYPE__)
172typedef atomic< __UINTPTR_TYPE__ > atomic_uintptr_t;
173#endif
174#endif
175
176#endif
177
178#ifndef BOOST_ATOMIC_FLAG_LOCK_FREE
179#define BOOST_ATOMIC_FLAG_LOCK_FREE 0
180class atomic_flag
181{
182public:
183 atomic_flag(void) : v_(false) {}
184
185 bool
186 test_and_set(memory_order order = memory_order_seq_cst)
187 {
188 return v_.exchange(true, order);
189 }
190
191 void
192 clear(memory_order order = memory_order_seq_cst) volatile
193 {
194 v_.store(false, order);
195 }
196private:
197 atomic_flag(const atomic_flag &) /* = delete */ ;
198 atomic_flag & operator=(const atomic_flag &) /* = delete */ ;
199 atomic<bool> v_;
200};
201#endif
202
203}
204
205#endif