From 3ab91d439500b27bd7250216ba7a2e926994b3e1 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 19 Mar 2020 12:44:20 +0100 Subject: [PATCH] newlib: don't define non-thread-safe versions of getc, putc getc, getchar, putc, putchar were defined both as functions and as macros. The macro versions are not thread safe, and should not be used in multithreaded applications. Upstream fix: https://github.com/mirror/newlib-cygwin/commit/b0f271d1db223b2cadd73e10258c48013d943691 --- components/newlib/include/stdio.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/newlib/include/stdio.h b/components/newlib/include/stdio.h index e336ee6eba..0836ab5637 100644 --- a/components/newlib/include/stdio.h +++ b/components/newlib/include/stdio.h @@ -696,8 +696,10 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { #ifndef __CYGWIN__ #ifndef lint +#ifdef __SINGLE_THREAD__ #define getc(fp) __sgetc_r(_REENT, fp) #define putc(x, fp) __sputc_r(_REENT, x, fp) +#endif /* __SINGLE_THREAD__ */ #endif /* lint */ #endif /* __CYGWIN__ */ @@ -714,8 +716,10 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { #endif /* !__CUSTOM_FILE_IO__ */ +#ifdef __SINGLE_THREAD__ #define getchar() getc(stdin) #define putchar(x) putc(x, stdout) +#endif /* __SINGLE_THREAD__ */ #ifndef __STRICT_ANSI__ #define getchar_unlocked() getc_unlocked(stdin)