Function symbol _fgetc_nolock is not available in any msvcrt DLL library
(versioned or system os). Function symbol getc_nolock is available since
msvcr90. So define _fgetc_nolock as wrapper around the getc_nolock and for
pre-msvcr90 move getc_nolock definition from header file.
---
 mingw-w64-crt/Makefile.am           | 1 +
 mingw-w64-crt/stdio/_fgetc_nolock.c | 7 +++++++
 mingw-w64-crt/stdio/_getc_nolock.c  | 4 +---
 mingw-w64-headers/crt/stdio.h       | 3 +--
 4 files changed, 10 insertions(+), 5 deletions(-)
 create mode 100644 mingw-w64-crt/stdio/_fgetc_nolock.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index a253f0b5268c..3ff209f68245 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -182,6 +182,7 @@ src_msvcrt_common=\
   misc/register_tls_atexit.c \
   misc/wcrtomb.c \
   misc/wcsrtombs.c \
+  stdio/_fgetc_nolock.c \
   stdio/_getwc_nolock.c \
   stdio/_putc_nolock.c \
   stdio/_putwc_nolock.c \
diff --git a/mingw-w64-crt/stdio/_fgetc_nolock.c 
b/mingw-w64-crt/stdio/_fgetc_nolock.c
new file mode 100644
index 000000000000..dfab9b62f351
--- /dev/null
+++ b/mingw-w64-crt/stdio/_fgetc_nolock.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int __cdecl _fgetc_nolock(FILE *stream)
+{
+    return _getc_nolock(stream);
+}
+int __cdecl (*__MINGW_IMP_SYMBOL(_fgetc_nolock))(FILE *) = _fgetc_nolock;
diff --git a/mingw-w64-crt/stdio/_getc_nolock.c 
b/mingw-w64-crt/stdio/_getc_nolock.c
index e67066a8a549..fb4b3f2a27fd 100644
--- a/mingw-w64-crt/stdio/_getc_nolock.c
+++ b/mingw-w64-crt/stdio/_getc_nolock.c
@@ -1,9 +1,7 @@
 #include <stdio.h>
 
-#undef _getc_nolock
-int __cdecl _getc_nolock(FILE *stream);
 int __cdecl _getc_nolock(FILE *stream)
 {
-    return _fgetc_nolock(stream);
+    return --stream->_cnt >= 0 ? 0xff & *stream->_ptr++ : _filbuf(stream);
 }
 int __cdecl (*__MINGW_IMP_SYMBOL(_getc_nolock))(FILE *) = _getc_nolock;
diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h
index 70ae19bcbf10..e46905243c49 100644
--- a/mingw-w64-headers/crt/stdio.h
+++ b/mingw-w64-headers/crt/stdio.h
@@ -1204,12 +1204,11 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const 
wchar_t *__format, __builti
 #endif
 
 #ifdef _UCRT
-  _CRTIMP int __cdecl _fgetc_nolock(FILE *_File);
   _CRTIMP int __cdecl _fputc_nolock(int _Char, FILE *_File);
 #else
-#define _fgetc_nolock(_stream) (--(_stream)->_cnt >= 0 ? 0xff & 
*(_stream)->_ptr++ : _filbuf(_stream))
 #define _fputc_nolock(_c,_stream) (--(_stream)->_cnt >= 0 ? 0xff & 
(*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream)))
 #endif
+  _CRTIMP int __cdecl _fgetc_nolock(FILE *_File);
   _CRTIMP int __cdecl _getc_nolock(FILE *_File);
   _CRTIMP int __cdecl _putc_nolock(int _Char, FILE *_File);
 #define _getchar_nolock() _getc_nolock(stdin)
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to