* config/pa/pa.c (pa_option_override): Remove auto increment FIXME.
[official-gcc.git] / libgcc / libgcov.h
blob1e831de698acbcca9f96eb66e000cbfc4cd443fc
1 /* Header file for libgcov-*.c.
2 Copyright (C) 1996-2014 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 #ifndef GCC_LIBGCOV_H
26 #define GCC_LIBGCOV_H
28 /* work around the poisoned malloc/calloc in system.h. */
29 #ifndef xmalloc
30 #define xmalloc malloc
31 #endif
32 #ifndef xcalloc
33 #define xcalloc calloc
34 #endif
36 #include "tconfig.h"
37 #include "tsystem.h"
38 #include "coretypes.h"
39 #include "tm.h"
40 #include "libgcc_tm.h"
42 #if BITS_PER_UNIT == 8
43 typedef unsigned gcov_unsigned_t __attribute__ ((mode (SI)));
44 typedef unsigned gcov_position_t __attribute__ ((mode (SI)));
45 #if LONG_LONG_TYPE_SIZE > 32
46 typedef signed gcov_type __attribute__ ((mode (DI)));
47 typedef unsigned gcov_type_unsigned __attribute__ ((mode (DI)));
48 #else
49 typedef signed gcov_type __attribute__ ((mode (SI)));
50 typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI)));
51 #endif
52 #else
53 #if BITS_PER_UNIT == 16
54 typedef unsigned gcov_unsigned_t __attribute__ ((mode (HI)));
55 typedef unsigned gcov_position_t __attribute__ ((mode (HI)));
56 #if LONG_LONG_TYPE_SIZE > 32
57 typedef signed gcov_type __attribute__ ((mode (SI)));
58 typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI)));
59 #else
60 typedef signed gcov_type __attribute__ ((mode (HI)));
61 typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI)));
62 #endif
63 #else
64 typedef unsigned gcov_unsigned_t __attribute__ ((mode (QI)));
65 typedef unsigned gcov_position_t __attribute__ ((mode (QI)));
66 #if LONG_LONG_TYPE_SIZE > 32
67 typedef signed gcov_type __attribute__ ((mode (HI)));
68 typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI)));
69 #else
70 typedef signed gcov_type __attribute__ ((mode (QI)));
71 typedef unsigned gcov_type_unsigned __attribute__ ((mode (QI)));
72 #endif
73 #endif
74 #endif
76 #if defined (TARGET_POSIX_IO)
77 #define GCOV_LOCKED 1
78 #else
79 #define GCOV_LOCKED 0
80 #endif
82 #if defined(inhibit_libc)
83 #define IN_LIBGCOV (-1)
84 #else
85 #define IN_LIBGCOV 1
86 #if defined(L_gcov)
87 #define GCOV_LINKAGE /* nothing */
88 #endif
89 #endif
91 /* In libgcov we need these functions to be extern, so prefix them with
92 __gcov. In libgcov they must also be hidden so that the instance in
93 the executable is not also used in a DSO. */
94 #define gcov_var __gcov_var
95 #define gcov_open __gcov_open
96 #define gcov_close __gcov_close
97 #define gcov_write_tag_length __gcov_write_tag_length
98 #define gcov_position __gcov_position
99 #define gcov_seek __gcov_seek
100 #define gcov_rewrite __gcov_rewrite
101 #define gcov_is_error __gcov_is_error
102 #define gcov_write_unsigned __gcov_write_unsigned
103 #define gcov_write_counter __gcov_write_counter
104 #define gcov_write_summary __gcov_write_summary
105 #define gcov_read_unsigned __gcov_read_unsigned
106 #define gcov_read_counter __gcov_read_counter
107 #define gcov_read_summary __gcov_read_summary
109 /* Poison these, so they don't accidentally slip in. */
110 #pragma GCC poison gcov_write_string gcov_write_tag gcov_write_length
111 #pragma GCC poison gcov_time gcov_magic
113 #ifdef HAVE_GAS_HIDDEN
114 #define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden")))
115 #else
116 #define ATTRIBUTE_HIDDEN
117 #endif
119 #include "gcov-io.h"
121 /* Structures embedded in coveraged program. The structures generated
122 by write_profile must match these. */
124 /* Information about counters for a single function. */
125 struct gcov_ctr_info
127 gcov_unsigned_t num; /* number of counters. */
128 gcov_type *values; /* their values. */
131 /* Information about a single function. This uses the trailing array
132 idiom. The number of counters is determined from the merge pointer
133 array in gcov_info. The key is used to detect which of a set of
134 comdat functions was selected -- it points to the gcov_info object
135 of the object file containing the selected comdat function. */
137 struct gcov_fn_info
139 const struct gcov_info *key; /* comdat key */
140 gcov_unsigned_t ident; /* unique ident of function */
141 gcov_unsigned_t lineno_checksum; /* function lineo_checksum */
142 gcov_unsigned_t cfg_checksum; /* function cfg checksum */
143 struct gcov_ctr_info ctrs[0]; /* instrumented counters */
146 /* Type of function used to merge counters. */
147 typedef void (*gcov_merge_fn) (gcov_type *, gcov_unsigned_t);
149 /* Information about a single object file. */
150 struct gcov_info
152 gcov_unsigned_t version; /* expected version number */
153 struct gcov_info *next; /* link to next, used by libgcov */
155 gcov_unsigned_t stamp; /* uniquifying time stamp */
156 const char *filename; /* output file name */
158 gcov_merge_fn merge[GCOV_COUNTERS]; /* merge functions (null for
159 unused) */
161 unsigned n_functions; /* number of functions */
162 const struct gcov_fn_info *const *functions; /* pointer to pointers
163 to function information */
166 /* Register a new object file module. */
167 extern void __gcov_init (struct gcov_info *) ATTRIBUTE_HIDDEN;
169 /* Called before fork, to avoid double counting. */
170 extern void __gcov_flush (void) ATTRIBUTE_HIDDEN;
172 /* Function to reset all counters to 0. */
173 extern void __gcov_reset (void);
175 /* Function to enable early write of profile information so far. */
176 extern void __gcov_dump (void);
178 /* The merge function that just sums the counters. */
179 extern void __gcov_merge_add (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
181 /* The merge function to select the minimum valid counter value. */
182 extern void __gcov_merge_time_profile (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
184 /* The merge function to choose the most common value. */
185 extern void __gcov_merge_single (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
187 /* The merge function to choose the most common difference between
188 consecutive values. */
189 extern void __gcov_merge_delta (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
191 /* The merge function that just ors the counters together. */
192 extern void __gcov_merge_ior (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
194 /* The profiler functions. */
195 extern void __gcov_interval_profiler (gcov_type *, gcov_type, int, unsigned);
196 extern void __gcov_pow2_profiler (gcov_type *, gcov_type);
197 extern void __gcov_one_value_profiler (gcov_type *, gcov_type);
198 extern void __gcov_indirect_call_profiler (gcov_type*, gcov_type,
199 void*, void*);
200 extern void __gcov_indirect_call_profiler_v2 (gcov_type, void *);
201 extern void __gcov_time_profiler (gcov_type *);
202 extern void __gcov_average_profiler (gcov_type *, gcov_type);
203 extern void __gcov_ior_profiler (gcov_type *, gcov_type);
205 #ifndef inhibit_libc
206 /* The wrappers around some library functions.. */
207 extern pid_t __gcov_fork (void) ATTRIBUTE_HIDDEN;
208 extern int __gcov_execl (const char *, char *, ...) ATTRIBUTE_HIDDEN;
209 extern int __gcov_execlp (const char *, char *, ...) ATTRIBUTE_HIDDEN;
210 extern int __gcov_execle (const char *, char *, ...) ATTRIBUTE_HIDDEN;
211 extern int __gcov_execv (const char *, char *const []) ATTRIBUTE_HIDDEN;
212 extern int __gcov_execvp (const char *, char *const []) ATTRIBUTE_HIDDEN;
213 extern int __gcov_execve (const char *, char *const [], char *const [])
214 ATTRIBUTE_HIDDEN;
216 /* Functions that only available in libgcov. */
217 GCOV_LINKAGE int gcov_open (const char */*name*/) ATTRIBUTE_HIDDEN;
218 GCOV_LINKAGE void gcov_write_counter (gcov_type) ATTRIBUTE_HIDDEN;
219 GCOV_LINKAGE void gcov_write_tag_length (gcov_unsigned_t, gcov_unsigned_t)
220 ATTRIBUTE_HIDDEN;
221 GCOV_LINKAGE void gcov_write_summary (gcov_unsigned_t /*tag*/,
222 const struct gcov_summary *)
223 ATTRIBUTE_HIDDEN;
224 GCOV_LINKAGE void gcov_seek (gcov_position_t /*position*/) ATTRIBUTE_HIDDEN;
225 GCOV_LINKAGE inline void gcov_rewrite (void);
227 #endif /* !inhibit_libc */
229 #endif /* GCC_LIBGCOV_H */