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
RevLine 
[c4c5de5]1/*
[d7f7a4a]2 * SPDX-FileCopyrightText: 2007 Jakub Jermar
[c4c5de5]3 *
[d7f7a4a]4 * SPDX-License-Identifier: BSD-3-Clause
[c4c5de5]5 */
6
[fa23560]7/** @addtogroup libc
[e209fc96]8 * @{
9 */
10/** @file
11 */
12
[4805495]13#ifndef _LIBC_TLS_H_
14#define _LIBC_TLS_H_
[c4c5de5]15
[fa23560]16#include <libarch/tls.h>
[0b05082]17#include <stdbool.h>
[8d2dd7f2]18#include <stddef.h>
19#include <stdint.h>
[fa23560]20
[0b05082]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
[d2bb25e7]45/** DTV Generation number - equals vector length */
46#define DTV_GN(dtv) (((uintptr_t *)(dtv))[0])
47
[40abf56a]48extern tcb_t *tls_make(const void *);
49extern tcb_t *tls_make_initial(const void *);
[4f205248]50extern tcb_t *tls_alloc_arch(size_t, size_t);
[31399f3]51extern void tls_free(tcb_t *);
[4f205248]52extern void tls_free_arch(tcb_t *, size_t, size_t);
[e2f26002]53extern void *tls_get(void);
[c4c5de5]54
[fa23560]55#ifdef CONFIG_TLS_VARIANT_1
[4f205248]56extern tcb_t *tls_alloc_variant_1(size_t, size_t);
57extern void tls_free_variant_1(tcb_t *, size_t, size_t);
[fa23560]58#endif
[47b7006]59
[fa23560]60#ifdef CONFIG_TLS_VARIANT_2
[4f205248]61extern tcb_t *tls_alloc_variant_2(size_t, size_t);
62extern void tls_free_variant_2(tcb_t *, size_t, size_t);
[fa23560]63#endif
[c4c5de5]64
[fa23560]65#endif
[e209fc96]66
[fadd381]67/** @}
[e209fc96]68 */
Note: See TracBrowser for help on using the repository browser.