File: post_function.c

package info (click to toggle)
emscripten 3.1.69%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 121,860 kB
  • sloc: ansic: 636,110; cpp: 425,974; javascript: 78,401; python: 58,404; sh: 49,154; pascal: 5,237; makefile: 3,366; asm: 2,415; lisp: 1,869
file content (104 lines) | stat: -rw-r--r-- 2,273 bytes parent folder | download | duplicates (2)
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
#include <emscripten.h>
#include <emscripten/console.h>
#include <emscripten/wasm_worker.h>
#include <assert.h>

// Test emscripten_wasm_worker_post_function_*() API

volatile int success = 0;

void v()
{
  emscripten_console_log("v");
  ++success;
}

void vi(int i)
{
  emscripten_console_log("vi");
  assert(i == 1);
  ++success;
}

void vii(int i, int j)
{
  emscripten_console_log("vii");
  assert(i == 2);
  assert(j == 3);
  ++success;
}

void viii(int i, int j, int k)
{
  emscripten_console_log("viii");
  assert(i == 4);
  assert(j == 5);
  assert(k == 6);
  ++success;
}

void vd(double i)
{
  emscripten_console_log("vd");
  assert(i == 1.5);
  ++success;
}

void vdd(double i, double j)
{
  emscripten_console_log("vdd");
  assert(i == 2.5);
  assert(j == 3.5);
  ++success;
}

void vddd(double i, double j, double k)
{
  emscripten_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)
{
  emscripten_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);
}