Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-05 08:36:32

0001 #ifndef BOOST_LEAF_CONFIG_TLS_FREERTOS_HPP_INCLUDED
0002 #define BOOST_LEAF_CONFIG_TLS_FREERTOS_HPP_INCLUDED
0003 
0004 // Copyright 2018-2023 Emil Dotchevski and Reverge Studios, Inc.
0005 // Copyright (c) 2022 Khalil Estell
0006 
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 
0010 // LEAF requires thread local storage support for pointers and for uin32_t values.
0011 
0012 // This header implements "thread local" storage via FreeTOS functions
0013 // pvTaskGetThreadLocalStoragePointer / pvTaskSetThreadLocalStoragePointer
0014 
0015 #include <task.h>
0016 
0017 #ifndef BOOST_LEAF_USE_TLS_ARRAY
0018 #   define BOOST_LEAF_USE_TLS_ARRAY
0019 #endif
0020 
0021 #ifndef BOOST_LEAF_CFG_TLS_ARRAY_SIZE
0022 #   define BOOST_LEAF_CFG_TLS_ARRAY_SIZE configNUM_THREAD_LOCAL_STORAGE_POINTERS
0023 #endif
0024 
0025 static_assert((BOOST_LEAF_CFG_TLS_ARRAY_SIZE) <= configNUM_THREAD_LOCAL_STORAGE_POINTERS,
0026     "Bad BOOST_LEAF_CFG_TLS_ARRAY_SIZE");
0027 
0028 namespace boost { namespace leaf {
0029 
0030 namespace tls
0031 {
0032     // See https://www.freertos.org/thread-local-storage-pointers.html.
0033 
0034     inline void * read_void_ptr( int tls_index ) noexcept
0035     {
0036         return pvTaskGetThreadLocalStoragePointer(0, tls_index);
0037     }
0038 
0039     inline void write_void_ptr( int tls_index, void * p ) noexcept
0040     {
0041         vTaskSetThreadLocalStoragePointer(0, tls_index, p);
0042     }
0043 }
0044 
0045 } }
0046 
0047 #endif