File: test_asyncify_tricky_function_sig.cpp

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

volatile int x;

int bar() { return 1; }

__attribute__((noinline))
int foo(const char *str, int &i)
{
  if (x == 1337) return bar(); // don't inline me
  printf("foo %s\n", str);
  emscripten_sleep(1);
  printf("foo %d\n", i);
  return 42;
}

__attribute__((noinline))
int foo2()
{
  if (x == 1337) return bar(); // don't inline me
  printf("foo2 1\n");
  emscripten_sleep(1);
  printf("foo2 2\n");
  return 43;
}

int main()
{
  printf("main 1\n");
  int j = 42;
  const char *str = "hello";
  int ret = foo(str, j);
  printf("main %d\n", ret);
  int ret2 = foo2();
  printf("ret2 %d\n", ret2);
  REPORT_RESULT(ret + ret2);
}