source: mainline/uspace/lib/c/include/tls.h@ cd1e3fc0

Last change on this file since cd1e3fc0 was d7f7a4a, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Replace some license headers with SPDX identifier

Headers are replaced using tools/transorm-copyright.sh only
when it can be matched verbatim with the license header used
throughout most of the codebase.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2007 Jakub Jermar
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7/** @addtogroup libc
8 * @{
9 */
10/** @file
11 */
12
13#ifndef _LIBC_TLS_H_
14#define _LIBC_TLS_H_
15
16#include <libarch/tls.h>
17#include <stdbool.h>
18#include <stddef.h>
19#include <stdint.h>
20
21static inline void __tcb_reset(void)
22{
23 __tcb_raw_set(NULL);
24}
25
26static inline void __tcb_set(tcb_t *tcb)
27{
28 __tcb_raw_set((uint8_t *)tcb + ARCH_TP_OFFSET);
29}
30
31static inline tcb_t *__tcb_get(void)
32{
33 return (tcb_t *)((uint8_t *)__tcb_raw_get() - ARCH_TP_OFFSET);
34}
35
36/*
37 * The TP register is supposed to be zero when the thread is first created
38 * by the kernel. We use this for some debugging assertions.
39 */
40static inline bool __tcb_is_set(void)
41{
42 return __tcb_raw_get() != NULL;
43}
44
45/** DTV Generation number - equals vector length */
46#define DTV_GN(dtv) (((uintptr_t *)(dtv))[0])
47
48extern tcb_t *tls_make(const void *);
49extern tcb_t *tls_make_initial(const void *);
50extern tcb_t *tls_alloc_arch(size_t, size_t);
51extern void tls_free(tcb_t *);
52extern void tls_free_arch(tcb_t *, size_t, size_t);
53extern void *tls_get(void);
54
55#ifdef CONFIG_TLS_VARIANT_1
56extern tcb_t *tls_alloc_variant_1(size_t, size_t);
57extern void tls_free_variant_1(tcb_t *, size_t, size_t);
58#endif
59
60#ifdef CONFIG_TLS_VARIANT_2
61extern tcb_t *tls_alloc_variant_2(size_t, size_t);
62extern void tls_free_variant_2(tcb_t *, size_t, size_t);
63#endif
64
65#endif
66
67/** @}
68 */
Note: See TracBrowser for help on using the repository browser.