C/C++ __thread/thread_local support.
C/C++ __thread/thread_local support.
This library provides transparent runtime support for thread locals for the different types of thread local implementations used by the SDK supported compilers and C libraries.
This means that by default, each core will get its own value for the thread local variable, and the core 1 value will be re-initialized if the core is restarted.
Additionally, this library provides the "picolibc" style methods _tls_size(), _init_tls() and _set_tls() even when not using picolibc, which makes it easy to enable thread locals per task on at least FreeRTOS (just set #define configUSE_PICOLIBC_TLS 1 in your FreeRTOSConfig.h).
The pico_thread_local library comes in three main flavors:
The support provided by the pico_thread_local library may be set from CMake via pico_set_thread_local_implementation(<TARGET> per_thread|global|none) and the default for all targets may be set via CMake variable (e.g. set(PICO_DEFAULT_THREAD_LOCAL_IMPL global)).