OSDN Git Service

2004-11-16 Eric Christopher <echristo@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / gcov-io.h
index 75abbea..eaa23ad 100644 (file)
@@ -29,22 +29,21 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    the executable file might be covered by the GNU General Public License.  */
 
 /* Coverage information is held in two files.  A notes file, which is
-   generated by the compiler, and a data file, which is generated
-   by the program under test.  Both files use a similar structure.  We
-   do not attempt to make these files backwards compatible with
-   previous versions, as you only need coverage information when
-   developing a program.  We do hold version information, so that
-   mismatches can be detected, and we use a format that allows tools
-   to skip information they do not understand or are not interested
-   in.
+   generated by the compiler, and a data file, which is generated by
+   the program under test.  Both files use a similar structure.  We do
+   not attempt to make these files backwards compatible with previous
+   versions, as you only need coverage information when developing a
+   program.  We do hold version information, so that mismatches can be
+   detected, and we use a format that allows tools to skip information
+   they do not understand or are not interested in.
 
    Numbers are recorded in the 32 bit unsigned binary form of the
    endianness of the machine generating the file. 64 bit numbers are
    stored as two 32 bit numbers, the low part first.  Strings are
    padded with 1 to 4 NUL bytes, to bring the length up to a multiple
    of 4. The number of 4 bytes is stored, followed by the padded
-   string. Zero length and NULL strings are simply stored as
-   a length of zero (they have no trailing NUL or padding).
+   string. Zero length and NULL strings are simply stored as a length
+   of zero (they have no trailing NUL or padding).
 
        int32:  byte3 byte2 byte1 byte0 | byte0 byte1 byte2 byte3
        int64:  int32:low int32:high
@@ -243,7 +242,6 @@ typedef HOST_WIDEST_INT gcov_type;
 #define gcov_seek __gcov_seek
 #define gcov_rewrite __gcov_rewrite
 #define gcov_is_error __gcov_is_error
-#define gcov_is_eof __gcov_is_eof
 #define gcov_write_unsigned __gcov_write_unsigned
 #define gcov_write_counter __gcov_write_counter
 #define gcov_write_summary __gcov_write_summary
@@ -284,7 +282,8 @@ typedef HOST_WIDEST_INT gcov_type;
 
 /* The record tags.  Values [1..3f] are for tags which may be in either
    file.  Values [41..9f] for those in the note file and [a1..ff] for
-   the data file.  */
+   the data file.  The tag value zero is used as an explicit end of
+   file marker -- it is not required to be present.  */
 
 #define GCOV_TAG_FUNCTION       ((gcov_unsigned_t)0x01000000)
 #define GCOV_TAG_FUNCTION_LENGTH (2)
@@ -510,7 +509,6 @@ GCOV_LINKAGE int gcov_close (void);
 /* Available everywhere.  */
 static gcov_position_t gcov_position (void);
 static int gcov_is_error (void);
-static int gcov_is_eof (void);
 
 GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned (void);
 GCOV_LINKAGE gcov_type gcov_read_counter (void);
@@ -522,7 +520,6 @@ GCOV_LINKAGE void gcov_write_counter (gcov_type);
 GCOV_LINKAGE void gcov_write_tag_length (gcov_unsigned_t, gcov_unsigned_t);
 GCOV_LINKAGE void gcov_write_summary (gcov_unsigned_t /*tag*/,
                                      const struct gcov_summary *);
-static void gcov_truncate (void);
 static void gcov_rewrite (void);
 GCOV_LINKAGE void gcov_seek (gcov_position_t /*position*/);
 #else
@@ -550,10 +547,15 @@ GCOV_LINKAGE time_t gcov_time (void);
 #endif
 
 /* Make sure the library is used correctly.  */
+#if IN_LIBGCOV
 #if ENABLE_CHECKING
-#define GCOV_CHECK(expr) ((expr) ? (void)0 : (void)abort ())
+#define GCOV_CHECK(EXPR) (!(EXPR) ? abort (), 0 : 0)
+#else
+/* Include EXPR, so that unused variable warnings do not occur.  */
+#define GCOV_CHECK(EXPR) ((void)(0 && (EXPR)))
+#endif
 #else
-#define GCOV_CHECK(expr)
+#define GCOV_CHECK(EXPR) gcc_assert (EXPR)
 #endif
 #define GCOV_CHECK_READING() GCOV_CHECK(gcov_var.mode > 0)
 #define GCOV_CHECK_WRITING() GCOV_CHECK(gcov_var.mode < 0)
@@ -567,14 +569,6 @@ gcov_position (void)
   return gcov_var.start + gcov_var.offset;
 }
 
-/* Return nonzero if we read to end of file.  */
-
-static inline int
-gcov_is_eof (void)
-{
-  return !gcov_var.overread;
-}
-
 /* Return nonzero if the error flag is set.  */
 
 static inline int
@@ -595,15 +589,6 @@ gcov_rewrite (void)
   gcov_var.offset = 0;
   fseek (gcov_var.file, 0L, SEEK_SET);
 }
-
-#ifdef __MINGW32__
-#define ftruncate _chsize
-#endif
-static inline void
-gcov_truncate (void)
-{
-  ftruncate (fileno (gcov_var.file), 0L);
-}
 #endif
 
 #endif /* IN_LIBGCOV >= 0 */