Skip to content

Commit 59af2e4

Browse files
authored
Merge pull request #21828 from maribu/pkg/mpaland-printf/wrap-putc-fputc
pkg/mpaland-printf: wrap putc() and fputc()
2 parents fed2108 + 69c6627 commit 59af2e4

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

pkg/mpaland-printf/Makefile.include

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ LINKFLAGS += -Wl,-wrap=vdprintf
1111
LINKFLAGS += -Wl,-wrap=vsprintf
1212
LINKFLAGS += -Wl,-wrap=vsnprintf
1313
LINKFLAGS += -Wl,-wrap=putchar
14+
LINKFLAGS += -Wl,-wrap=putc
15+
LINKFLAGS += -Wl,-wrap=fputc
1416
LINKFLAGS += -Wl,-wrap=puts
1517

1618
# By wrapping the newlib only `_printf_common` symbol to the undefined

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

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

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

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

2323
#include "printf.h"
2424
#include "stdio_base.h"
25-
@@ -920,3 +923,87 @@ static void _putchar(char character)
25+
@@ -920,3 +923,99 @@ static void _putchar(char character)
2626
{
2727
stdio_write(&character, sizeof(character));
2828
}
@@ -54,7 +54,19 @@ index 7c1ac61..8a1311c 100644
5454
+ _putchar((char)c);
5555
+ return 1;
5656
+}
57+
+
5758
+
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+
+
5870
+
5971
+int __wrap_puts(const char *s)
6072
+{

0 commit comments

Comments
 (0)