aboutsummaryrefslogtreecommitdiff
path: root/gcc/libgcov.c
diff options
context:
space:
mode:
authorZdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>2003-05-04 17:20:26 +0200
committerZdenek Dvorak <rakdver@gcc.gnu.org>2003-05-04 15:20:26 +0000
commit09780dfb652960d422da1c5a9d81dc536cdf09f4 (patch)
tree05de4edb80cb0ae6e59ff9b0f5b6509cae6fde04 /gcc/libgcov.c
parentc71f2ffd78811e3aaafdca4618c737c0c10e72ca (diff)
downloadgcc-09780dfb652960d422da1c5a9d81dc536cdf09f4.zip
gcc-09780dfb652960d422da1c5a9d81dc536cdf09f4.tar.gz
gcc-09780dfb652960d422da1c5a9d81dc536cdf09f4.tar.bz2
Makefile.in (LIBGCOV): Add _gcov_merge_add.
* Makefile.in (LIBGCOV): Add _gcov_merge_add. * gcov-io.h: Make GCOV_LINKAGE extern in libgcov and prevent resulting namespace clash. (GCOV_MERGE_FUNCTIONS): New. (gcov_merge_fn): Declare. (struct gcov_ctr_info): New field "merge". (__gcov_merge_add): Declare. * coverage.c (ctr_merge_functions): New. (build_ctr_info_type, build_ctr_info_value): Initialize merge field of gcov_ctr_info type. * libgcov.c (__gcov_merge_add): New. (gcov_exit): Call a hook to merge values of counters. From-SVN: r66457
Diffstat (limited to 'gcc/libgcov.c')
-rw-r--r--gcc/libgcov.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/gcc/libgcov.c b/gcc/libgcov.c
index a406114..74e8fa1 100644
--- a/gcc/libgcov.c
+++ b/gcc/libgcov.c
@@ -32,11 +32,19 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#if defined(inhibit_libc)
/* If libc and its header files are not available, provide dummy functions. */
+#ifdef L_gcov
void __gcov_init (void *p);
void __gcov_flush (void);
void __gcov_init (void *p) { }
void __gcov_flush (void) { }
+#endif
+
+#ifdef L_gcov_merge_add
+void __gcov_merge_add (gcov_type *, unsigned);
+
+void __gcov_merge_add (gcov_type *counters, unsigned n_counters) { }
+#endif
#else
@@ -59,6 +67,8 @@ void __gcov_flush (void) { }
#endif
#define IN_LIBGCOV 1
#include "gcov-io.h"
+
+#ifdef L_gcov
#include "gcov-io.c"
/* Chain of per-object gcov structures. */
@@ -227,7 +237,7 @@ gcov_exit (void)
if ((1 << t_ix) & gi_ptr->ctr_mask)
{
unsigned n_counts;
- gcov_type *c_ptr;
+ gcov_merge_fn merge;
tag = gcov_read_unsigned ();
length = gcov_read_unsigned ();
@@ -235,11 +245,10 @@ gcov_exit (void)
if (tag != GCOV_TAG_FOR_COUNTER (t_ix)
|| fi_ptr->n_ctrs[c_ix] * 8 != length)
goto read_mismatch;
- c_ptr = values[c_ix];
- for (n_counts = fi_ptr->n_ctrs[c_ix];
- n_counts--; c_ptr++)
- *c_ptr += gcov_read_counter ();
- values[c_ix] = c_ptr;
+ n_counts = fi_ptr->n_ctrs[c_ix];
+ merge = gi_ptr->counts[c_ix].merge;
+ (*merge) (values[c_ix], n_counts);
+ values[c_ix] += n_counts;
c_ix++;
}
if ((error = gcov_is_error ()))
@@ -450,4 +459,20 @@ __gcov_flush (void)
}
}
+#endif /* L_gcov */
+
+#ifdef L_gcov_merge_add
+/* The profile merging function that just adds the counters. It is given
+ an array COUNTERS of N_COUNTERS old counters and it reads the same number
+ of counters from the gcov file. */
+void
+__gcov_merge_add (counters, n_counters)
+ gcov_type *counters;
+ unsigned n_counters;
+{
+ for (; n_counters; counters++, n_counters--)
+ *counters += gcov_read_counter ();
+}
+#endif /* L_gcov_merge_add */
+
#endif /* inhibit_libc */