summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/gcov-io.h
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2002-02-01 18:16:02 +0000
committerobrien <obrien@FreeBSD.org>2002-02-01 18:16:02 +0000
commitc9ab9ae440a8066b2c2b85b157b1fdadcf09916a (patch)
tree086d9d6c8fbd4fc8fe4495059332f66bc0f8d12b /contrib/gcc/gcov-io.h
parent2ecfd8bd04b63f335c1ec6295740a4bfd97a4fa6 (diff)
downloadFreeBSD-src-c9ab9ae440a8066b2c2b85b157b1fdadcf09916a.zip
FreeBSD-src-c9ab9ae440a8066b2c2b85b157b1fdadcf09916a.tar.gz
Enlist the FreeBSD-CURRENT users as testers of what is to become Gcc 3.1.0.
These bits are taken from the FSF anoncvs repo on 1-Feb-2002 08:20 PST.
Diffstat (limited to 'contrib/gcc/gcov-io.h')
-rw-r--r--contrib/gcc/gcov-io.h112
1 files changed, 83 insertions, 29 deletions
diff --git a/contrib/gcc/gcov-io.h b/contrib/gcc/gcov-io.h
index d2605fe..7352429 100644
--- a/contrib/gcc/gcov-io.h
+++ b/contrib/gcc/gcov-io.h
@@ -1,43 +1,46 @@
/* Machine-independent I/O routines for gcov.
- Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
Contributed by Bob Manson <manson@cygnus.com>.
-This file is part of GNU CC.
+This file is part of GCC.
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+along with GCC; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
-#ifndef GCOV_IO_H
-#define GCOV_IO_H
+#ifndef GCC_GCOV_IO_H
+#define GCC_GCOV_IO_H
#include <stdio.h>
#include <sys/types.h>
-static int __fetch_long PROTO ((long *, char *, size_t));
-static int __store_long PROTO ((long, char *, size_t));
-static int __read_long PROTO ((long *, FILE *, size_t));
-static int __write_long PROTO ((long, FILE *, size_t));
+static int __fetch_long PARAMS ((long *, char *, size_t)) ATTRIBUTE_UNUSED;
+static int __read_long PARAMS ((long *, FILE *, size_t)) ATTRIBUTE_UNUSED;
+static int __write_long PARAMS ((long, FILE *, size_t)) ATTRIBUTE_UNUSED;
+static int __fetch_gcov_type PARAMS ((gcov_type *, char *, size_t)) ATTRIBUTE_UNUSED;
+static int __store_gcov_type PARAMS ((gcov_type, char *, size_t)) ATTRIBUTE_UNUSED;
+static int __read_gcov_type PARAMS ((gcov_type *, FILE *, size_t)) ATTRIBUTE_UNUSED;
+static int __write_gcov_type PARAMS ((gcov_type, FILE *, size_t)) ATTRIBUTE_UNUSED;
-/* These routines only work for signed values. */
+/* These routines only work for signed values. */
/* Store a portable representation of VALUE in DEST using BYTES*8-1 bits.
Return a non-zero value if VALUE requires more than BYTES*8-1 bits
- to store. */
+ to store. */
static int
-__store_long (value, dest, bytes)
- long value;
+__store_gcov_type (value, dest, bytes)
+ gcov_type value;
char *dest;
size_t bytes;
{
@@ -46,7 +49,7 @@ __store_long (value, dest, bytes)
if (value < 0)
{
- long oldvalue = value;
+ gcov_type oldvalue = value;
value = -value;
if (oldvalue != -value)
return 1;
@@ -68,7 +71,30 @@ __store_long (value, dest, bytes)
/* Retrieve a quantity containing BYTES*8-1 bits from SOURCE and store
the result in DEST. Returns a non-zero value if the value in SOURCE
- will not fit in DEST. */
+ will not fit in DEST. */
+
+static int
+__fetch_gcov_type (dest, source, bytes)
+ gcov_type *dest;
+ char *source;
+ size_t bytes;
+{
+ gcov_type value = 0;
+ int i;
+
+ for (i = bytes - 1; (size_t) i > (sizeof (*dest) - 1); i--)
+ if (source[i] & ((size_t) i == (bytes - 1) ? 127 : 255 ))
+ return 1;
+
+ for (; i >= 0; i--)
+ value = value * 256 + (source[i] & ((size_t)i == (bytes - 1) ? 127 : 255));
+
+ if ((source[bytes - 1] & 128) && (value > 0))
+ value = - value;
+
+ *dest = value;
+ return 0;
+}
static int
__fetch_long (dest, source, bytes)
@@ -100,7 +126,21 @@ __fetch_long (dest, source, bytes)
Note that VALUE may not actually be large enough to hold BYTES*8
bits, but BYTES characters will be written anyway.
- BYTES may be a maximum of 10. */
+ BYTES may be a maximum of 10. */
+
+static int
+__write_gcov_type (value, file, bytes)
+ gcov_type value;
+ FILE *file;
+ size_t bytes;
+{
+ char c[10];
+
+ if (bytes > 10 || __store_gcov_type (value, c, bytes))
+ return 1;
+ else
+ return fwrite(c, 1, bytes, file) != bytes;
+}
static int
__write_long (value, file, bytes)
@@ -110,7 +150,7 @@ __write_long (value, file, bytes)
{
char c[10];
- if (bytes > 10 || __store_long (value, c, bytes))
+ if (bytes > 10 || __store_gcov_type ((gcov_type)value, c, bytes))
return 1;
else
return fwrite(c, 1, bytes, file) != bytes;
@@ -123,7 +163,21 @@ __write_long (value, file, bytes)
Note that DEST may not be large enough to hold all of the requested
data, but the function will read BYTES characters anyway.
- BYTES may be a maximum of 10. */
+ BYTES may be a maximum of 10. */
+
+static int
+__read_gcov_type (dest, file, bytes)
+ gcov_type *dest;
+ FILE *file;
+ size_t bytes;
+{
+ char c[10];
+
+ if (bytes > 10 || fread(c, 1, bytes, file) != bytes)
+ return 1;
+ else
+ return __fetch_gcov_type (dest, c, bytes);
+}
static int
__read_long (dest, file, bytes)
@@ -139,4 +193,4 @@ __read_long (dest, file, bytes)
return __fetch_long (dest, c, bytes);
}
-#endif
+#endif /* ! GCC_GCOV_IO_H */
OpenPOWER on IntegriCloud