diff options
author | rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-04 15:20:26 +0000 |
---|---|---|
committer | rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-05-04 15:20:26 +0000 |
commit | 35cb45c4eaeb15d82c29d4555824c4fe2f7d1678 (patch) | |
tree | 05de4edb80cb0ae6e59ff9b0f5b6509cae6fde04 /gcc/libgcov.c | |
parent | 65ff8f7314508add07c15d6c9d77e2724318bdeb (diff) | |
download | gcc-35cb45c4eaeb15d82c29d4555824c4fe2f7d1678.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66457 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/libgcov.c')
-rw-r--r-- | gcc/libgcov.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/gcc/libgcov.c b/gcc/libgcov.c index a40611494fc..74e8fa123de 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 */ |