Skip to content

Commit b67daab

Browse files
committed
pkg/mpaland-printf: Add missing wrapper for fputs
Another endpoint that was forgotten to overwrite. This fixes the output of the `i2c_scan` shell command that is e.g. included in the test app in `tests/periph/i2c`.
1 parent 0a2e164 commit b67daab

2 files changed

Lines changed: 34 additions & 24 deletions

File tree

pkg/mpaland-printf/Makefile.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ LINKFLAGS += -Wl,-wrap=putchar
1414
LINKFLAGS += -Wl,-wrap=putc
1515
LINKFLAGS += -Wl,-wrap=fputc
1616
LINKFLAGS += -Wl,-wrap=puts
17+
LINKFLAGS += -Wl,-wrap=fputs
1718

1819
# By wrapping the newlib only `_printf_common` symbol to the undefined
1920
# `__wrap__printf_common` symbol, linking will fail if any reference to

pkg/mpaland-printf/patches/0004-Wrapper-targets-Add-endpoints-for-Wl-wrap.patch

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
From a01af4cb4991f6d5f0320f03d1f1d918df07caec Mon Sep 17 00:00:00 2001
1+
From b1ee169d8cfd6e37817ad267736aa1f92f1a2076 Mon Sep 17 00:00:00 2001
22
From: Marian Buschsieweke <marian.buschsieweke@posteo.net>
33
Date: Sat, 11 May 2024 17:51:38 +0200
4-
Subject: [PATCH] Wrapper targets: Add endpoints for -Wl,wrap=...
4+
Subject: [PATCH 4/6] Wrapper targets: Add endpoints for -Wl,wrap=...
55

66
This adds aliases needed to wrap printf() and friends.
77
---
8-
printf.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9-
1 file changed, 99 insertions(+)
8+
printf.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
9+
1 file changed, 108 insertions(+)
1010

1111
diff --git a/printf.c b/printf.c
12-
index edf41d1..e00c3e5 100644
12+
index edf41d1..ed7f72b 100644
1313
--- a/printf.c
1414
+++ b/printf.c
1515
@@ -32,6 +32,9 @@
@@ -22,7 +22,7 @@ index edf41d1..e00c3e5 100644
2222

2323
#include "printf.h"
2424
#include "stdio_base.h"
25-
@@ -920,3 +923,99 @@ static void _putchar(char character)
25+
@@ -920,3 +923,108 @@ static void _putchar(char character)
2626
{
2727
stdio_write(&character, sizeof(character));
2828
}
@@ -54,26 +54,35 @@ index edf41d1..e00c3e5 100644
5454
+ _putchar((char)c);
5555
+ return 1;
5656
+}
57-
+
5857
+
59-
+int __wrap_putc(int c, FILE *stream)
60-
+{
61-
+ (void)stream;
62-
+ _putchar((char)c);
63-
+ return 1;
64-
+}
65-
+
66-
+
67-
+__attribute__((alias("__wrap_putc")))
68-
+int __wrap_fputc(int c, FILE *stream);
69-
+
58+
+
59+
+int __wrap_putc(int c, FILE *stream)
60+
+{
61+
+ (void)stream;
62+
+ _putchar((char)c);
63+
+ return 1;
64+
+}
65+
+
66+
+
67+
+__attribute__((alias("__wrap_putc")))
68+
+int __wrap_fputc(int c, FILE *stream);
69+
+
7070
+
7171
+int __wrap_puts(const char *s)
7272
+{
7373
+ size_t len = strlen(s);
7474
+ stdio_write(s, len);
7575
+ stdio_write("\n", 1);
7676
+ return len + 1;
77+
+}
78+
+
79+
+
80+
+int __wrap_fputs(const char *s, FILE *stream)
81+
+{
82+
+ (void)stream;
83+
+ size_t len = strlen(s);
84+
+ write_all(s, len);
85+
+ return len;
7786
+}
7887
+
7988
+
@@ -104,13 +113,13 @@ index edf41d1..e00c3e5 100644
104113
+ }
105114
+
106115
+ return vprintf_(format, va);
107-
+}
116+
+}
108117
+
109-
+
110-
+int __wrap_vsprintf(char* buffer, const char* format, va_list va)
111-
+{
112-
+ return __wrap_vsnprintf(buffer, (size_t)-1, format, va);
113-
+}
118+
+
119+
+int __wrap_vsprintf(char* buffer, const char* format, va_list va)
120+
+{
121+
+ return __wrap_vsnprintf(buffer, (size_t)-1, format, va);
122+
+}
114123
+
115124
+
116125
+int __wrap_dprintf(int fd, const char *format, ...)

0 commit comments

Comments
 (0)