tls.h 405 B

123456789101112131415161718
  1. #pragma once
  2. #include <util/system/compiler.h>
  3. #define YT_PREVENT_TLS_CACHING Y_NO_INLINE
  4. // Workaround for fiber (un)friendly TLS.
  5. #define YT_DECLARE_THREAD_LOCAL(type, name) \
  6. type& name();
  7. #define YT_DEFINE_THREAD_LOCAL(type, name, ...) \
  8. thread_local type name##Data { __VA_ARGS__ }; \
  9. Y_NO_INLINE type& name() \
  10. { \
  11. asm volatile(""); \
  12. return name##Data; \
  13. }