Loading...
Searching...
No Matches
thread_local.h
1/*
2* Copyright (c) 2026 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _PICO_THREAD_LOCAL_H
8#define _PICO_THREAD_LOCAL_H
9
10#include <picotls.h>
11
12// PICO_CONFIG: PICO_THREAD_LOCAL_CORE1_REINITIALIZE, Whether re-initializing core 1 should reset its thread local variables. A tiny space-saving can be achieved by disabling this support if not needed, type=bool, default=1, advanced=true, group=pico_thread_local
13// PICO_CONFIG: PICO_THREAD_LOCAL_PROVIDE_INIT_TLS, Whether pico_thread_local should provide its own implementation of _init_tls, type=bool, default=1 for non-picolibc and 0 for picolibc, advanced=true, group=pico_thread_local
14// PICO_CONFIG: PICO_THREAD_LOCAL_PROVIDE_SET_TLS, Whether pico_thread_local should provide its own implementation of _set_tls, type=bool, default=1, advanced=true, group=pico_thread_local
15
16#if !defined(PICO_THREAD_LOCAL_CORE1_REINITIALIZE) && LIB_PICO_MULTICORE
17#define PICO_THREAD_LOCAL_CORE1_REINITIALIZE 1
18#endif
19
20#if !PICO_THREAD_LOCAL_MODE_NONE
21#ifndef PICO_THREAD_LOCAL_PROVIDE_INIT_TLS
22#ifndef PICOLIBC_TLS // this provides the function, and frankly in that case we don't expect emutls - is that fair tho?
23#define PICO_THREAD_LOCAL_PROVIDE_INIT_TLS 1
24#endif
25#endif
26
27#ifndef PICO_THREAD_LOCAL_PROVIDE_SET_TLS
28#define PICO_THREAD_LOCAL_PROVIDE_SET_TLS 1
29#endif
30#endif
31
32#if PICO_THREAD_LOCAL_SUPPORT_THREAD_POINTER
33// auto-select THREAD_POINTER type if not provided
34#if !PICO_THREAD_LOCAL_THREAD_POINTER_VIA_ARM_EABI && !PICO_THREAD_LOCAL_THREAD_POINTER_VIA_RISCV_REG
35#if __riscv || PICO_THREAD_LOCAL_THREAD_POINTER_RISCV_REG_CONFIRMED
36#define PICO_THREAD_LOCAL_THREAD_POINTER_VIA_RISCV_REG 1
37#else
38#define PICO_THREAD_LOCAL_THREAD_POINTER_VIA_ARM_EABI 1
39#endif
40#endif
41#endif
42
43#endif