KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
tls_static.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 arch/dreamcast/include/arch/tls_static.h
4 Copyright (C) 2025 Donald Haase
5
6*/
7
8/** \file arch/tls_static.h
9 \brief Compiler Thread-local storage.
10 \ingroup kthreads
11
12 The functions in this file deal with managing static
13 TLS for C99's __thread or C11's _Thread_local.
14
15 This should not be exported or accessed externally.
16
17 \author Donald Haase
18*/
19
20#ifndef __ARCH_TLS_STATIC_H
21#define __ARCH_TLS_STATIC_H
22
23#include <sys/cdefs.h>
24__BEGIN_DECLS
25
26#include <kos/thread.h>
27
28/** \brief Initialize tls.
29
30 This function takes the steps necessary to initialize tls after
31 the creation of the k_thread for the main kernel thread.
32
33 For SH, this forces the setting of the GBR register to the TLS
34 of the kernel thread. That isn't necessary afterwards as it is
35 handled during context switching.
36
37*/
38void arch_tls_init(void);
39
40/** \brief Set up tls data for a new kthread.
41
42 This function allocates the memory for a kthread's TLS,
43 copies static data from the executable, and sets the
44 kthread's IRQ context to match.
45
46 It will be called by `thd_create_ex`
47
48 \param thd The thread to setup tls data for.
49*/
51
52/** \brief Destroy tls data for an old kthread.
53
54 This function undoes arch_tls_setup_data.
55
56 It will be called by `thd_destroy`
57
58 \param thd The thread to destroy tls data for.
59*/
61
62__END_DECLS
63
64#endif /* __ARCH_TLS_STATIC_H */
65
Structure describing one running thread.
Definition thread.h:160
Threading support.
bool arch_tls_setup_data(kthread_t *thd)
Set up tls data for a new kthread.
void arch_tls_init(void)
Initialize tls.
void arch_tls_destroy_data(kthread_t *thd)
Destroy tls data for an old kthread.