Showing the changes to tests (3 of 5 files). Show all
Unified · Split
| @@ -0,0 +1,50 @@ | ||
| 1 | +#include <stdio.h> | |
| 2 | +#include <pthread.h> | |
| 3 | + | |
| 4 | +__thread int tls_init = 42; | |
| 5 | +__thread int tls_zero; | |
| 6 | + | |
| 7 | +static void *thread_func(void *arg) | |
| 8 | +{ | |
| 9 | + (void)arg; | |
| 10 | + | |
| 11 | + printf("%d\n", tls_init); | |
| 12 | + if (tls_init != 42) return (void *)1; | |
| 13 | + | |
| 14 | + printf("%d\n", tls_zero); | |
| 15 | + if (tls_zero != 0) return (void *)1; | |
| 16 | + | |
| 17 | + tls_init = 100; | |
| 18 | + tls_zero = 200; | |
| 19 | + | |
| 20 | + printf("%d\n", tls_init); | |
| 21 | + printf("%d\n", tls_zero); | |
| 22 | + | |
| 23 | + return (void *)0; | |
| 24 | +} | |
| 25 | + | |
| 26 | +int main() | |
| 27 | +{ | |
| 28 | + pthread_t t; | |
| 29 | + void *ret; | |
| 30 | + int errors = 0; | |
| 31 | + | |
| 32 | + printf("%d\n", tls_init); | |
| 33 | + if (tls_init != 42) errors = 1; | |
| 34 | + | |
| 35 | + printf("%d\n", tls_zero); | |
| 36 | + if (tls_zero != 0) errors = 1; | |
| 37 | + | |
| 38 | + pthread_create(&t, NULL, thread_func, NULL); | |
| 39 | + pthread_join(t, &ret); | |
| 40 | + | |
| 41 | + if (ret) errors = 1; | |
| 42 | + | |
| 43 | + printf("%d\n", tls_init); | |
| 44 | + if (tls_init != 42) errors = 1; | |
| 45 | + | |
| 46 | + printf("%d\n", tls_zero); | |
| 47 | + if (tls_zero != 0) errors = 1; | |
| 48 | + | |
| 49 | + return errors; | |
| 50 | +} | |
| @@ -0,0 +1,8 @@ | ||
| 1 | +42 | |
| 2 | +0 | |
| 3 | +42 | |
| 4 | +0 | |
| 5 | +100 | |
| 6 | +200 | |
| 7 | +42 | |
| 8 | +0 | |
| @@ -19,6 +19,9 @@ ifeq (,$(filter i386 x86_64,$(ARCH))) · 18 unmodified lines | ||
| 19 | 19 | SKIP += 85_asm-outside-function.test # x86 asm |
| 20 | 20 | SKIP += 127_asm_goto.test # hardcodes x86 asm |
| 21 | 21 | endif |
| 22 | +ifeq (,$(filter x86_64,$(ARCH))) | |
| 23 | + SKIP += 144_tls.test # TLS only implemented on x86_64 so far | |
| 24 | +endif | |
| 22 | 25 | ifeq ($(CONFIG_backtrace),no) |
| 23 | 26 | SKIP += 113_btdll.test |
| 24 | 27 | CONFIG_bcheck = no |
| @@ -107,6 +110,10 @@ GEN-ALWAYS = · 82 unmodified lines | ||
| 107 | 110 | # constructor/destructor |
| 108 | 111 | 108_constructor.test: NORUN = true |
| 109 | 112 | |
| 113 | +# TLS needs executable and pthread, not -run | |
| 114 | +144_tls.test: FLAGS += -pthread | |
| 115 | +144_tls.test: NORUN = true | |
| 116 | + | |
| 110 | 117 | 112_backtrace.test: FLAGS += -dt -b |
| 111 | 118 | 112_backtrace.test 113_btdll.test 126_bound_global.test: FILTER += \ |
| 112 | 119 | -e 's;[0-9A-Fa-fx]\{5,\};........;g' \ |