Documented GVF_SAVE_VAR alongside other flags, and removed a query/doubt
[AROS.git] / arch / x86_64-pc / kernel / tls.h
blob84eab0ed5dc733e9e742864fabce4805158bcef7
1 #ifndef ASM_TLS_H
2 #define ASM_TLS_H
4 typedef struct tls
6 struct ExecBase *SysBase;
7 void * *KernelBase; /* Base of kernel.resource */
8 } tls_t;
10 #define TLS_OFFSET(name) ((char *)&(((tls_t *)0)->name)-(char *)0)
12 #define TLS_GET(name) \
13 ({ \
14 tls_t *__tls = (tls_t *)0; \
15 typeof(__tls -> name) __ret; \
16 switch (sizeof(__tls -> name)) { \
17 case 2: asm volatile("movw %%gs:%P1,%0":"=r"(__ret):"n"(TLS_OFFSET(name)):"memory"); break; \
18 case 4: asm volatile("movl %%gs:%P1,%0":"=r"(__ret):"n"(TLS_OFFSET(name)):"memory"); break; \
19 case 8: asm volatile("movq %%gs:%P1,%0":"=r"(__ret):"n"(TLS_OFFSET(name)):"memory"); break; \
20 } \
21 __ret; \
24 #define TLS_SET(name, val) \
25 do { \
26 tls_t *__tls = (tls_t *)0; \
27 typeof(__tls -> name) __set = val; \
28 switch (sizeof(__tls -> name)) { \
29 case 2: asm volatile("movw %0,%%gs:%P1"::"r"(__set),"n"(TLS_OFFSET(name)):"memory"); break; \
30 case 4: asm volatile("movl %0,%%gs:%P1"::"r"(__set),"n"(TLS_OFFSET(name)):"memory"); break; \
31 case 8: asm volatile("movq %0,%%gs:%P1"::"r"(__set),"n"(TLS_OFFSET(name)):"memory"); break; \
32 } \
33 } while(0);
35 #endif