Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:39:07

0001 #ifndef BOOST_LEAF_CONFIG_TLS_GLOBALS_HPP_INCLUDED
0002 #define BOOST_LEAF_CONFIG_TLS_GLOBALS_HPP_INCLUDED
0003 
0004 // Copyright 2018-2024 Emil Dotchevski and Reverge Studios, Inc.
0005 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0006 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 // LEAF requires thread local storage support for pointers and for uin32_t values.
0009 
0010 // This header implements "thread local" storage for pointers and for unsigned int
0011 // values using globals, which is suitable for single thread environments.
0012 
0013 #include <cstdint>
0014 
0015 namespace boost { namespace leaf {
0016 
0017 namespace detail
0018 {
0019     using atomic_unsigned_int = unsigned int;
0020 }
0021 
0022 namespace tls
0023 {
0024     template <class T>
0025     struct BOOST_LEAF_SYMBOL_VISIBLE ptr
0026     {
0027         static T * p;
0028     };
0029 
0030     template <class T>
0031     T * ptr<T>::p;
0032 
0033     template <class T>
0034     T * read_ptr() noexcept
0035     {
0036         return ptr<T>::p;
0037     }
0038 
0039     template <class T>
0040     void write_ptr( T * p ) noexcept
0041     {
0042         ptr<T>::p = p;
0043     }
0044 
0045     ////////////////////////////////////////
0046 
0047     template <class Tag>
0048     struct BOOST_LEAF_SYMBOL_VISIBLE tagged_uint
0049     {
0050         static unsigned x;
0051     };
0052 
0053     template <class Tag>
0054     unsigned tagged_uint<Tag>::x;
0055 
0056     template <class Tag>
0057     unsigned read_uint() noexcept
0058     {
0059         return tagged_uint<Tag>::x;
0060     }
0061 
0062     template <class Tag>
0063     void write_uint( unsigned x ) noexcept
0064     {
0065         tagged_uint<Tag>::x = x;
0066     }
0067 }
0068 
0069 } }
0070 
0071 #endif // BOOST_LEAF_CONFIG_TLS_GLOBALS_HPP_INCLUDED