aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcov-io.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2003-05-07 10:40:09 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2003-05-07 10:40:09 +0000
commit474f141e8d6c6808888ad42842c7cc179c6d3525 (patch)
treeaa2fd5f968bcc9f49c44463d7bb9b157b0c4d790 /gcc/gcov-io.c
parent6cbeaa7e52a2ba53925b916a4b181d63e2712014 (diff)
downloadgcc-474f141e8d6c6808888ad42842c7cc179c6d3525.zip
gcc-474f141e8d6c6808888ad42842c7cc179c6d3525.tar.gz
gcc-474f141e8d6c6808888ad42842c7cc179c6d3525.tar.bz2
gcov-io.h (GCOV_LOCKED): New #define.
* gcov-io.h (GCOV_LOCKED): New #define. (GCOV_LINKAGE): Make sure it is #defined. (gcov_write_string, gcov_write_tag, gcov_write_length, gcov_read_string, gcov_time): Poison in libgcov. (gcov_seek_end): Remove. (gcov_write_tag_length, gcov_sync, gcov_rewrite): New. (GCOV_TAG_FUNCTION_LENGTH, GCOV_TAG_BLOCKS_LENGTH, GCOV_TAG_ARCS_LENGTH, GCOV_TAG_COUNTER_LENGTH, GCOV_TAG_SUMMARY_LENGTH): New #defines. (gcov_write_tag, gcov_write_length): Not in libgcov. * gcov-io.c (gcov_open): Use GCOV_LOCKED. (gcov_write_tag, gcov_write_length): Not in libgcov. (gcov_write_tag_length): New. (gcov_write_summary): Use gcov_write_tag_length. * libgcov.c: Always #include gcov-io.h. (IN_LIBGCOV): -1 for inhibit_libc, +1 otherwise. (GCOV_LINKAGE): Define to nothing for L_gcov. (gcov_exit): Replace gcov_write_tag, gcov_write_length with gcov_write_tag_length. Use gcov_rewrite & gcov_seek. * gcov.c (read_graph_file): Replace gcov_seek by gcov_sync. (read_count_file): Likewise. * gcov-dump.c (dump_file): Likewise. * coverag.c (read_counts_file): Likewise. From-SVN: r66555
Diffstat (limited to 'gcc/gcov-io.c')
-rw-r--r--gcc/gcov-io.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index 2f2a87f..188d27a 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -37,7 +37,7 @@ gcov_open (const char *name, int mode)
{
int result = 1;
size_t alloc = 1024;
-#if defined (TARGET_HAS_F_SETLKW) && IN_LIBGCOV
+#if GCOV_LOCKED
struct flock s_flock;
s_flock.l_type = F_WRLCK;
@@ -61,7 +61,7 @@ gcov_open (const char *name, int mode)
if (!gcov_var.file)
return 0;
-#if defined (TARGET_HAS_F_SETLKW) && IN_LIBGCOV
+#if GCOV_LOCKED
while (fcntl (fileno (gcov_var.file), F_SETLKW, &s_flock)
&& errno == EINTR)
continue;
@@ -257,6 +257,7 @@ gcov_write_string (const char *string)
}
#endif
+#if !IN_LIBGCOV
/* Write a tag TAG and reserve space for the record length. Return a
value to be used for gcov_write_length. */
@@ -299,6 +300,30 @@ gcov_write_length (unsigned long position)
}
}
}
+#endif
+
+/* Write a tag TAG and length LENGTH. */
+
+GCOV_LINKAGE void
+gcov_write_tag_length (unsigned tag, unsigned length)
+{
+ unsigned char *buffer = gcov_write_bytes (8);
+ unsigned ix;
+
+ if (!buffer)
+ return;
+ for (ix = 4; ix--; )
+ {
+ buffer[ix] = tag;
+ tag >>= 8;
+ }
+ for (ix = 4; ix--; )
+ {
+ buffer[ix + 4] = length;
+ length >>= 8;
+ }
+ return;
+}
#if IN_LIBGCOV
/* Write a summary structure to the gcov file. Return non-zero on
@@ -309,9 +334,8 @@ gcov_write_summary (unsigned tag, const struct gcov_summary *summary)
{
unsigned ix;
const struct gcov_ctr_summary *csum;
- unsigned long base;
- base = gcov_write_tag (tag);
+ gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH);
gcov_write_unsigned (summary->checksum);
for (csum = summary->ctrs, ix = GCOV_COUNTERS; ix--; csum++)
{
@@ -321,7 +345,6 @@ gcov_write_summary (unsigned tag, const struct gcov_summary *summary)
gcov_write_counter (csum->run_max);
gcov_write_counter (csum->sum_max);
}
- gcov_write_length (base);
}
#endif /* IN_LIBGCOV */