forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_function.c
More file actions
107 lines (93 loc) · 2.18 KB
/
post_function.c
File metadata and controls
107 lines (93 loc) · 2.18 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <emscripten.h>
#include <emscripten/wasm_worker.h>
#include <assert.h>
// Test emscripten_wasm_worker_post_function_*() API
EM_JS(void, console_log, (char* str), {
console.log(UTF8ToString(str));
});
volatile int success = 0;
void v()
{
console_log("v");
++success;
}
void vi(int i)
{
console_log("vi");
assert(i == 1);
++success;
}
void vii(int i, int j)
{
console_log("vii");
assert(i == 2);
assert(j == 3);
++success;
}
void viii(int i, int j, int k)
{
console_log("viii");
assert(i == 4);
assert(j == 5);
assert(k == 6);
++success;
}
void vd(double i)
{
console_log("vd");
assert(i == 1.5);
++success;
}
void vdd(double i, double j)
{
console_log("vdd");
assert(i == 2.5);
assert(j == 3.5);
++success;
}
void vddd(double i, double j, double k)
{
console_log("vddd");
assert(i == 4.5);
assert(j == 5.5);
assert(k == 6.5);
++success;
}
void viiiiiidddddd(int a, int b, int c, int d, int e, int f, double g, double h, double i, double j, double k, double l)
{
console_log("viiiiiidddddd");
assert(a == 10);
assert(b == 11);
assert(c == 12);
assert(d == 13);
assert(e == 14);
assert(f == 15);
assert(g == 16.5);
assert(h == 17.5);
assert(i == 18.5);
assert(j == 19.5);
assert(k == 20.5);
assert(l == 21.5);
++success;
}
void test_finished()
{
#ifdef REPORT_RESULT
REPORT_RESULT(success);
#endif
}
char stack[1024];
int main()
{
assert(!emscripten_current_thread_is_wasm_worker());
emscripten_wasm_worker_t worker = emscripten_create_wasm_worker(stack, sizeof(stack));
emscripten_wasm_worker_post_function_v(worker, v);
emscripten_wasm_worker_post_function_vi(worker, vi, 1);
emscripten_wasm_worker_post_function_vii(worker, vii, 2, 3);
emscripten_wasm_worker_post_function_viii(worker, viii, 4, 5, 6);
emscripten_wasm_worker_post_function_vd(worker, vd, 1.5);
emscripten_wasm_worker_post_function_vdd(worker, vdd, 2.5, 3.5);
emscripten_wasm_worker_post_function_vddd(worker, vddd, 4.5, 5.5, 6.5);
emscripten_wasm_worker_post_function_sig(worker, viiiiiidddddd, "iiiiiidddddd", 10, 11, 12, 13, 14, 15, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5);
emscripten_wasm_worker_post_function_v(worker, test_finished);
}