]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/gcov-info-to-gcda.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / gcov-info-to-gcda.c
CommitLineData
d8a62882 1/* { dg-do run { target *-*-linux* *-*-gnu* } } */
9124bbe1
SH
2/* { dg-options "-fprofile-arcs -fprofile-info-section" } */
3
4#define assert(expr) \
5 ((expr) \
6 ? (void)0 \
7 : (__builtin_printf ("%s:%i: Assertion `%s' failed.\n", \
8 __FILE__, __LINE__, #expr), \
9 __builtin_abort ()))
10
11struct gcov_info;
12
13extern void
14__gcov_info_to_gcda (const struct gcov_info *__info,
15 void (*__filename_fn) (const char *, void *),
16 void (*__dump_fn) (const void *, unsigned, void *),
17 void *(*__allocate_fn) (unsigned, void *),
18 void *__arg);
19
20extern const struct gcov_info *my_info;
21
22static unsigned counter;
23
24static void
25filename (const char *f, void *arg)
26{
27 assert (arg == &counter);
28 assert (__builtin_strstr (f, "gcov-info-to-gcda.c") == 0);
29}
30
31static void
32dump (const void *d, unsigned n, void *arg)
33{
34 unsigned *m = (unsigned *)arg;
35 assert (arg == &counter);
36
37 if (*m == 0)
38 {
39 const unsigned *u = d;
40 assert (*u == 0x67636461);
41 }
42
43 *m += n;
44}
45
46static void *
47allocate (unsigned length, void *arg)
48{
49 assert (arg == &counter);
50 return __builtin_malloc (length);
51}
52
53int main()
54{
55 __asm__ volatile (".set my_info, .LPBX2");
56 __gcov_info_to_gcda (my_info, filename, dump, allocate, &counter);
57 assert (counter > 4);
58 return 0;
59}