Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/lib/pthread/emscripten_thread_state.S
6171 views
1
#ifdef __wasm64__
2
#define PTR i64
3
#else
4
#define PTR i32
5
#endif
6
7
.section .globals,"",@
8
9
.globaltype thread_ptr, PTR
10
thread_ptr:
11
12
.globaltype is_main_thread, i32
13
is_main_thread:
14
15
.globaltype is_runtime_thread, i32
16
is_runtime_thread:
17
18
.globaltype supports_wait, i32
19
supports_wait:
20
21
.section .text,"",@
22
23
.globl __get_tp
24
__get_tp:
25
.functype __get_tp () -> (PTR)
26
global.get thread_ptr
27
end_function
28
29
.globl __set_thread_state
30
__set_thread_state:
31
.functype __set_thread_state (PTR, i32, i32, i32) -> ()
32
local.get 0
33
global.set thread_ptr
34
local.get 1
35
global.set is_main_thread
36
local.get 2
37
global.set is_runtime_thread
38
local.get 3
39
global.set supports_wait
40
end_function
41
42
# Semantically the same as testing "!ENVIRONMENT_IS_PTHREAD" in JS
43
.globl emscripten_is_main_runtime_thread
44
emscripten_is_main_runtime_thread:
45
.functype emscripten_is_main_runtime_thread () -> (i32)
46
global.get is_runtime_thread
47
end_function
48
49
# Semantically the same as testing "!ENVIRONMENT_IS_WORKER" in JS
50
.globl emscripten_is_main_browser_thread
51
emscripten_is_main_browser_thread:
52
.functype emscripten_is_main_browser_thread () -> (i32)
53
global.get is_main_thread
54
end_function
55
56
# Semantically the same as testing "!ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_AUDIO_WORKLET" in JS
57
.globl _emscripten_thread_supports_atomics_wait
58
_emscripten_thread_supports_atomics_wait:
59
.functype _emscripten_thread_supports_atomics_wait () -> (i32)
60
global.get supports_wait
61
end_function
62
63