Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
43 lines (37 loc) · 1.48 KB

File metadata and controls

43 lines (37 loc) · 1.48 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <emscripten.h>
#include <emscripten/wasm_worker.h>
#include <emscripten/stack.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#define THREAD_STACK_SIZE 1024
#define NUM_THREADS 2
void *thread_stack[NUM_THREADS];
volatile int threadsOk = 0;
void test_stack(int i)
{
EM_ASM(out(`In thread ${$0}, stack low addr=0x${$1.toString(16)}, emscripten_stack_get_base()=0x${$2.toString(16)}, emscripten_stack_get_end()=0x${$3.toString(16)}, THREAD_STACK_SIZE=0x${$4.toString(16)}`),
i, thread_stack[i], emscripten_stack_get_base(), emscripten_stack_get_end(), THREAD_STACK_SIZE);
assert(emscripten_stack_get_base() == (uintptr_t)thread_stack[i] + THREAD_STACK_SIZE);
assert(emscripten_stack_get_end() == (uintptr_t)thread_stack[i]);
int ok = __sync_fetch_and_add(&threadsOk, 1);
EM_ASM(out($0), ok);
if (ok == 1)
{
EM_ASM(out(`Test finished!`));
#ifdef REPORT_RESULT
REPORT_RESULT(0);
#endif
}
}
int main()
{
EM_ASM(out(`Main thread stack base=0x${$0.toString(16)}, end=0x${$1.toString(16)}`), emscripten_stack_get_base(), emscripten_stack_get_end());
for(int i = 0; i < NUM_THREADS; ++i)
{
thread_stack[i] = memalign(16, THREAD_STACK_SIZE);
emscripten_wasm_worker_t worker = emscripten_create_wasm_worker(thread_stack[i], THREAD_STACK_SIZE);
EM_ASM(out(`Created thread ${$0} with stack ptr=0x${$1.toString(16)}, size=0x${$2.toString(16)}`), i, thread_stack[i], THREAD_STACK_SIZE);
emscripten_wasm_worker_post_function_vi(worker, test_stack, i);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.