-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Implement initialization for local-exec TLS #8976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3c751ef
Implement initialization for local-exec TLS
quantum5 a9370cc
Add unit tests for local-exec TLS
quantum5 533cd0c
Ensure TLS works on the true main thread as well
quantum5 80694ad
Test more POD types with thread local
quantum5 f6f91c2
Move TLS to library_pthread_wasm.c
quantum5 f2ae717
Merge remote-tracking branch 'origin/incoming' into tls-local-exec
quantum5 e86b4f5
Support thread-locals in __attribute((constructor))
quantum5 7998220
Remove -ftls-model=local-exec
quantum5 b4c716e
Merge remote-tracking branch 'origin/incoming' into tls-local-exec
quantum5 546a837
Merge remote-tracking branch 'origin/incoming' into tls-local-exec
quantum5 6f26c23
Don't break fastcomp calling wasm-backend-specific stuff
quantum5 b1c2e77
Fix pthread tests hanging
quantum5 7aa69c5
Add to change log
quantum5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #include <thread> | ||
| #include <cstdio> | ||
|
|
||
| thread_local int tls; | ||
| thread_local struct { | ||
| int a; | ||
| double b; | ||
| } data = {1, 2}; | ||
| thread_local int array[10]; | ||
|
|
||
| void thread(void) { | ||
| ++tls; | ||
| data.a = 3; | ||
| data.b = 4; | ||
| assert(tls == 1); | ||
| assert(data.a == 3); | ||
| assert(data.b == 4); | ||
| assert(array[9] == 0); | ||
| } | ||
|
|
||
| int main(void) { | ||
| array[9] = 1337; | ||
| std::thread t(thread); | ||
| t.join(); | ||
| assert(tls == 0); | ||
| assert(data.a == 1); | ||
| assert(data.b == 2); | ||
| assert(array[9] == 1337); | ||
| #ifdef REPORT_RESULT | ||
| REPORT_RESULT(1337); | ||
| #endif | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #include <thread> | ||
| #include <cstdio> | ||
|
|
||
| thread_local int tls = 1330; | ||
| thread_local int tls2; | ||
|
|
||
| __attribute__((constructor)) | ||
| void init_tls2(void) { | ||
| tls2 = 7; | ||
| } | ||
|
|
||
| int main(void) { | ||
| #ifdef REPORT_RESULT | ||
| REPORT_RESULT(tls + tls2); | ||
| #endif | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.