blob: 12f68b81963e05df22661e74ccb72d3a87807ad5 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <stdint.h>
2#include <stdlib.h>
3#include <tls.h>
4
5
6struct tls_obj
7{
8 const char *name;
9 uintptr_t addr;
10 size_t size;
11 size_t align;
12};
13extern struct tls_obj tls_registry[];
14
15#define TLS_REGISTER(x) \
16static void __attribute__((constructor)) \
17tls_register_##x (void) \
18{ \
19 size_t i; \
20 for (i = 0; tls_registry[i].name; ++i); \
21 tls_registry[i].name = #x; \
22 tls_registry[i].addr = (uintptr_t) &x; \
23 tls_registry[i].size = sizeof (x); \
24 tls_registry[i].align = __alignof__ (x); \
25}