1 #ifndef BOOST_LEAF_CONFIG_TLS_GLOBALS_HPP_INCLUDED
2 #define BOOST_LEAF_CONFIG_TLS_GLOBALS_HPP_INCLUDED
4 // Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
6 // Distributed under the Boost Software License, Version 1.0. (See accompanying
7 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 // LEAF requires thread local storage support for pointers and for uin32_t values.
11 // This header implements "thread local" storage for pointers and for uint32_t
12 // values using globals, which is suitable for single thread environments.
16 namespace boost { namespace leaf {
20 using atomic_unsigned_int = unsigned int;
26 struct BOOST_LEAF_SYMBOL_VISIBLE ptr
35 T * read_ptr() noexcept
41 void write_ptr( T * p ) noexcept
46 ////////////////////////////////////////
49 struct BOOST_LEAF_SYMBOL_VISIBLE tagged_uint32
51 static std::uint32_t x;
55 std::uint32_t tagged_uint32<Tag>::x;
58 std::uint32_t read_uint32() noexcept
60 return tagged_uint32<Tag>::x;
64 void write_uint32( std::uint32_t x ) noexcept
66 tagged_uint32<Tag>::x = x;
70 void uint32_increment() noexcept
72 ++tagged_uint32<Tag>::x;
76 void uint32_decrement() noexcept
78 --tagged_uint32<Tag>::x;