2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / eeprof-1.c
blob248b8ccbe0125a5318335b0af0f336fbedaef9bd
1 #define ASSERT(X) if (!(X)) abort ();
2 #define NOCHK __attribute__ ((no_instrument_function))
4 int entry_calls, exit_calls;
5 void (*last_fn_entered)();
6 void (*last_fn_exited)();
8 __attribute__ ((noinline))
9 int main () NOCHK;
11 __attribute__ ((noinline))
12 void foo ()
14 ASSERT (last_fn_entered == foo);
17 __attribute__ ((noinline))
18 static void foo2 ()
20 ASSERT (entry_calls == 1 && exit_calls == 0);
21 ASSERT (last_fn_entered == foo2);
22 foo ();
23 ASSERT (entry_calls == 2 && exit_calls == 1);
24 ASSERT (last_fn_entered == foo);
25 ASSERT (last_fn_exited == foo);
28 __attribute__ ((noinline))
29 void nfoo (void) NOCHK;
30 void nfoo ()
32 ASSERT (entry_calls == 2 && exit_calls == 2);
33 ASSERT (last_fn_entered == foo);
34 ASSERT (last_fn_exited == foo2);
35 foo ();
36 ASSERT (entry_calls == 3 && exit_calls == 3);
37 ASSERT (last_fn_entered == foo);
38 ASSERT (last_fn_exited == foo);
41 int main ()
43 ASSERT (entry_calls == 0 && exit_calls == 0);
45 foo2 ();
47 ASSERT (entry_calls == 2 && exit_calls == 2);
48 ASSERT (last_fn_entered == foo);
49 ASSERT (last_fn_exited == foo2);
51 nfoo ();
53 ASSERT (entry_calls == 3 && exit_calls == 3);
54 ASSERT (last_fn_entered == foo);
56 return 0;
59 void __cyg_profile_func_enter (void (*fn)(), void (*parent)()) NOCHK;
60 void __cyg_profile_func_exit (void (*fn)(), void (*parent)()) NOCHK;
62 __attribute__ ((noinline))
63 void __cyg_profile_func_enter (void (*fn)(), void (*parent)())
65 entry_calls++;
66 last_fn_entered = fn;
68 __attribute__ ((noinline))
69 void __cyg_profile_func_exit (void (*fn)(), void (*parent)())
71 exit_calls++;
72 last_fn_exited = fn;