aboutsummaryrefslogtreecommitdiffstats
path: root/main/libc0.9.32/0001-stdio-inline-getchar-putchar.patch
blob: e6fe9fed2b5c83f27236b53633405cf8ed567aad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
From 79899f6b3cade5b0ad39b70d30ccf15f182ba045 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 16 May 2013 14:04:39 +0000
Subject: [PATCH] stdio: inline getchar/putchar

Some apps like lvm2 modifies stdin. This breaks getchar since it is
a macro that uses __stdin.
(cherry picked from commit aabeb90f74aa2736fb993cd5840a894eff3b958f)

Conflicts:
	include/stdio.h
	libc/sysdeps/linux/common/bits/uClibc_stdio.h
---
 include/stdio.h                               | 17 +++++++----------
 libc/stdio/getchar.c                          |  2 --
 libc/stdio/putchar.c                          |  3 ---
 libc/sysdeps/linux/common/bits/uClibc_stdio.h |  6 ------
 4 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/include/stdio.h b/include/stdio.h
index 289b861..4d6092a 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -906,19 +906,16 @@ extern void funlockfile (FILE *__stream) __THROW;
 #define fputc_unlocked(_ch, _fp)     __FPUTC_UNLOCKED(_ch, _fp)
 #endif
 
-#ifndef __STDIO_GETC_MACRO
-#define __stdin stdin
-#endif
-#define getchar()                    __GETC(__stdin)
+#ifdef __USE_EXTERN_INLINES
 
-#ifndef __STDIO_PUTC_MACRO
-#define __stdout stdout
-#endif
-#define putchar(_ch)                 __PUTC((_ch), __stdout)
+__extern_inline int getchar(void) { return __GETC(stdin); }
+__extern_inline int putchar(int c) { return __PUTC(c, stdout); }
 
 #if defined __USE_POSIX || defined __USE_MISC
-#define getchar_unlocked()           __GETC_UNLOCKED(__stdin)
-#define putchar_unlocked(_ch)        __PUTC_UNLOCKED((_ch), __stdout)
+__extern_inline int getchar_unlocked(void) { return __GETC_UNLOCKED(stdin); }
+__extern_inline int putchar_unlocked(int c) { return __PUTC_UNLOCKED(c, stdout); }
+#endif
+
 #endif
 
 /* Clear the error and EOF indicators for STREAM.  */
diff --git a/libc/stdio/getchar.c b/libc/stdio/getchar.c
index b6c650c..f8c487b 100644
--- a/libc/stdio/getchar.c
+++ b/libc/stdio/getchar.c
@@ -8,11 +8,9 @@
 #include "_stdio.h"
 
 
-#undef getchar
 #ifdef __DO_UNLOCKED
 
 /* the only use of the hidden getchar_unlocked is in gets.c */
-#undef getchar_unlocked
 int getchar_unlocked(void)
 {
 	register FILE *stream = stdin;
diff --git a/libc/stdio/putchar.c b/libc/stdio/putchar.c
index 583e90f..804b09d 100644
--- a/libc/stdio/putchar.c
+++ b/libc/stdio/putchar.c
@@ -7,11 +7,8 @@
 
 #include "_stdio.h"
 
-
-#undef putchar
 #ifdef __DO_UNLOCKED
 
-#undef putchar_unlocked
 int putchar_unlocked(int c)
 {
 	register FILE *stream = stdout;
diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
index a8cf4eb..2ec8ad4 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
@@ -411,8 +411,6 @@ libc_hidden_proto(__fputc_unlocked)
 
 #ifdef __STDIO_GETC_MACRO
 
-extern FILE *__stdin;			/* For getchar() macro. */
-
 # undef  __GETC_UNLOCKED_MACRO
 # define __GETC_UNLOCKED_MACRO(__stream)				\
 		( ((__stream)->__bufpos < (__stream)->__bufgetc_u)	\
@@ -463,15 +461,11 @@ extern FILE *__stdin;			/* For getchar() macro. */
 #  endif
 # endif
 
-#else
-
 #endif /* __STDIO_GETC_MACRO */
 
 
 #ifdef __STDIO_PUTC_MACRO
 
-extern FILE *__stdout;			/* For putchar() macro. */
-
 # undef  __PUTC_UNLOCKED_MACRO
 # define __PUTC_UNLOCKED_MACRO(__c, __stream)				\
 		( ((__stream)->__bufpos < (__stream)->__bufputc_u)	\
-- 
1.8.2.3