1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 22:13:52 +01:00

Merge pull request #21889 from maribu/pkg/mpaland-printf/wrap-fputs

pkg/mpaland-printf: Add missing wrapper for fputs
This commit is contained in:
benpicco 2025-11-17 20:14:32 +00:00 committed by GitHub
commit 298f722795
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 24 deletions

View File

@ -14,6 +14,7 @@ LINKFLAGS += -Wl,-wrap=putchar
LINKFLAGS += -Wl,-wrap=putc
LINKFLAGS += -Wl,-wrap=fputc
LINKFLAGS += -Wl,-wrap=puts
LINKFLAGS += -Wl,-wrap=fputs
# By wrapping the newlib only `_printf_common` symbol to the undefined
# `__wrap__printf_common` symbol, linking will fail if any reference to

View File

@ -1,15 +1,15 @@
From a01af4cb4991f6d5f0320f03d1f1d918df07caec Mon Sep 17 00:00:00 2001
From b1ee169d8cfd6e37817ad267736aa1f92f1a2076 Mon Sep 17 00:00:00 2001
From: Marian Buschsieweke <marian.buschsieweke@posteo.net>
Date: Sat, 11 May 2024 17:51:38 +0200
Subject: [PATCH] Wrapper targets: Add endpoints for -Wl,wrap=...
Subject: [PATCH 4/6] Wrapper targets: Add endpoints for -Wl,wrap=...
This adds aliases needed to wrap printf() and friends.
---
printf.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 99 insertions(+)
printf.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
diff --git a/printf.c b/printf.c
index edf41d1..e00c3e5 100644
index edf41d1..ed7f72b 100644
--- a/printf.c
+++ b/printf.c
@@ -32,6 +32,9 @@
@ -22,7 +22,7 @@ index edf41d1..e00c3e5 100644
#include "printf.h"
#include "stdio_base.h"
@@ -920,3 +923,99 @@ static void _putchar(char character)
@@ -920,3 +923,108 @@ static void _putchar(char character)
{
stdio_write(&character, sizeof(character));
}
@ -54,19 +54,19 @@ index edf41d1..e00c3e5 100644
+ _putchar((char)c);
+ return 1;
+}
+
+
+int __wrap_putc(int c, FILE *stream)
+{
+ (void)stream;
+ _putchar((char)c);
+ return 1;
+}
+
+
+__attribute__((alias("__wrap_putc")))
+int __wrap_fputc(int c, FILE *stream);
+
+
+int __wrap_putc(int c, FILE *stream)
+{
+ (void)stream;
+ _putchar((char)c);
+ return 1;
+}
+
+
+__attribute__((alias("__wrap_putc")))
+int __wrap_fputc(int c, FILE *stream);
+
+
+int __wrap_puts(const char *s)
+{
@ -74,6 +74,15 @@ index edf41d1..e00c3e5 100644
+ stdio_write(s, len);
+ stdio_write("\n", 1);
+ return len + 1;
+}
+
+
+int __wrap_fputs(const char *s, FILE *stream)
+{
+ (void)stream;
+ size_t len = strlen(s);
+ write_all(s, len);
+ return len;
+}
+
+
@ -104,13 +113,13 @@ index edf41d1..e00c3e5 100644
+ }
+
+ return vprintf_(format, va);
+}
+}
+
+
+int __wrap_vsprintf(char* buffer, const char* format, va_list va)
+{
+ return __wrap_vsnprintf(buffer, (size_t)-1, format, va);
+}
+
+int __wrap_vsprintf(char* buffer, const char* format, va_list va)
+{
+ return __wrap_vsnprintf(buffer, (size_t)-1, format, va);
+}
+
+
+int __wrap_dprintf(int fd, const char *format, ...)