summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2007-10-04 07:56:12 +0000
committerlaranjeiro2007-10-04 07:56:12 +0000
commit3943e4129977f6a034134a8ff6b41fcbaada0c05 (patch)
tree9d570ef72cb5d72feb920aeb17a9fa0a8e37e1e0
parent0210f4eb65c0c8987fa72ab21b1c05386d3b8eae (diff)
Add Gcov to Ecos for ecoscentric.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@767 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--ecos/packages/ecos.db11
-rw-r--r--ecos/packages/services/gcov/current/cdl/services_gcov.cdl30
-rw-r--r--ecos/packages/services/gcov/current/doc/README17
-rw-r--r--ecos/packages/services/gcov/current/doc/gcov-doc.tex41
-rw-r--r--ecos/packages/services/gcov/current/doc/makefile19
-rw-r--r--ecos/packages/services/gcov/current/gcovadd.db8
-rw-r--r--ecos/packages/services/gcov/current/include/gbl-ctors.h88
-rw-r--r--ecos/packages/services/gcov/current/include/gcov-io.h199
-rw-r--r--ecos/packages/services/gcov/current/include/gcov.h35
-rw-r--r--ecos/packages/services/gcov/current/include/gcov_ecos.h158
-rw-r--r--ecos/packages/services/gcov/current/include/gcov_fio.h232
-rw-r--r--ecos/packages/services/gcov/current/include/gcov_types.h51
-rw-r--r--ecos/packages/services/gcov/current/src/gcov_bb.c254
-rw-r--r--ecos/packages/services/gcov/current/src/gcov_ecos.c256
14 files changed, 1398 insertions, 1 deletions
diff --git a/ecos/packages/ecos.db b/ecos/packages/ecos.db
index 65ce7fa0c4..3e68b70ef4 100644
--- a/ecos/packages/ecos.db
+++ b/ecos/packages/ecos.db
@@ -582,7 +582,8 @@ target linux {
CYGPKG_DEVS_FLASH_SYNTH
CYGPKG_DEVS_ETH_ECOSYNTH
CYGPKG_DEVS_WATCHDOG_SYNTH
- CYGPKG_DEVS_WALLCLOCK_SYNTH
+ CYGPKG_DEVS_WALLCLOCK_SYNTH
+ CYGPKG_GCOV
}
description "
The linux target provides the
@@ -664,3 +665,11 @@ package CYGPKG_BLOCK_LIB {
This package contains the block cache and access library."
}
+
+package CYGPKG_GCOV {
+ alias { "Gcov for ECOS" gcov }
+ directory services/gcov/
+ script services_gcov.cdl
+ description "
+ This package contains the gcov source to use with ecos."
+}
diff --git a/ecos/packages/services/gcov/current/cdl/services_gcov.cdl b/ecos/packages/services/gcov/current/cdl/services_gcov.cdl
new file mode 100644
index 0000000000..05fd4c6ea3
--- /dev/null
+++ b/ecos/packages/services/gcov/current/cdl/services_gcov.cdl
@@ -0,0 +1,30 @@
+# ====================================================================
+#
+# services_gcov.cdl
+#
+# gcov for Ecos
+# This version of gcov only works with gcc 3.2.1 due to the
+# way the gcov in gcc is made.
+#
+# ====================================================================
+######DESCRIPTIONBEGIN####
+#
+# Author(s): jpSave
+# Original data: jpSave
+# Contributors: SPiDCOM
+# Date: 03/10/2007
+#
+#####DESCRIPTIONEND####
+#
+# ====================================================================
+
+cdl_package CYGPKG_GCOV {
+ display "Gcov"
+ include_dir cyg/gcov
+
+ compile gcov_ecos.c gcov_bb.c
+ description "
+ Gcov for ecos to be compile with gcc 3.2.1"
+ }
+
+# EOF services_gcov.cdl \ No newline at end of file
diff --git a/ecos/packages/services/gcov/current/doc/README b/ecos/packages/services/gcov/current/doc/README
new file mode 100644
index 0000000000..e15ed1d518
--- /dev/null
+++ b/ecos/packages/services/gcov/current/doc/README
@@ -0,0 +1,17 @@
+SPiDCOM Technologie Gcov package
+
+Deferents formats of the documentation can be generated.
+For that you will need :
+ * latex2html
+ * pdflatex
+ * latex
+programs install in your computer.
+
+1. PDF format use :
+make pdf
+
+2. HTML format use :
+make html
+
+3. DVI format use :
+make dvi
diff --git a/ecos/packages/services/gcov/current/doc/gcov-doc.tex b/ecos/packages/services/gcov/current/doc/gcov-doc.tex
new file mode 100644
index 0000000000..44219d6747
--- /dev/null
+++ b/ecos/packages/services/gcov/current/doc/gcov-doc.tex
@@ -0,0 +1,41 @@
+\documentclass[a4paper,10pt]{article}
+
+
+%opening
+\title{Gcov for Ecos}
+\author{SPiDCOM Technologies}
+
+\begin{document}
+
+\maketitle
+
+\begin{abstract}
+Gcov for Ecos.
+\end{abstract}
+
+\section {Package Gcov for gcc 3.2.1}
+
+\subsection{Files}
+
+The files used for this package are some of the gnu gcov files.\\
+The others ones are only sources files to detect the version of the compiler and use the system function to use gcov with ecos.
+
+\subsection{Version}
+
+This version of gcov actually works with the gnu gcc compiler with the version 3.2.1, the other ones does not work.\\
+
+\subsection{Files generated}
+
+The file generated by this version are~:
+\begin{itemize}
+ \item .bb
+ \item .bbg
+ \item .da
+\end{itemize}
+
+\subsection{How to check the coverage}
+
+To verfify the coverage of the test use the gcov tool of ecos with the following command~:\\
+i386-elf-gcov $<$name\_of\_src.da$>$
+
+\end{document}
diff --git a/ecos/packages/services/gcov/current/doc/makefile b/ecos/packages/services/gcov/current/doc/makefile
new file mode 100644
index 0000000000..01856feb09
--- /dev/null
+++ b/ecos/packages/services/gcov/current/doc/makefile
@@ -0,0 +1,19 @@
+src = gcov-doc
+
+pdf : $(src).tex
+ pdflatex $(src).tex
+ rm -f $(src).aux
+ rm -f $(src).log
+
+html : $(src)
+ latex2html $(src).tex
+
+dvi : $(src)
+ latex $(src).tex
+ rm -f $(src).aux
+ rm -f $(src).log
+
+clean :
+ rm -f $(src).pdf
+ rm -f $(src).dvi
+ rm -rf $(src) \ No newline at end of file
diff --git a/ecos/packages/services/gcov/current/gcovadd.db b/ecos/packages/services/gcov/current/gcovadd.db
new file mode 100644
index 0000000000..b898b0a3c0
--- /dev/null
+++ b/ecos/packages/services/gcov/current/gcovadd.db
@@ -0,0 +1,8 @@
+package CYGPKG_GCOV {
+ alias { "Gcov for ECOS" gcov }
+ directory services/gcov/
+ script services_gcov.cdl
+ description "
+ This package contains the gcov source to use with ecos."
+}
+
diff --git a/ecos/packages/services/gcov/current/include/gbl-ctors.h b/ecos/packages/services/gcov/current/include/gbl-ctors.h
new file mode 100644
index 0000000000..424afcabc0
--- /dev/null
+++ b/ecos/packages/services/gcov/current/include/gbl-ctors.h
@@ -0,0 +1,88 @@
+#ifndef GBLCTORS_H_
+#define GBLCTORS_H_
+
+/* Definitions relating to the special __do_global_init function used
+ for getting g++ file-scope static objects constructed. This file
+ will get included either by libgcc2.c (for systems that don't support
+ a .init section) or by crtstuff.c (for those that do).
+ Copyright (C) 1991, 1995, 1996, 1998, 1999, 2000
+ Free Software Foundation, Inc.
+ Contributed by Ron Guilmette (rfg@segfault.us.com)
+
+This file is part of GCC.
+
+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.
+
+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 GCC; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+/* This file contains definitions and declarations of things
+ relating to the normal start-up-time invocation of C++
+ file-scope static object constructors. These declarations
+ and definitions are used by *both* libgcc2.c and by crtstuff.c.
+
+ Note that this file should only be compiled with GCC.
+*/
+
+#ifdef NEED_ATEXIT
+extern int atexit (void (*) (void));
+#endif
+
+/* Declare a pointer to void function type. */
+
+typedef void (*func_ptr) (void);
+
+/* Declare the set of symbols use as begin and end markers for the lists
+ of global object constructors and global object destructors. */
+
+extern func_ptr __CTOR_LIST__[];
+extern func_ptr __DTOR_LIST__[];
+
+/* Declare the routine which needs to get invoked at program start time. */
+
+extern void __do_global_ctors (void);
+
+/* Declare the routine which needs to get invoked at program exit time. */
+
+extern void __do_global_dtors (void);
+
+/* Define a macro with the code which needs to be executed at program
+ start-up time. This macro is used in two places in crtstuff.c (for
+ systems which support a .init section) and in one place in libgcc2.c
+ (for those system which do *not* support a .init section). For all
+ three places where this code might appear, it must be identical, so
+ we define it once here as a macro to avoid various instances getting
+ out-of-sync with one another. */
+
+/* Some systems place the number of pointers
+ in the first word of the table.
+ On other systems, that word is -1.
+ In all cases, the table is null-terminated.
+ If the length is not recorded, count up to the null. */
+
+/* Some systems use a different strategy for finding the ctors.
+ For example, svr3. */
+#ifndef DO_GLOBAL_CTORS_BODY
+#define DO_GLOBAL_CTORS_BODY \
+do { \
+ unsigned long nptrs = (unsigned long) __CTOR_LIST__[0]; \
+ unsigned i; \
+ if (nptrs == (unsigned long)-1) \
+ for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); \
+ for (i = nptrs; i >= 1; i--) \
+ __CTOR_LIST__[i] (); \
+} while (0)
+#endif
+
+
+#endif /*GBLCTORS_H_*/
diff --git a/ecos/packages/services/gcov/current/include/gcov-io.h b/ecos/packages/services/gcov/current/include/gcov-io.h
new file mode 100644
index 0000000000..be7c6123da
--- /dev/null
+++ b/ecos/packages/services/gcov/current/include/gcov-io.h
@@ -0,0 +1,199 @@
+/* Machine-independent I/O routines for gcov.
+ Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+ Contributed by Bob Manson <manson@cygnus.com>.
+
+This file is part of GCC.
+
+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.
+
+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 GCC; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#ifndef GCC_GCOV_IO_H
+#define GCC_GCOV_IO_H
+
+#ifndef GCOV_TYPES_H_
+#include <stdio.h>
+#endif
+#include <sys/types.h>
+
+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. */
+
+/* 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. */
+
+static int
+__store_gcov_type (value, dest, bytes)
+ gcov_type value;
+ char *dest;
+ size_t bytes;
+{
+ int upper_bit = (value < 0 ? 128 : 0);
+ size_t i;
+
+ if (value < 0)
+ {
+ gcov_type oldvalue = value;
+ value = -value;
+ if (oldvalue != -value)
+ return 1;
+ }
+
+ for(i = 0 ; i < (sizeof (value) < bytes ? sizeof (value) : bytes) ; i++) {
+ dest[i] = value & (i == (bytes - 1) ? 127 : 255);
+ value = value / 256;
+ }
+
+ if (value && value != -1)
+ return 1;
+
+ for(; i < bytes ; i++)
+ dest[i] = 0;
+ dest[bytes - 1] |= upper_bit;
+ return 0;
+}
+
+/* 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. */
+
+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)
+ long *dest;
+ char *source;
+ size_t bytes;
+{
+ long 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;
+}
+
+/* Write a BYTES*8-bit quantity to FILE, portably. Returns a non-zero
+ value if the write fails, or if VALUE can't be stored in BYTES*8
+ bits.
+
+ 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. */
+
+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)
+ long value;
+ FILE *file;
+ size_t bytes;
+{
+ char c[10];
+
+ if (bytes > 10 || __store_gcov_type ((gcov_type)value, c, bytes))
+ return 1;
+ else
+ return fwrite(c, 1, bytes, file) != bytes;
+}
+
+/* Read a quantity containing BYTES bytes from FILE, portably. Return
+ a non-zero value if the read fails or if the value will not fit
+ in DEST.
+
+ 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. */
+
+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)
+ long *dest;
+ FILE *file;
+ size_t bytes;
+{
+ char c[10];
+
+ if (bytes > 10 || fread(c, 1, bytes, file) != bytes)
+ return 1;
+ else
+ return __fetch_long (dest, c, bytes);
+}
+
+#endif /* ! GCC_GCOV_IO_H */
diff --git a/ecos/packages/services/gcov/current/include/gcov.h b/ecos/packages/services/gcov/current/include/gcov.h
new file mode 100644
index 0000000000..3bb3d54773
--- /dev/null
+++ b/ecos/packages/services/gcov/current/include/gcov.h
@@ -0,0 +1,35 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file gcov.c
+ * \brief gcov test of the compiler.
+ * \ingroup infra
+ *
+ */
+
+#if __GNUC__ == 3 && __GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ == 1
+
+#define fopen cyg_hal_cov_fopen
+#define fclose cyg_hal_cov_fclose
+#define lseek cyg_hal_sys_lseek
+#define ungetc cyg_hal_cov_ungetc
+#define rewind cyg_hal_cov_rewind
+#define fwrite cyg_hal_cov_fwrite
+#define fread cyg_hal_cov_fread
+
+#include <cyg/hal/hal_arch.h>
+#include <cyg/kernel/kapi.h>
+
+#include <cyg/gcov/gcov_types.h>
+#include <cyg/gcov/gcov_ecos.h>
+#include <cyg/gcov/gbl-ctors.h>
+#include <cyg/gcov/gcov-io.h>
+
+#else
+#error "compilor not supported"
+#endif
diff --git a/ecos/packages/services/gcov/current/include/gcov_ecos.h b/ecos/packages/services/gcov/current/include/gcov_ecos.h
new file mode 100644
index 0000000000..b4ebd2849b
--- /dev/null
+++ b/ecos/packages/services/gcov/current/include/gcov_ecos.h
@@ -0,0 +1,158 @@
+#ifndef gcov_ecos_h
+#define gcov_ecos_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file gcov_ecos.c
+ * \brief Redifinitions of the functions for gcov.
+ * \ingroup infra
+ *
+ *
+ * This file only works with gcc 3.2.1 and gcov 3.2.1.
+ */
+
+#include <cyg/gcov/gcov_types.h>
+
+struct FILE
+{
+ /** File descriptor */
+ int fd;
+ /** mode open */
+ char mode;
+ /** path */
+ const char *path;
+ /** the position in the file */
+ int pos;
+};
+typedef struct FILE FILE;
+
+FILE *stderr;
+
+/**
+ * Open a file as a binary file
+ *
+ * \param path the .da file path.
+ * \param mode the file open mode.
+ * \return the file descriptor.
+ *
+ * This function will allows the gcov to open a file in several :
+ * * a for apppend mode.
+ * * r for read mode
+ * * w for write mode
+ * * otherwise the file is opened in a read write mode.
+ *
+ * This function will use the open system function of ecos.
+ */
+FILE *cyg_hal_cov_fopen (const char *path, const char *mode);
+
+
+/**
+ * Close a the file correspondinf to the file descriptor.
+ *
+ * \param fp the file descriptor integer.
+ * \return zero on success, -1 on error.
+ *
+ * This function will call the close function of ecos.
+ */
+int cyg_hal_cov_fclose (FILE *fp);
+
+/**
+ * Goes to the previous byte of the file represented by the file descriptor.
+ *
+ * \param c the character to insert in the file.
+ * \param file the file descriptor
+ *
+ * \return the value of the the new position in the file from the previous
+ * one
+ *
+ * This function call lseek function provided by ecos.
+ */
+int cyg_hal_cov_ungetc (char c, FILE *file);
+
+/**
+ * Get the first character of the file
+ *
+ * \param file the file descriptor
+ *
+ * \return the character read.
+ */
+int cyg_hal_cov_fgetc(FILE *stream);
+
+/**
+ * implementation of ferror for gcov
+ *
+ * \param file the file descriptor
+ * \return always 0
+ */
+int cyg_hal_cov_ferror(FILE *stream);
+
+/**
+ * Put the file descriptor to the begining of the file.
+ *
+ * \param file the file descriptor
+ *
+ * uses the function lseek of ecos.
+ */
+void cyg_hal_cov_rewind (FILE *file);
+
+/**
+ * Write a bytes length to the file
+ *
+ * \param ptr the buffer to copy to the file
+ * \param size the element size
+ * \param nmemb the quantity of elements.
+ * \param stream the file descriptor
+ *
+ * \return the quantity of elements written in the file.
+ *
+ * Use the write function of ecos.
+ */
+size_t
+cyg_hal_cov_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream);
+
+/**
+ * Write a bytes length to the file
+ *
+ * \param ptr the buffer to copy from the file
+ * \param size the element size
+ * \param nmemb the quantity of elements.
+ * \param stream the file descriptor
+ *
+ * \return the quantity of elements read from the file.
+ *
+ * Use the read function of ecos.
+ */
+size_t
+cyg_hal_cov_fread (void *ptr, size_t size, size_t nmemb, FILE *stream);
+
+/**
+ * Prints to the std ouput the string.
+ *
+ * \param stream
+ * \param format the string to print.
+ * \param format2 the file name
+ */
+int cyg_hal_cov_fprintf(FILE *stream, const char *format, ...);
+
+/**
+ * Perror function define in the stdio.h
+ * Prints the error on the std output
+ *
+ * \param s the error to print
+ */
+void cyg_hal_cov_perror(const char *s);
+
+/**
+ * See atexit man page
+ *
+ * \param the function pointer to call on exit
+ * \return the value 0 if successful; otherwise it returns a non-zero value.
+ */
+int cyg_hal_cov_atexit(void (*function)(void));
+
+#endif /* gcov_ecos_h */
diff --git a/ecos/packages/services/gcov/current/include/gcov_fio.h b/ecos/packages/services/gcov/current/include/gcov_fio.h
new file mode 100644
index 0000000000..ee4bdb506b
--- /dev/null
+++ b/ecos/packages/services/gcov/current/include/gcov_fio.h
@@ -0,0 +1,232 @@
+#ifndef CYGONCE_FIO_H
+#define CYGONCE_FIO_H
+//=============================================================================
+//
+// fio.h
+//
+// Fileio private header
+//
+//=============================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2002 Nick Garnett
+//
+// eCos 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.
+//
+// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): nickg
+// Contributors: nickg
+// Date: 2000-05-25
+// Purpose: Fileio private header
+// Description: This file contains private definitions for communication
+// between the parts of the fileio package.
+//
+// Usage:
+// #include "fio.h"
+// ...
+//
+//
+//####DESCRIPTIONEND####
+//
+//=============================================================================
+
+#include <pkgconf/hal.h>
+#include <pkgconf/io_fileio.h>
+#include <pkgconf/isoinfra.h>
+
+#include <cyg/infra/cyg_type.h>
+
+#include <stddef.h> // NULL, size_t
+#include <unistd.h>
+#include <limits.h>
+#include <sys/types.h>
+
+#include <cyg/fileio/fileio.h>
+#include <cyg/fileio/sockio.h>
+
+#include <errno.h>
+
+#ifdef CYGPKG_KERNEL
+#include <pkgconf/kernel.h>
+#include <cyg/kernel/mutex.hxx> // mutex definitions
+
+#define FILEIO_MUTEX_LOCK(_m_) ((_m_).lock())
+#define FILEIO_MUTEX_UNLOCK(_m_) ((_m_).unlock())
+
+#else
+#define FILEIO_MUTEX_LOCK(_m_)
+#define FILEIO_MUTEX_UNLOCK(_m_)
+#endif
+
+
+//=============================================================================
+// POSIX API support
+
+#ifdef CYGPKG_POSIX
+#include <pkgconf/posix.h>
+#include <cyg/posix/export.h>
+
+#define CYG_FILEIO_FUNCTION_START() CYG_POSIX_FUNCTION_START()
+
+#define CYG_FILEIO_FUNCTION_FINISH() CYG_POSIX_FUNCTION_FINISH()
+
+#else
+
+#define CYG_FILEIO_FUNCTION_START() CYG_EMPTY_STATEMENT
+
+#define CYG_FILEIO_FUNCTION_FINISH() CYG_EMPTY_STATEMENT
+
+#endif
+
+#ifdef CYGPKG_POSIX_SIGNALS
+
+#define CYG_FILEIO_SIGMASK_SET( __set, __oset ) \
+ CYG_PTHREAD_SIGMASK_SET( __set, __oset )
+
+#define CYG_FILEIO_SIGPENDING() CYG_POSIX_SIGPENDING()
+
+#define CYG_FILEIO_DELIVER_SIGNALS( __mask ) \
+ CYG_POSIX_DELIVER_SIGNALS( __mask )
+
+#else
+
+#define CYG_FILEIO_SIGMASK_SET( __set, __oset ) \
+CYG_MACRO_START \
+CYG_UNUSED_PARAM( const sigset_t*, __set ); \
+CYG_UNUSED_PARAM( const sigset_t*, __oset ); \
+CYG_MACRO_END
+
+#define CYG_FILEIO_SIGPENDING() (0)
+
+#define CYG_FILEIO_DELIVER_SIGNALS( __mask ) CYG_UNUSED_PARAM( const sigset_t*, __mask )
+
+typedef int sigset_t;
+
+#endif
+
+//=============================================================================
+// Fileio function entry and return macros.
+
+// Handle entry to a fileio package function.
+#define FILEIO_ENTRY() \
+ CYG_REPORT_FUNCTYPE( "returning %d" ); \
+ CYG_FILEIO_FUNCTION_START(); \
+
+// Do a fileio package defined return. This requires the error code
+// to be placed in errno, and if it is non-zero, -1 returned as the
+// result of the function. This also gives us a place to put any
+// generic tidyup handling needed for things like signal delivery and
+// cancellation.
+#define FILEIO_RETURN(err) \
+CYG_MACRO_START \
+ int __retval = 0; \
+ CYG_FILEIO_FUNCTION_FINISH(); \
+ if( err != 0 ) __retval = -1, errno = err; \
+ CYG_REPORT_RETVAL( __retval ); \
+ return __retval; \
+CYG_MACRO_END
+
+#define FILEIO_RETURN_VALUE(val) \
+CYG_MACRO_START \
+ CYG_FILEIO_FUNCTION_FINISH(); \
+ CYG_REPORT_RETVAL( val ); \
+ return val; \
+CYG_MACRO_END
+
+#define FILEIO_RETURN_VOID() \
+CYG_MACRO_START \
+ CYG_FILEIO_FUNCTION_FINISH(); \
+ CYG_REPORT_RETURN(); \
+ return; \
+CYG_MACRO_END
+
+//=============================================================================
+// Cancellation support
+// If the POSIX package is present we want to include cancellation points
+// in the routines that are defined to contain them.
+// The macro CYG_CANCELLATION_POINT does this.
+
+#ifdef CYGINT_ISO_PTHREAD_IMPL
+
+# include <pthread.h>
+
+# define CYG_CANCELLATION_POINT pthread_testcancel()
+
+#else
+
+# define CYG_CANCELLATION_POINT CYG_EMPTY_STATEMENT
+
+#endif
+
+//=============================================================================
+// Internal exports
+
+//-----------------------------------------------------------------------------
+// Exports from misc.cxx
+
+// Current directory info
+__externC cyg_mtab_entry *cyg_cdir_mtab_entry;
+__externC cyg_dir cyg_cdir_dir;
+
+__externC int cyg_mtab_lookup( cyg_dir *dir, const char **name, cyg_mtab_entry **mte);
+
+//-----------------------------------------------------------------------------
+// Exports from fd.cxx
+
+__externC void cyg_fd_init();
+
+__externC cyg_file *cyg_file_alloc();
+
+__externC void cyg_file_free(cyg_file * fp);
+
+__externC int cyg_fd_alloc(int low);
+
+__externC void cyg_fd_assign(int fd, cyg_file *fp);
+
+__externC int cyg_fd_free(int fd);
+
+__externC cyg_file *cyg_fp_get( int fd );
+
+__externC void cyg_fp_free( cyg_file *fp );
+
+__externC void cyg_file_lock( cyg_file *fp, cyg_uint32 syncmode );
+
+__externC void cyg_file_unlock( cyg_file *fp, cyg_uint32 syncmode );
+
+//-----------------------------------------------------------------------------
+// Exports from socket.cxx
+
+__externC void cyg_nstab_init();
+
+//-----------------------------------------------------------------------------
+#endif // ifndef CYGONCE_FIO_H
+// End of fio.h
diff --git a/ecos/packages/services/gcov/current/include/gcov_types.h b/ecos/packages/services/gcov/current/include/gcov_types.h
new file mode 100644
index 0000000000..66ed166990
--- /dev/null
+++ b/ecos/packages/services/gcov/current/include/gcov_types.h
@@ -0,0 +1,51 @@
+#ifndef GCOV_TYPES_H_
+#define GCOV_TYPES_H_
+
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file gcov_types.h
+ * \brief <brief>
+ * \ingroup infra
+ *
+ */
+
+#define PARAMS(X) X
+#define ATTRIBUTE_UNUSED
+typedef long long gcov_type;
+
+#if __GNUC__ == 3 && __GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ == 1
+
+#include <cyg/hal/hal_arch.h>
+#include <cyg/kernel/kapi.h>
+#include <cyg/infra/diag.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define fopen cyg_hal_cov_fopen
+#define fclose cyg_hal_cov_fclose
+#define ungetc cyg_hal_cov_ungetc
+#define fgetc cyg_hal_cov_fgetc
+#define rewind cyg_hal_cov_rewind
+#define fwrite cyg_hal_cov_fwrite
+#define fread cyg_hal_cov_fread
+#define ferror cyg_hal_cov_ferror
+#define fprintf cyg_hal_cov_fprintf
+#define atexit cyg_hal_cov_atexit
+#define lseek cyg_hal_sys_lseek
+#define printf diag_printf
+#define perror cyg_hal_cov_perror
+
+#define EOF -1
+
+#else
+#error "compilor not supported"
+#endif
+
+#endif /*GCOV_TYPES_H_*/
diff --git a/ecos/packages/services/gcov/current/src/gcov_bb.c b/ecos/packages/services/gcov/current/src/gcov_bb.c
new file mode 100644
index 0000000000..7e6c3b8fc3
--- /dev/null
+++ b/ecos/packages/services/gcov/current/src/gcov_bb.c
@@ -0,0 +1,254 @@
+/* More subroutines needed by GCC output code on some machines. */
+/* Compile this one with gcc. */
+/* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ 2000, 2001, 2002 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ 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.
+
+ In addition to the permissions in the GNU General Public License, the
+ Free Software Foundation gives you unlimited permission to link the
+ compiled version of this file into combinations with other programs,
+ and to distribute those combinations without any restriction coming
+ from the use of this file. (The General Public License restrictions
+ do apply in other respects; for example, they cover modification of
+ the file, and distribution when not linked into a combine
+ executable.)
+
+ 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 GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/*
+ * author nelio
+ * 2 oct. 07 - 14:15:38
+ *
+ * Taken from the libgcc2.c h from gcc 3.2.1.
+ */
+
+/* Simple minded basic block profiling output dumper for
+ systems that don't provide tcov support. At present,
+ it requires atexit and stdio. */
+
+#include <cyg/gcov/gcov.h>
+
+/* Structure emitted by -a */
+struct bb
+{
+ long zero_word;
+ const char *filename;
+ gcov_type *counts;
+ long ncounts;
+ struct bb *next;
+ const unsigned long *addresses;
+
+ /* Older GCC's did not emit these fields. */
+ long nwords;
+ const char **functions;
+ const long *line_nums;
+ const char **filenames;
+ char *flags;
+};
+
+/* Simple minded basic block profiling output dumper for
+ systems that don't provide tcov support. At present,
+ it requires atexit and stdio. */
+
+#undef NULL /* Avoid errors if stdio.h and our stddef.h mismatch. */
+#ifndef GCOV_TYPES_H_
+#include <stdio.h>
+#endif
+
+#include <string.h>
+#ifdef TARGET_HAS_F_SETLKW
+#include <fcntl.h>
+#include <errno.h>
+#endif
+
+static struct bb *bb_head;
+
+void __bb_exit_func (void)
+{
+ FILE *da_file;
+ int i;
+ struct bb *ptr;
+
+ if (bb_head == 0)
+ return;
+
+ i = strlen (bb_head->filename) - 3;
+
+ for (ptr = bb_head; ptr != (struct bb *) 0; ptr = ptr->next)
+ {
+ int firstchar;
+
+ /* Make sure the output file exists -
+ but don't clobber exiting data. */
+ if ((da_file = fopen (ptr->filename, "a")) != 0)
+ fclose (da_file);
+
+ /* Need to re-open in order to be able to write from the start. */
+ da_file = fopen (ptr->filename, "r+b");
+ /* Some old systems might not allow the 'b' mode modifier.
+ Therefore, try to open without it. This can lead to a race
+ condition so that when you delete and re-create the file, the
+ file might be opened in text mode, but then, you shouldn't
+ delete the file in the first place. */
+ if (da_file == 0)
+ da_file = fopen (ptr->filename, "r+");
+ if (da_file == 0)
+ {
+ fprintf (stderr, "arc profiling: Can't open output file %s.\n",
+ ptr->filename);
+ continue;
+ }
+
+ /* After a fork, another process might try to read and/or write
+ the same file simultanously. So if we can, lock the file to
+ avoid race conditions. */
+#if defined (TARGET_HAS_F_SETLKW)
+ {
+ struct flock s_flock;
+
+ s_flock.l_type = F_WRLCK;
+ s_flock.l_whence = SEEK_SET;
+ s_flock.l_start = 0;
+ s_flock.l_len = 1;
+ s_flock.l_pid = getpid ();
+
+ while (fcntl (fileno (da_file), F_SETLKW, &s_flock)
+ && errno == EINTR);
+ }
+#endif
+
+ /* If the file is not empty, and the number of counts in it is the
+ same, then merge them in. */
+ firstchar = fgetc (da_file);
+ if (firstchar == EOF)
+ {
+ if (ferror (da_file))
+ {
+ fprintf (stderr, "arc profiling: Can't read output file ");
+ perror (ptr->filename);
+ }
+ }
+ else
+ {
+ long n_counts = 0;
+
+ if (ungetc (firstchar, da_file) == EOF)
+ rewind (da_file);
+ if (__read_long (&n_counts, da_file, 8) != 0)
+ {
+ fprintf (stderr, "arc profiling: Can't read output file %s.\n",
+ ptr->filename);
+ continue;
+ }
+
+ if (n_counts == ptr->ncounts)
+ {
+ int i;
+
+ for (i = 0; i < n_counts; i++)
+ {
+ gcov_type v = 0;
+
+ if (__read_gcov_type (&v, da_file, 8) != 0)
+ {
+ fprintf (stderr,
+ "arc profiling: Can't read output file %s.\n",
+ ptr->filename);
+ break;
+ }
+ ptr->counts[i] += v;
+ }
+ }
+
+ }
+
+ rewind (da_file);
+
+ /* ??? Should first write a header to the file. Preferably, a 4 byte
+ magic number, 4 bytes containing the time the program was
+ compiled, 4 bytes containing the last modification time of the
+ source file, and 4 bytes indicating the compiler options used.
+
+ That way we can easily verify that the proper source/executable/
+ data file combination is being used from gcov. */
+
+ if (__write_gcov_type (ptr->ncounts, da_file, 8) != 0)
+ {
+
+ fprintf (stderr, "arc profiling: Error writing output file %s.\n",
+ ptr->filename);
+ }
+ else
+ {
+ int j;
+ gcov_type *count_ptr = ptr->counts;
+ int ret = 0;
+ for (j = ptr->ncounts; j > 0; j--)
+ {
+ if (__write_gcov_type (*count_ptr, da_file, 8) != 0)
+ {
+ ret = 1;
+ break;
+ }
+ count_ptr++;
+ }
+ if (ret)
+ fprintf (stderr, "arc profiling: Error writing output file %s.\n",
+ ptr->filename);
+ }
+
+ if (fclose (da_file) == EOF)
+ fprintf (stderr, "arc profiling: Error closing output file %s.\n",
+ ptr->filename);
+ }
+
+ return;
+}
+
+void __bb_init_func (struct bb *blocks)
+{
+ /* User is supposed to check whether the first word is non-0,
+ but just in case.... */
+
+ if (blocks->zero_word)
+ return;
+
+ /* Initialize destructor. */
+ if (!bb_head)
+ atexit (__bb_exit_func);
+
+ /* Set up linked list. */
+ blocks->zero_word = 1;
+ blocks->next = bb_head;
+ bb_head = blocks;
+}
+
+/* Called before fork or exec - write out profile information gathered so
+ far and reset it to zero. This avoids duplication or loss of the
+ profile information gathered so far. */
+void __bb_fork_func (void)
+{
+ struct bb *ptr;
+
+ __bb_exit_func ();
+ for (ptr = bb_head; ptr != (struct bb *) 0; ptr = ptr->next)
+ {
+ long i;
+ for (i = ptr->ncounts - 1; i >= 0; i--)
+ ptr->counts[i] = 0;
+ }
+}
diff --git a/ecos/packages/services/gcov/current/src/gcov_ecos.c b/ecos/packages/services/gcov/current/src/gcov_ecos.c
new file mode 100644
index 0000000000..c293cb9a87
--- /dev/null
+++ b/ecos/packages/services/gcov/current/src/gcov_ecos.c
@@ -0,0 +1,256 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file gcov_ecos.c
+ * \brief Redifinitions of the functions for gcov.
+ * \ingroup infra
+ *
+ *
+ * This file only works with gcc 3.2.1 and gcov 3.2.1.
+ */
+
+#include <cyg/gcov/gcov_ecos.h>
+#include <cyg/hal/hal_io.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+/**
+ * Open a file as a binary file
+ *
+ * \param path the .da file path.
+ * \param mode the file open mode.
+ * \return the file descriptor.
+ *
+ * This function will allows the gcov to open a file in several :
+ * * a for apppend mode.
+ * * r for read mode
+ * * w for write mode
+ * * otherwise the file is opened in a read write mode.
+ *
+ * This function will use the open system function of ecos.
+ */
+FILE *cyg_hal_cov_fopen (const char *path, const char *mode)
+{
+ int res;
+ FILE *fd;
+
+ switch (mode[0]) {
+ case 'a':
+ res = cyg_hal_sys_open (path, CYG_HAL_SYS_O_CREAT
+ | CYG_HAL_SYS_O_APPEND, CYG_HAL_SYS_S_IREAD
+ | CYG_HAL_SYS_S_IWUSR);
+ break;
+ // case 'r':
+ // res = open (path, CYG_HAL_SYS_O_CREAT | CYG_HAL_SYS_O_RDONLY,
+ // CYG_HAL_SYS_S_IREAD | CYG_HAL_SYS_S_IWUSR);
+ // break;
+ // case 'w':
+ // res = open (path, CYG_HAL_SYS_O_CREAT | CYG_HAL_SYS_O_WRONLY,
+ // CYG_HAL_SYS_S_IREAD | CYG_HAL_SYS_S_IWUSR);
+ // break;
+ default:
+ res = cyg_hal_sys_open (path, CYG_HAL_SYS_O_CREAT
+ | CYG_HAL_SYS_O_RDWR, CYG_HAL_SYS_S_IREAD
+ | CYG_HAL_SYS_S_IWUSR);
+ }
+
+ if (res < 0)
+ {
+ printf ("Error on opening file : %s\n", path);
+ }
+
+ fd = (FILE *) malloc (sizeof(FILE));
+ fd->fd = res;
+ fd->mode = mode[0];
+ fd->path = path;
+ fd->pos = 0;
+ return (FILE *) fd;
+}
+
+/**
+ * Close a the file correspondinf to the file descriptor.
+ *
+ * \param fp the file descriptor integer.
+ * \return zero on success, -1 on error.
+ *
+ * This function will call the close function of ecos.
+ */
+int cyg_hal_cov_fclose (FILE *fp)
+{
+ int res;
+ res = cyg_hal_sys_close (fp->fd);
+
+ free (fp);
+ return res;
+}
+
+/**
+ * Goes to the previous byte of the file represented by the file descriptor.
+ *
+ * \param c the character to insert in the file.
+ * \param file the file descriptor
+ *
+ * \return the value of the the new position in the file from the previous
+ * one
+ *
+ * This function call lseek function provided by ecos.
+ */
+int cyg_hal_cov_ungetc (char c, FILE *file)
+{
+ int res;
+
+ if (file->pos)
+ {
+ res = cyg_hal_sys_lseek (file->fd, -1, 1);
+ file->pos --;
+ return c;
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+/**
+ * Get the first character of the file
+ *
+ * \param file the file descriptor
+ *
+ * \return the character read.
+ */
+int cyg_hal_cov_fgetc (FILE *stream)
+{
+ char buf;
+ int res;
+
+ res = cyg_hal_sys_read (stream->fd, &buf, 1);
+ if (res == 0)
+ {
+ return -1;
+ }
+ else
+ {
+ stream->pos ++;
+ }
+
+ return buf;
+}
+
+/**
+ * implementation of ferror for gcov
+ *
+ * \param file the file descriptor
+ * \return always 0
+ */
+int cyg_hal_cov_ferror (FILE *stream)
+{
+ return 0;
+}
+
+/**
+ * Put the file descriptor to the begining of the file.
+ *
+ * \param file the file descriptor
+ *
+ * uses the function lseek of ecos.
+ */
+void cyg_hal_cov_rewind (FILE *file)
+{
+ for (; file->pos; file->pos --)
+ {
+ lseek (file->fd, -1, 1);
+ }
+}
+
+/**
+ * Write a bytes length to the file
+ *
+ * \param ptr the buffer to copy to the file
+ * \param size the element size
+ * \param nmemb the quantity of elements.
+ * \param stream the file descriptor
+ *
+ * \return the quantity of elements written in the file.
+ *
+ * Use the write function of ecos.
+ */
+size_t cyg_hal_cov_fwrite (const void *ptr, size_t size, size_t nmemb,
+ FILE *stream)
+{
+ int bytes_written;
+
+ bytes_written = cyg_hal_sys_write (stream->fd, ptr, size * nmemb);
+ stream->pos += bytes_written;
+ return (bytes_written / size);
+}
+
+/**
+ * Write a bytes length to the file
+ *
+ * \param ptr the buffer to copy from the file
+ * \param size the element size
+ * \param nmemb the quantity of elements.
+ * \param stream the file descriptor
+ *
+ * \return the quantity of elements read from the file.
+ *
+ * Use the read function of ecos.
+ */
+size_t cyg_hal_cov_fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
+{
+ int res;
+
+ res = cyg_hal_sys_read (stream->fd, ptr, size * nmemb);
+ stream->pos += res;
+ return (res / size);
+}
+
+/**
+ * Prints to the std ouput the string.
+ *
+ * \param stream
+ * \param format the string to print.
+ * \param format2 the file name
+ */
+int cyg_hal_cov_fprintf (FILE *stream, const char *format, ...)
+{
+ va_list ap;
+ char *s;
+
+ va_start(ap, format);
+ while (*format)
+ {
+ s = va_arg(ap, char *);
+ printf ("string %s\n", s);
+ }
+ va_end(ap);
+
+ return 0;
+}
+
+/**
+ * Perror function define in the stdio.h
+ * Prints the error on the std output
+ *
+ * \param s the error to print
+ */
+void cyg_hal_cov_perror(const char *s)
+{
+ printf ("%s\n", s);
+}
+
+/**
+ * See atexit man page
+ *
+ * \param the function pointer to call on exit
+ * \return the value 0 if successful; otherwise it returns a non-zero value.
+ */
+int cyg_hal_cov_atexit (void (*function)(void))
+{
+ return cyg_hal_sys_atexit_handler (function);
+}