[ASan/Win] Add a comment about DCL-using-static vs threads
[blocksruntime.git] / test / msan / wrap_indirect_calls / caller.cc
bloba0af8b7bb0c53988554a07fcf96f26e0e1b5dedc
1 // Indirectly call a bunch of functions.
3 #include <assert.h>
5 extern int cnt;
7 typedef int (*F)(int, int);
9 // A function in the same object.
10 int f_local(int x, int y) {
11 return x + y;
14 // A function in another object.
15 int f_other_object(int x, int y);
17 // A function in another DSO.
18 int f_dso(int x, int y);
20 // A function in another DSO that is replaced by the wrapper.
21 int f_replaced(int x, int y);
23 void run_test(void) {
24 int x;
25 int expected_cnt = 0;
26 volatile F f;
28 if (SLOW) ++expected_cnt;
29 f = &f_local;
30 x = f(1, 2);
31 assert(x == 3);
32 assert(cnt == expected_cnt);
34 if (SLOW) ++expected_cnt;
35 f = &f_other_object;
36 x = f(2, 3);
37 assert(x == 6);
38 assert(cnt == expected_cnt);
40 ++expected_cnt;
41 f = &f_dso;
42 x = f(2, 3);
43 assert(x == 7);
44 assert(cnt == expected_cnt);
46 ++expected_cnt;
47 f = &f_replaced;
48 x = f(2, 3);
49 assert(x == 11);
50 assert(cnt == expected_cnt);