Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / gcov-info-to-gcda.c
blobca9b3e831fe7db720e7443d994b95f298ba35a58
1 /* { dg-do run { target *-*-linux* *-*-gnu* } } */
2 /* { dg-options "-fprofile-arcs -fprofile-info-section" } */
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 ()))
11 struct gcov_info;
13 extern 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);
20 extern void
21 __gcov_filename_to_gcfn (const char *__filename,
22 void (*__dump_fn) (const void *, unsigned, void *),
23 void *__arg);
25 extern const struct gcov_info *my_info;
27 static unsigned counter;
29 static unsigned counter_after_filename;
31 static int check_zero;
33 static int check_after_filename;
35 static void
36 dump (const void *d, unsigned n, void *arg)
38 unsigned *m = (unsigned *)arg;
39 assert (arg == &counter);
41 if (*m == 0)
43 const unsigned *u = d;
44 assert (*u == 0x6763666e);
45 check_zero = 1;
47 else if (*m == counter_after_filename)
49 const unsigned *u = d;
50 assert (*u == 0x67636461);
51 check_after_filename = 1;
54 *m += n;
57 static void
58 filename (const char *f, void *arg)
60 assert (arg == &counter);
61 assert (__builtin_strstr (f, "gcov-info-to-gcda.c") == 0);
62 __gcov_filename_to_gcfn (f, dump, arg);
63 counter_after_filename = counter;
66 static void *
67 allocate (unsigned length, void *arg)
69 assert (arg == &counter);
70 return __builtin_malloc (length);
73 int main()
75 __asm__ volatile (".set my_info, .LPBX2");
76 __gcov_info_to_gcda (my_info, filename, dump, allocate, &counter);
77 assert (counter > 8);
78 assert (check_zero);
79 assert (check_after_filename);
80 return 0;