summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/stdio.h7
-rw-r--r--libc/stdio/getchar.c2
-rw-r--r--libc/stdio/gets.c6
3 files changed, 11 insertions, 4 deletions
diff --git a/include/stdio.h b/include/stdio.h
index 787a6aa52..fd2a73842 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -840,7 +840,14 @@ 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)
+
+#ifndef __STDIO_PUTC_MACRO
+#define __stdout stdout
+#endif
#define putchar(_ch) __PUTC((_ch), __stdout)
#if defined __USE_POSIX || defined __USE_MISC
diff --git a/libc/stdio/getchar.c b/libc/stdio/getchar.c
index 6da8307b6..a8c39f8db 100644
--- a/libc/stdio/getchar.c
+++ b/libc/stdio/getchar.c
@@ -12,7 +12,9 @@ libc_hidden_proto(__fgetc_unlocked)
#undef getchar
#ifdef __DO_UNLOCKED
+/* the only use of the hidden getchar_unlocked is in gets.c */
#undef getchar_unlocked
+libc_hidden_proto(getchar_unlocked)
int getchar_unlocked(void)
{
register FILE *stream = stdin;
diff --git a/libc/stdio/gets.c b/libc/stdio/gets.c
index dc541339b..85bb8475a 100644
--- a/libc/stdio/gets.c
+++ b/libc/stdio/gets.c
@@ -11,11 +11,9 @@ link_warning(gets, "the 'gets' function is dangerous and should not be used.")
/* UNSAFE FUNCTION -- do not bother optimizing */
+/* disable macro, force actual function call */
+#undef getchar_unlocked
libc_hidden_proto(getchar_unlocked)
-libc_hidden_proto(__fgetc_unlocked)
-#ifndef __STDIO_GETC_MACRO
-#define __stdin stdin
-#endif
char *gets(char *s)
{