[PATCH 11/13] stdio: stub out basprintf and friends when built for PBL
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Oct 16 02:01:48 PDT 2024
To optimize out calls to undefined functions in PBL at compile-time
instead of link time, let's define stubs for the functions that
are referenced in obj-pbl-y files, but inside function sections
that are ultimately unreferenced.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/stdio.h | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/include/stdio.h b/include/stdio.h
index 1ed7e1d3e38b..64deec64e66c 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -17,12 +17,32 @@ int sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__,
int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4)));
int scnprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4)));
int vsprintf(char *buf, const char *fmt, va_list args);
+int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
+int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
+
+#ifndef __PBL__
char *basprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2)));
int asprintf(char **strp, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
char *bvasprintf(const char *fmt, va_list ap);
int vasprintf(char **strp, const char *fmt, va_list ap);
-int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
-int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
+#else
+static inline char *basprintf(const char *fmt, ...)
+{
+ return NULL;
+}
+static inline int asprintf(char **strp, const char *fmt, ...)
+{
+ return -ENOMEM;
+}
+static inline char *bvasprintf(const char *fmt, va_list ap)
+{
+ return NULL;
+}
+static inline int vasprintf(char **strp, const char *fmt, va_list ap)
+{
+ return -ENOMEM;
+}
+#endif
#ifdef CONFIG_ARCH_HAS_CTRLC
int arch_ctrlc(void);
--
2.39.5
More information about the barebox
mailing list