Back to index

glibc  2.9
tst-tls5.h
Go to the documentation of this file.
00001 #include <stdint.h>
00002 #include <stdlib.h>
00003 #include <tls.h>
00004 
00005 #if HAVE___THREAD
00006 
00007 struct tls_obj
00008 {
00009   const char *name;
00010   uintptr_t addr;
00011   size_t size;
00012   size_t align;
00013 };
00014 extern struct tls_obj tls_registry[];
00015 
00016 #define TLS_REGISTER(x)                          \
00017 static void __attribute__((constructor))  \
00018 tls_register_##x (void)                          \
00019 {                                         \
00020   size_t i;                               \
00021   for (i = 0; tls_registry[i].name; ++i); \
00022   tls_registry[i].name = #x;                     \
00023   tls_registry[i].addr = (uintptr_t) &x;  \
00024   tls_registry[i].size = sizeof (x);             \
00025   tls_registry[i].align = __alignof__ (x);       \
00026 }
00027 
00028 #endif