[PATCH 1/1] common: redefine getc()

Heinrich Schuchardt xypron.glpk at gmx.de
Tue Sep 29 01:45:14 CEST 2020


The sandbox is built with the SDL2 library with invokes the X11 library
which in turn calls getc(). But getc() in glibc is defined as

    int getc(FILE *)

This does not match our definition.

    int getc(void)

The sandbox crashes when called with parameter -l.

Rename our library symbol to be called _u_boot_getc(). To keep the coding
changes minimal use a define.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 include/_exports.h | 2 +-
 include/exports.h  | 2 +-
 include/stdio.h    | 2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/_exports.h b/include/_exports.h
index 1e9ba86108..1da78dea1a 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -8,7 +8,7 @@
 #define EXPORT_FUNC(a, b, c, ...)
 #endif
 	EXPORT_FUNC(get_version, unsigned long, get_version, void)
-	EXPORT_FUNC(getc, int, getc, void)
+	EXPORT_FUNC(getc, int, _u_boot_getc, void)
 	EXPORT_FUNC(tstc, int, tstc, void)
 	EXPORT_FUNC(putc, void, putc, const char)
 	EXPORT_FUNC(puts, void, puts, const char *)
diff --git a/include/exports.h b/include/exports.h
index b300554091..f982b1b49b 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -20,7 +20,7 @@ void jumptable_init(void);

 /* These are declarations of exported functions available in C code */
 unsigned long get_version(void);
-int  getc(void);
+int  _u_boot_getc(void);
 int  tstc(void);
 void putc(const char);
 void puts(const char*);
diff --git a/include/stdio.h b/include/stdio.h
index aedf374452..a204e06c69 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -4,6 +4,8 @@
 #include <stdarg.h>
 #include <linux/compiler.h>

+#define getc _u_boot_getc
+
 /* stdin */
 int getc(void);
 int tstc(void);
--
2.28.0



More information about the U-Boot mailing list