From d0f479141396211ab08deb1f787e2afc5ce73b26 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 10 Mar 2023 10:23:41 +0100 Subject: [PATCH] demo: remove use of format strings from mini_c lib The implementations of snprintf and vsnprintf are not needed for the loading of png images by the demo applications. So we can avoid the dependency from the format library hosted in the libports repository. Issue #2064 --- repos/demo/lib/mk/mini_c.mk | 7 ++----- repos/demo/recipes/src/demo/used_apis | 1 - repos/demo/src/lib/mini_c/README | 11 +++-------- repos/demo/src/lib/mini_c/mini_c.cc | 4 ++++ repos/demo/src/lib/mini_c/snprintf.cc | 27 -------------------------- repos/demo/src/lib/mini_c/vsnprintf.cc | 21 -------------------- 6 files changed, 9 insertions(+), 62 deletions(-) delete mode 100644 repos/demo/src/lib/mini_c/snprintf.cc delete mode 100644 repos/demo/src/lib/mini_c/vsnprintf.cc diff --git a/repos/demo/lib/mk/mini_c.mk b/repos/demo/lib/mk/mini_c.mk index e9289be3b3..376d6e09a1 100644 --- a/repos/demo/lib/mk/mini_c.mk +++ b/repos/demo/lib/mk/mini_c.mk @@ -1,8 +1,5 @@ -SRC_CC = snprintf.cc vsnprintf.cc atol.cc strtol.cc strtod.cc \ - malloc_free.cc memcmp.cc strlen.cc memset.cc abort.cc \ - mini_c.cc - -LIBS += format +SRC_CC = atol.cc strtol.cc strtod.cc malloc_free.cc memcmp.cc strlen.cc \ + memset.cc abort.cc mini_c.cc STDINC = yes diff --git a/repos/demo/recipes/src/demo/used_apis b/repos/demo/recipes/src/demo/used_apis index e53d4ac20d..a91105fd08 100644 --- a/repos/demo/recipes/src/demo/used_apis +++ b/repos/demo/recipes/src/demo/used_apis @@ -1,7 +1,6 @@ base os blit -format nitpicker_gfx timer_session input_session diff --git a/repos/demo/src/lib/mini_c/README b/repos/demo/src/lib/mini_c/README index ef2ffd5796..57c6253879 100644 --- a/repos/demo/src/lib/mini_c/README +++ b/repos/demo/src/lib/mini_c/README @@ -1,10 +1,5 @@ Mini C library -This library only provides the libc support for libz, libpng, -and DOpE. Most functions are not implemented. The implemented -functions might be slightly incompatible to a real libc. -Please use this library with caution! - -If you require libc support that goes beyond simple string -functions for your application, please consider porting a -real libc to Genode instead of enhancing mini_c. +This library only provides the libc support for libz and libpng. +Most functions are not implemented. The implemented functions might be +slightly incompatible to a real libc. Please use this library with caution! diff --git a/repos/demo/src/lib/mini_c/mini_c.cc b/repos/demo/src/lib/mini_c/mini_c.cc index 8c3ee4c583..89837bbcaa 100644 --- a/repos/demo/src/lib/mini_c/mini_c.cc +++ b/repos/demo/src/lib/mini_c/mini_c.cc @@ -51,6 +51,10 @@ int puts(const char *s) { Genode::log("%s", s); return 1; } int putchar(int c) { Genode::log("%c", c); return c; } +int vsnprintf(char *, size_t, const char *, va_list) + { NOT_IMPLEMENTED; return 0; } +int snprintf(char *, size_t, const char *, ...) + { NOT_IMPLEMENTED; return 0; } #include diff --git a/repos/demo/src/lib/mini_c/snprintf.cc b/repos/demo/src/lib/mini_c/snprintf.cc deleted file mode 100644 index 7a10c76632..0000000000 --- a/repos/demo/src/lib/mini_c/snprintf.cc +++ /dev/null @@ -1,27 +0,0 @@ -/* - * \brief Mini C snprintf() - * \author Christian Helmuth - * \date 2008-07-24 - */ - -/* - * Copyright (C) 2008-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#include -#include - -extern "C" int snprintf(char *dst, Format::size_t dst_len, const char *format, ...) -{ - va_list list; - va_start(list, format); - - Format::String_console sc(dst, dst_len); - sc.vprintf(format, list); - - va_end(list); - return (int)sc.len(); -} diff --git a/repos/demo/src/lib/mini_c/vsnprintf.cc b/repos/demo/src/lib/mini_c/vsnprintf.cc deleted file mode 100644 index befc186351..0000000000 --- a/repos/demo/src/lib/mini_c/vsnprintf.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* - * \brief Mini C vsnprintf() - * \author Christian Helmuth - * \date 2008-07-24 - */ - -/* - * Copyright (C) 2008-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#include - -extern "C" int vsnprintf(char *dst, Format::size_t dst_len, const char *format, va_list list) -{ - Format::String_console sc(dst, dst_len); - sc.vprintf(format, list); - return (int)sc.len(); -}