aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/tls.h
blob: a0656dedc15e3cce8221586f0b095ac56924e542 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#pragma once

#include <util/system/compiler.h>

#define YT_PREVENT_TLS_CACHING Y_NO_INLINE

// Workaround for fiber (un)friendly TLS.
#define YT_DECLARE_THREAD_LOCAL(type, name) \
    type& name();

#define YT_DEFINE_THREAD_LOCAL(type, name, ...) \
    thread_local type name##Data { __VA_ARGS__ }; \
    Y_NO_INLINE type& name() \
    { \
        asm volatile(""); \
        return name##Data; \
    }