Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/core/test_dylink_tls.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <threads.h>

static thread_local int foo = 10;
static thread_local int bar = 11;

void sidey();

int get_foo() {
return foo;
}

int get_bar() {
return bar;
}

int main(int argc, char const *argv[]) {
printf("main TLS: %d %d\n", get_foo(), get_bar());
sidey();
return 0;
}
2 changes: 2 additions & 0 deletions tests/core/test_dylink_tls.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main TLS: 10 11
side TLS: 42 43
17 changes: 17 additions & 0 deletions tests/core/test_dylink_tls_side.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>
#include <threads.h>

static thread_local int baz = 42;
static thread_local int wiz = 43;

int get_baz() {
return baz;
}

int get_wiz() {
return wiz;
}

void sidey() {
printf("side TLS: %d %d\n", get_baz(), get_wiz());
}
25 changes: 1 addition & 24 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4592,31 +4592,8 @@ def test_dylink_tls(self):

# TODO(sbc): Add tests that depend on importing/exported TLS symbols
# once we figure out how to do that.
create_file('main.c', r'''
#include <stdio.h>

_Thread_local int foo = 10;

void sidey();

int main(int argc, char const *argv[]) {
printf("main TLS: %d\n", foo);
sidey();
return 0;
}
''')
create_file('side.c', r'''
#include <stdio.h>

_Thread_local int bar = 11;

void sidey() {
printf("side TLS: %d\n", bar);
}
''')
self.emcc_args.append('-Wno-experimental')
self.dylink_testf('main.c', 'side.c',
expected='main TLS: 10\nside TLS: 11\n',
self.dylink_testf(test_file('core/test_dylink_tls.c'), test_file('core/test_dylink_tls_side.c'),
need_reverse=False)

def test_random(self):
Expand Down