History

feat(x86_64): add TLS Local Exec support with tests

Meng Zhuo committed 6 months ago

Commit ea26b851 parent 8443e255 files · +141 −6Browse files

Showing the changes to tests (3 of 5 files). Show all

Unified · Split

3 files
  1. tests/tests2/144_tls.c +50 −0
  2. tests/tests2/144_tls.expect +8 −0
  3. tests/tests2/Makefile +7 −0
tests/tests2/144_tls.c+50−0
@@ -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
7static 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
26int 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}
tests/tests2/144_tls.expect+8−0
@@ -0,0 +1,8 @@
142
20
342
40
5100
6200
742
80
tests/tests2/Makefile+7−0
@@ -19,6 +19,9 @@ ifeq (,$(filter i386 x86_64,$(ARCH))) · 18 unmodified lines
19 SKIP += 85_asm-outside-function.test # x86 asm19 SKIP += 85_asm-outside-function.test # x86 asm
20 SKIP += 127_asm_goto.test # hardcodes x86 asm20 SKIP += 127_asm_goto.test # hardcodes x86 asm
21endif21endif
22ifeq (,$(filter x86_64,$(ARCH)))
23 SKIP += 144_tls.test # TLS only implemented on x86_64 so far
24endif
22ifeq ($(CONFIG_backtrace),no)25ifeq ($(CONFIG_backtrace),no)
23 SKIP += 113_btdll.test26 SKIP += 113_btdll.test
24 CONFIG_bcheck = no27 CONFIG_bcheck = no
@@ -107,6 +110,10 @@ GEN-ALWAYS = · 82 unmodified lines
107# constructor/destructor110# constructor/destructor
108108_constructor.test: NORUN = true111108_constructor.test: NORUN = true
109 112
113# TLS needs executable and pthread, not -run
114144_tls.test: FLAGS += -pthread
115144_tls.test: NORUN = true
116
110112_backtrace.test: FLAGS += -dt -b117112_backtrace.test: FLAGS += -dt -b
111112_backtrace.test 113_btdll.test 126_bound_global.test: FILTER += \118112_backtrace.test 113_btdll.test 126_bound_global.test: FILTER += \
112 -e 's;[0-9A-Fa-fx]\{5,\};........;g' \119 -e 's;[0-9A-Fa-fx]\{5,\};........;g' \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t