gcov: update to version 10.3.0

Issue #4094
This commit is contained in:
Christian Prochaska 2021-04-03 21:42:46 +02:00 committed by Christian Helmuth
parent a0f5d34e25
commit 4a4b754bf2
23 changed files with 239 additions and 51 deletions

View File

@ -55,10 +55,6 @@ endif
%.o: %.cc
$(MSG_COMP)$@
$(VERBOSE)$(CXX) $(CXX_DEF) $(CC_CXX_OPT) $(INCLUDES) -c $< -o $@
ifeq ($(COVERAGE),yes)
$(VERBOSE)mkdir -p $(INSTALL_DIR)/gcov_data/$(TARGET)/$(dir $@)
$(VERBOSE)ln -sf $(CURDIR)/$(@:.o=.gcno) $(INSTALL_DIR)/gcov_data/$(TARGET)/$(@:.o=.gcno)
endif
%.o: %.cpp
$(MSG_COMP)$@

View File

@ -224,6 +224,10 @@ $(TARGET).stripped: $(TARGET)
$(INSTALL_DIR)/$(TARGET): $(TARGET).stripped
$(VERBOSE)ln -sf $(CURDIR)/$< $@
ifeq ($(COVERAGE),yes)
$(VERBOSE)mkdir -p $(INSTALL_DIR)/gcov_data/$(TARGET)
$(VERBOSE)ln -sf $(CURDIR)/*.gcno $(INSTALL_DIR)/gcov_data/$(TARGET)/
endif
ifneq ($(DEBUG_DIR),)
$(DEBUG_DIR)/$(TARGET): $(TARGET)

View File

@ -10,14 +10,16 @@ SRC_CC = diagnostic.cc \
hash-table.cc \
input.cc \
intl.cc \
json.cc \
memory-block.cc \
pretty-print.cc \
sort.cc \
vec.cc \
version.cc
CC_OPT += -DIN_GCC
CC_OPT_version += -DBASEVER="\"6.3.0\"" \
CC_OPT_version += -DBASEVER="\"10.3.0\"" \
-DDATESTAMP="\"\"" \
-DREVISION="\"\"" \
-DDEVPHASE="\"\"" \

View File

@ -2,9 +2,11 @@ GCOV_PORT_DIR := $(call select_from_ports,gcov)
GCOV_DIR := $(GCOV_PORT_DIR)/src/gcov
SRC_CC = line-map.cc
SRC_CC = charset.cc \
errors.cc \
line-map.cc
LIBS += libc
LIBS += libc stdcxx
INC_DIR += $(GCOV_DIR)/include \
$(GCOV_DIR)/libcpp/include

View File

@ -10,6 +10,7 @@ SRC_C = argv.c \
filename_cmp.c \
fopen_unlocked.c \
hashtab.c \
hex.c \
lbasename.c \
md5.c \
obstack.c \
@ -20,6 +21,7 @@ SRC_C = argv.c \
xexit.c \
xmalloc.c \
xmemdup.c \
xasprintf.c \
xstrdup.c \
xstrerror.c \
xstrndup.c \

View File

@ -16,7 +16,8 @@ LIBGCOV_MERGE = _gcov_merge_add \
_gcov_merge_delta \
_gcov_merge_ior \
_gcov_merge_time_profile \
_gcov_merge_icall_topn
_gcov_merge_icall_topn \
_gcov_merge_topn
LIBGCOV_PROFILER = _gcov_interval_profiler \
_gcov_pow2_profiler \

View File

@ -1 +1 @@
a6f8522b8cd63162a9aeef8b5509138c3724af6e
3da457023a91c4f0f272ab61fffdaf6e69eb173f

View File

@ -1,27 +1,32 @@
LICENSE := GPLv2
VERSION := 8.3.0
VERSION := 10.3.0
DOWNLOADS := gcov.archive generated.git
URL(gcov) := ftp://ftp.fu-berlin.de/gnu/gcc/gcc-$(VERSION)/gcc-$(VERSION).tar.xz
SHA(gcov) := 64baadfe6cc0f4947a84cb12d7f0dfaf45bb58b7e92461639596c21e02d97d2c
SHA(gcov) := 64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344
DIR(gcov) := src/gcov
SIG(gcov) := ${URL(gcov)}
KEY(gcov) := GNU
URL(generated) := https://github.com/cproc/genode-generated.git
REV(generated) := 745e78b2ea6abd4a9c601de2cc40702bcb6c636a
REV(generated) := de10bc1a61aed36a0c8ed923bbeb2777d1e3b844
DIR(generated) := include
TAR_OPT(gcov) := gcc-$(VERSION)/gcc/color-macros.h \
TAR_OPT(gcov) := gcc-$(VERSION)/gcc/align.h \
gcc-$(VERSION)/gcc/color-macros.h \
gcc-$(VERSION)/gcc/coretypes.h \
gcc-$(VERSION)/gcc/defaults.h \
gcc-$(VERSION)/gcc/diagnostic.c \
gcc-$(VERSION)/gcc/diagnostic-color.c \
gcc-$(VERSION)/gcc/diagnostic-color.h \
gcc-$(VERSION)/gcc/diagnostic-core.h \
gcc-$(VERSION)/gcc/diagnostic-event-id.h \
gcc-$(VERSION)/gcc/diagnostic-metadata.h \
gcc-$(VERSION)/gcc/diagnostic-path.h \
gcc-$(VERSION)/gcc/diagnostic-show-locus.c \
gcc-$(VERSION)/gcc/diagnostic-url.h \
gcc-$(VERSION)/gcc/diagnostic.def \
gcc-$(VERSION)/gcc/diagnostic.h \
gcc-$(VERSION)/gcc/diagnostic-show-locus.c \
gcc-$(VERSION)/gcc/double-int.h \
gcc-$(VERSION)/gcc/dumpfile.h \
gcc-$(VERSION)/gcc/edit-context.h \
@ -48,20 +53,25 @@ TAR_OPT(gcov) := gcc-$(VERSION)/gcc/color-macros.h \
gcc-$(VERSION)/gcc/intl.c \
gcc-$(VERSION)/gcc/intl.h \
gcc-$(VERSION)/gcc/is-a.h \
gcc-$(VERSION)/gcc/json.cc \
gcc-$(VERSION)/gcc/json.h \
gcc-$(VERSION)/gcc/machmode.h \
gcc-$(VERSION)/gcc/memory-block.cc \
gcc-$(VERSION)/gcc/memory-block.h \
gcc-$(VERSION)/gcc/mem-stats.h \
gcc-$(VERSION)/gcc/mem-stats-traits.h \
gcc-$(VERSION)/gcc/mode-classes.def \
gcc-$(VERSION)/gcc/opts.h \
gcc-$(VERSION)/gcc/poly-int.h \
gcc-$(VERSION)/gcc/poly-int-types.h \
gcc-$(VERSION)/gcc/pretty-print.c \
gcc-$(VERSION)/gcc/pretty-print.h \
gcc-$(VERSION)/gcc/profile-count.h \
gcc-$(VERSION)/gcc/real.h \
gcc-$(VERSION)/gcc/selftest.h \
gcc-$(VERSION)/gcc/selftest-diagnostic.h \
gcc-$(VERSION)/gcc/signop.h \
gcc-$(VERSION)/gcc/sort.cc \
gcc-$(VERSION)/gcc/statistics.h \
gcc-$(VERSION)/gcc/system.h \
gcc-$(VERSION)/gcc/tsystem.h \
@ -71,6 +81,7 @@ TAR_OPT(gcov) := gcc-$(VERSION)/gcc/color-macros.h \
gcc-$(VERSION)/gcc/version.c \
gcc-$(VERSION)/gcc/version.h \
gcc-$(VERSION)/gcc/wide-int.h \
gcc-$(VERSION)/gcc/wide-int-bitmask.h \
gcc-$(VERSION)/gcc/wide-int-print.h \
gcc-$(VERSION)/gcc/config/dbxelf.h \
gcc-$(VERSION)/gcc/config/elfos.h \
@ -103,10 +114,12 @@ TAR_OPT(gcov) := gcc-$(VERSION)/gcc/color-macros.h \
gcc-$(VERSION)/include/obstack.h \
gcc-$(VERSION)/include/safe-ctype.h \
gcc-$(VERSION)/include/splay-tree.h \
gcc-$(VERSION)/libcpp/charset.c \
gcc-$(VERSION)/libcpp/errors.c \
gcc-$(VERSION)/libcpp/internal.h \
gcc-$(VERSION)/libcpp/line-map.c \
gcc-$(VERSION)/libcpp/system.h \
gcc-$(VERSION)/libcpp/include/cpp-id-data.h \
gcc-$(VERSION)/libcpp/ucnid.h \
gcc-$(VERSION)/libcpp/include/cpplib.h \
gcc-$(VERSION)/libcpp/include/line-map.h \
gcc-$(VERSION)/libcpp/include/symtab.h \
@ -126,6 +139,7 @@ TAR_OPT(gcov) := gcc-$(VERSION)/gcc/color-macros.h \
gcc-$(VERSION)/libiberty/filename_cmp.c \
gcc-$(VERSION)/libiberty/fopen_unlocked.c \
gcc-$(VERSION)/libiberty/hashtab.c \
gcc-$(VERSION)/libiberty/hex.c \
gcc-$(VERSION)/libiberty/lbasename.c \
gcc-$(VERSION)/libiberty/md5.c \
gcc-$(VERSION)/libiberty/obstack.c \
@ -134,6 +148,7 @@ TAR_OPT(gcov) := gcc-$(VERSION)/gcc/color-macros.h \
gcc-$(VERSION)/libiberty/splay-tree.c \
gcc-$(VERSION)/libiberty/vprintf-support.c \
gcc-$(VERSION)/libiberty/vprintf-support.h \
gcc-$(VERSION)/libiberty/xasprintf.c \
gcc-$(VERSION)/libiberty/xexit.c \
gcc-$(VERSION)/libiberty/xmalloc.c \
gcc-$(VERSION)/libiberty/xmemdup.c \
@ -166,4 +181,6 @@ symlinks: $(DOWNLOADS)
$(VERBOSE)ln -s pretty-print.c ${DIR(gcov)}/gcc/pretty-print.cc
$(VERBOSE)ln -s vec.c ${DIR(gcov)}/gcc/vec.cc
$(VERBOSE)ln -s version.c ${DIR(gcov)}/gcc/version.cc
$(VERBOSE)ln -s charset.c ${DIR(gcov)}/libcpp/charset.cc
$(VERBOSE)ln -s errors.c ${DIR(gcov)}/libcpp/errors.cc
$(VERBOSE)ln -s line-map.c ${DIR(gcov)}/libcpp/line-map.cc

View File

@ -5,3 +5,4 @@ _/src/libc
_/src/posix
_/src/stdcxx
_/src/vfs
_/src/zlib

View File

@ -16,6 +16,7 @@
<rom label="posix.lib.so"/>
<rom label="stdcxx.lib.so"/>
<rom label="vfs.lib.so"/>
<rom label="zlib.lib.so"/>
</content>
<config>

View File

@ -3,3 +3,4 @@ gmp
libc
posix
stdcxx
zlib

View File

@ -9,7 +9,7 @@ From: Christian Prochaska <christian.prochaska@genode-labs.com>
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c
index 9c567bd..c307120 100644
index 4618b4edb..6b15b0740 100644
--- a/gcc/diagnostic-show-locus.c
+++ b/gcc/diagnostic-show-locus.c
@@ -24,7 +24,9 @@ along with GCC; see the file COPYING3. If not see
@ -23,7 +23,7 @@ index 9c567bd..c307120 100644
#include "diagnostic-color.h"
#include "gcc-rich-location.h"
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index c61e0c4..fea960f 100644
index ed52bc03d..a5d949d14 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -28,7 +28,9 @@ along with GCC; see the file COPYING3. If not see
@ -35,8 +35,8 @@ index c61e0c4..fea960f 100644
+#endif
#include "diagnostic.h"
#include "diagnostic-color.h"
#include "edit-context.h"
@@ -376,7 +378,7 @@ static const char * const bt_stop[] =
#include "diagnostic-url.h"
@@ -438,7 +440,7 @@ static const char * const bt_stop[] =
};
/* A callback function passed to the backtrace_full function. */
@ -45,7 +45,7 @@ index c61e0c4..fea960f 100644
static int
bt_callback (void *data, uintptr_t pc, const char *filename, int lineno,
const char *function)
@@ -456,7 +458,7 @@ bt_err_callback (void *data ATTRIBUTE_UNUSED, const char *msg, int errnum)
@@ -518,7 +520,7 @@ bt_err_callback (void *data ATTRIBUTE_UNUSED, const char *msg, int errnum)
fprintf (stderr, "%s%s%s\n", msg, errnum == 0 ? "" : ": ",
errnum == 0 ? "" : xstrerror (errnum));
}
@ -54,7 +54,7 @@ index c61e0c4..fea960f 100644
/* Check if we've met the maximum error limit, and if so fatally exit
with a message. CONTEXT is the context to check, and FLUSH
indicates whether a diagnostic_finish call is needed. */
@@ -511,14 +513,17 @@ diagnostic_action_after_output (diagnostic_context *context,
@@ -573,14 +575,17 @@ diagnostic_action_after_output (diagnostic_context *context,
case DK_ICE:
case DK_ICE_NOBT:
{

View File

@ -0,0 +1,32 @@
charset.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
---
libcpp/charset.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libcpp/charset.c b/libcpp/charset.c
index d9281c5fb..e10cbc218 100644
--- a/libcpp/charset.c
+++ b/libcpp/charset.c
@@ -2350,9 +2350,10 @@ cpp_display_column_to_byte_column (const char *data, int data_length,
are not highly optimized, but for the present purpose of outputting
diagnostics, they are sufficient. */
-#include "generated_cpp_wcwidth.h"
+//#include "generated_cpp_wcwidth.h"
int cpp_wcwidth (cppchar_t c)
{
+#if 0
if (__builtin_expect (c <= wcwidth_range_ends[0], true))
return wcwidth_widths[0];
@@ -2376,5 +2377,6 @@ int cpp_wcwidth (cppchar_t c)
if (__builtin_expect (begin != end, true))
return wcwidth_widths[begin];
+#endif
return 1;
}

View File

@ -4,15 +4,15 @@ From: Christian Prochaska <christian.prochaska@genode-labs.com>
---
gcc/gcov.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 132 insertions(+), 7 deletions(-)
gcc/gcov.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 136 insertions(+), 9 deletions(-)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index c7c52ce..e039ef0 100644
index a291bac3e..813c7e19b 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -47,6 +47,8 @@ along with Gcov; see the file COPYING3. If not see
@@ -50,6 +50,8 @@ along with Gcov; see the file COPYING3. If not see
#include <zlib.h>
#include <getopt.h>
+#include <dirent.h>
@ -20,7 +20,7 @@ index c7c52ce..e039ef0 100644
#include "md5.h"
using namespace std;
@@ -55,6 +57,7 @@ using namespace std;
@@ -58,6 +60,7 @@ using namespace std;
#include "gcov-io.h"
#include "gcov-io.c"
@ -28,7 +28,7 @@ index c7c52ce..e039ef0 100644
/* The gcno file is generated by -ftest-coverage option. The gcda file is
generated by a program compiled with -fprofile-arcs. Their formats
are documented in gcov-io.h. */
@@ -436,6 +439,11 @@ static unsigned bbg_supports_has_unexecuted_blocks;
@@ -507,6 +510,11 @@ static const char *bbg_cwd;
static char *da_file_name;
@ -40,7 +40,7 @@ index c7c52ce..e039ef0 100644
/* Data file is missing. */
static int no_data_file;
@@ -504,6 +512,16 @@ static int flag_human_readable_numbers = 0;
@@ -579,6 +587,16 @@ static int flag_human_readable_numbers = 0;
static int flag_function_summary = 0;
@ -57,7 +57,7 @@ index c7c52ce..e039ef0 100644
/* Object directory file prefix. This is the directory/file where the
graph and data files are looked for, if nonzero. */
@@ -750,6 +768,43 @@ get_cycles_count (line_info &linfo, bool handle_negative_cycles = true)
@@ -826,6 +844,43 @@ get_cycles_count (line_info &linfo)
return count;
}
@ -101,7 +101,7 @@ index c7c52ce..e039ef0 100644
int
main (int argc, char **argv)
{
@@ -775,13 +830,25 @@ main (int argc, char **argv)
@@ -851,13 +906,25 @@ main (int argc, char **argv)
expandargv (&argc, &argv);
argno = process_args (argc, argv);
@ -128,7 +128,7 @@ index c7c52ce..e039ef0 100644
for (; argno != argc; argno++)
{
@@ -833,7 +900,8 @@ print_usage (int error_p)
@@ -911,7 +978,8 @@ print_usage (int error_p)
fnotice (file, " -u, --unconditional-branches Show unconditional branch counts too\n");
fnotice (file, " -v, --version Print version number, then exit\n");
fnotice (file, " -w, --verbose Print verbose informations\n");
@ -138,24 +138,24 @@ index c7c52ce..e039ef0 100644
fnotice (file, "\nFor bug reporting instructions, please see:\n%s.\n",
bug_report_url);
exit (status);
@@ -877,6 +945,7 @@ static const struct option options[] =
{ "display-progress", no_argument, NULL, 'd' },
@@ -957,6 +1025,7 @@ static const struct option options[] =
{ "hash-filenames", no_argument, NULL, 'x' },
{ "use-colors", no_argument, NULL, 'k' },
{ "use-hotness-colors", no_argument, NULL, 'q' },
+ { "genode-autopilot", no_argument, NULL, 'g' },
{ 0, 0, 0, 0 }
};
@@ -887,7 +956,7 @@ process_args (int argc, char **argv)
@@ -967,7 +1036,7 @@ process_args (int argc, char **argv)
{
int opt;
- const char *opts = "abcdfhijklmno:prs:uvwx";
+ const char *opts = "abcdfghijklmno:prs:uvwx";
- const char *opts = "abcdfhijklmno:pqrs:tuvwx";
+ const char *opts = "abcdfghijklmno:pqrs:tuvwx";
while ((opt = getopt_long (argc, argv, opts, options, NULL)) != -1)
{
switch (opt)
@@ -904,6 +973,9 @@ process_args (int argc, char **argv)
@@ -984,6 +1053,9 @@ process_args (int argc, char **argv)
case 'f':
flag_function_summary = 1;
break;
@ -165,7 +165,7 @@ index c7c52ce..e039ef0 100644
case 'h':
print_usage (false);
/* print_usage will exit. */
@@ -1234,11 +1306,43 @@ process_all_functions (void)
@@ -1363,11 +1435,43 @@ process_all_functions (void)
static void
output_gcov_file (const char *file_name, source_info *src)
{
@ -210,7 +210,7 @@ index c7c52ce..e039ef0 100644
if (gcov_file)
{
fnotice (stdout, "Creating '%s'\n", gcov_file_name);
@@ -1246,7 +1350,8 @@ output_gcov_file (const char *file_name, source_info *src)
@@ -1375,7 +1479,8 @@ output_gcov_file (const char *file_name, source_info *src)
if (ferror (gcov_file))
fnotice (stderr, "Error writing output file '%s'\n",
gcov_file_name);
@ -220,8 +220,28 @@ index c7c52ce..e039ef0 100644
}
else
fnotice (stderr, "Could not open output file '%s'\n", gcov_file_name);
@@ -1329,7 +1434,10 @@ generate_results (const char *file_name)
function_summary (&src->coverage, "File");
@@ -1422,7 +1527,8 @@ generate_results (const char *file_name)
file_name = canonicalize_name (file_name);
}
- gcov_intermediate_filename = get_gcov_intermediate_filename (file_name);
+ if (file_name)
+ gcov_intermediate_filename = get_gcov_intermediate_filename (file_name);
json::object *root = new json::object ();
root->set ("format_version", new json::string ("1"));
@@ -1430,7 +1536,8 @@ generate_results (const char *file_name)
if (bbg_cwd != NULL)
root->set ("current_working_directory", new json::string (bbg_cwd));
- root->set ("data_file", new json::string (file_name));
+ if (file_name)
+ root->set ("data_file", new json::string (file_name));
json::array *json_files = new json::array ();
root->set ("files", json_files);
@@ -1459,7 +1566,10 @@ generate_results (const char *file_name)
file_summary (&src->coverage);
total_lines += src->coverage.lines;
total_executed += src->coverage.lines_executed;
- if (flag_gcov_file)
@ -230,9 +250,9 @@ index c7c52ce..e039ef0 100644
+ !(flag_genode_autopilot &&
+ (src->coverage.lines_executed == src->coverage.lines)))
{
if (flag_intermediate_format)
/* Output the intermediate format without requiring source
@@ -1384,7 +1492,8 @@ create_file_names (const char *file_name)
if (flag_json_format)
output_json_intermediate_file (json_files, src);
@@ -1547,7 +1657,8 @@ create_file_names (const char *file_name)
/* Free previous file names. */
free (bbg_file_name);
free (da_file_name);
@ -242,7 +262,7 @@ index c7c52ce..e039ef0 100644
bbg_file_time = 0;
bbg_stamp = 0;
@@ -1430,6 +1539,10 @@ create_file_names (const char *file_name)
@@ -1593,6 +1704,10 @@ create_file_names (const char *file_name)
strcpy (da_file_name, name);
strcpy (da_file_name + length, GCOV_DATA_SUFFIX);
@ -253,7 +273,7 @@ index c7c52ce..e039ef0 100644
free (name);
return;
}
@@ -1486,6 +1599,18 @@ find_source (const char *file_name)
@@ -1649,6 +1764,18 @@ find_source (const char *file_name)
#endif
&& IS_DIR_SEPARATOR (src->coverage.name[source_length]))
src->coverage.name += source_length + 1;

View File

@ -0,0 +1,43 @@
i386.patch
From: Christian Prochaska <christian.prochaska@genode-labs.com>
---
gcc/config/i386/i386.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 4ff8b5e65..96409d759 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2482,6 +2482,7 @@ const wide_int_bitmask PTA_TREMONT = PTA_GOLDMONT_PLUS | PTA_CLWB
const wide_int_bitmask PTA_KNM = PTA_KNL | PTA_AVX5124VNNIW
| PTA_AVX5124FMAPS | PTA_AVX512VPOPCNTDQ;
+#if 0
#ifndef GENERATOR_FILE
#include "insn-attr-common.h"
@@ -2499,6 +2500,7 @@ extern const pta processor_alias_table[];
extern int const pta_size;
#endif
+#endif
#endif
extern enum processor_type ix86_tune;
@@ -2955,11 +2957,13 @@ extern void debug_dispatch_window (int);
#define TARGET_SUPPORTS_WIDE_INT 1
+#if 0
#if !defined(GENERATOR_FILE) && !defined(IN_LIBGCC2)
extern enum attr_cpu ix86_schedule;
#define NUM_X86_64_MS_CLOBBERED_REGS 12
#endif
+#endif
/*
Local variables:

View File

@ -28,7 +28,7 @@ ifeq ($(filter-out $(SPECS),x86_64),)
INC_DIR += $(GCOV_PORT_DIR)/include/x86_64/gcc
endif
LIBS += libc posix gmp stdcxx gcov-libcommon gcov-libcpp gcov-libiberty
LIBS += libc posix gmp stdcxx zlib gcov-libcommon gcov-libcpp gcov-libiberty
vpath %.cc $(GCOV_DIR)/gcc

View File

@ -75,6 +75,13 @@ extern "C" int atoi(const char *nptr)
}
extern "C" void exit(int status)
{
gcov_env->env.parent().exit(status);
Genode::sleep_forever();
}
extern "C" int fclose(FILE *stream)
{
gcov_env->fs.close(*(gcov_env->file_handle));
@ -246,6 +253,12 @@ extern "C" char *getenv(const char *name)
}
extern "C" int getpid()
{
return 1;
}
extern "C" void *malloc(size_t size)
{
void *res = nullptr;
@ -254,6 +267,53 @@ extern "C" void *malloc(size_t size)
}
extern "C" int sprintf(char *str, const char *format, ...)
{
using namespace Genode;
va_list list;
va_start(list, format);
String_console sc {str, 1024 };
sc.vprintf(format, list);
va_end(list);
return sc.len();
}
extern "C" char *strcat(char *dest, const char *src)
{
while (*dest != '\0')
dest++;
while (*src != '\0') {
*dest = *src;
src++;
dest++;
}
*dest = '\0';
return dest;
}
extern "C" char *strchr(const char *s, int c)
{
while (*s != '\0') {
if (*s == c)
return (char*)s;
s++;
}
if (c == '\0')
return (char*)s;
return nullptr;
}
extern "C" char *strcpy(char *dest, const char *src)
{
Genode::copy_cstring(dest, src, Genode::strlen(src) + 1);
@ -275,7 +335,7 @@ extern "C" int vfprintf(FILE *stream, const char *format, va_list list)
using namespace Genode;
char buf[128] { };
char buf[1024] { };
String_console sc { buf, sizeof(buf) };
sc.vprintf(format, list);
log(Cstring(buf));

View File

@ -32,6 +32,7 @@ int fseek(FILE *stream, long offset, int whence);
long ftell(FILE *stream);
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
void setbuf(FILE *stream, char *buf);
int sprintf(char *str, const char *format, ...);
int vfprintf(FILE *stream, const char *format, va_list ap);
#endif

View File

@ -18,6 +18,7 @@
void abort(void);
void atexit(void (*func)(void));
int atoi(const char *nptr);
void exit(int status);
void free(void *ptr);
char *getenv(const char *name);
void *malloc(size_t size);

View File

@ -17,6 +17,8 @@
void *memcpy(void *dest, const void *src, size_t n);
void *memset(void *s, int c, size_t n);
char *strcat(char *dest, const char *src);
char *strchr(const char *s, int c);
char *strcpy(char *dest, const char *src);
size_t strlen(const char *s);

View File

@ -17,4 +17,6 @@
#define F_OK 0
int getpid();
#endif

View File

@ -8,7 +8,7 @@ From: Christian Prochaska <christian.prochaska@genode-labs.com>
1 file changed, 6 insertions(+)
diff --git a/gcc/tsystem.h b/gcc/tsystem.h
index 969b105..529dfe3 100644
index 7be251313..dd85a677e 100644
--- a/gcc/tsystem.h
+++ b/gcc/tsystem.h
@@ -90,7 +90,9 @@ extern void *memset (void *, int, size_t);

View File

@ -8,7 +8,7 @@ From: Christian Prochaska <christian.prochaska@genode-labs.com>
1 file changed, 2 insertions(+)
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index 3fe1e61..c4cc246 100644
index ac60f9baf..f35fcca1f 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -192,7 +192,9 @@ gcov_open (const char *name, int mode)