aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2003-10-03 10:16:53 +0000
committerDanny Smith <dannysmith@users.sourceforge.net>2003-10-03 10:16:53 +0000
commite1ce6d5f2a8470c9c4ca775bf144ff9c15c553d8 (patch)
treee35bc6eb33462bcc9d1eae17fbd864c85a85845f /winsup
parentc536f54adab29e9646a91639ce205ec91b1f9234 (diff)
downloadnewlib-e1ce6d5f2a8470c9c4ca775bf144ff9c15c553d8.zip
newlib-e1ce6d5f2a8470c9c4ca775bf144ff9c15c553d8.tar.gz
newlib-e1ce6d5f2a8470c9c4ca775bf144ff9c15c553d8.tar.bz2
* include/stdio.h (_filbuf): Add prototype.
(_flsbuf): Add prototype. (getc): Add inline version. (putc): Likewise. (getchar): Likewise. (putchar): Likewise.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/mingw/ChangeLog9
-rw-r--r--winsup/mingw/include/stdio.h53
2 files changed, 57 insertions, 5 deletions
diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog
index 2ccd140..057e7cb 100644
--- a/winsup/mingw/ChangeLog
+++ b/winsup/mingw/ChangeLog
@@ -1,5 +1,14 @@
2003-10-03 Danny Smith <dannysmith@users.sourceforge.net>
+ * include/stdio.h (_filbuf): Add prototype.
+ (_flsbuf): Add prototype.
+ (getc): Add inline version.
+ (putc): Likewise.
+ (getchar): Likewise.
+ (putchar): Likewise.
+
+2003-10-03 Danny Smith <dannysmith@users.sourceforge.net>
+
* mingwex/dirent.c (_treaddir): Reset errno to 0 if end
of directory.
diff --git a/winsup/mingw/include/stdio.h b/winsup/mingw/include/stdio.h
index c80b105..d923e24 100644
--- a/winsup/mingw/include/stdio.h
+++ b/winsup/mingw/include/stdio.h
@@ -142,7 +142,7 @@
/*
* The structure underlying the FILE type.
*
- * I still believe that nobody in their right mind should make use of the
+ * Some believe that nobody in their right mind should make use of the
* internals of this structure. Provided by Pedro A. Aranda Gutiirrez
* <paag@tid.es>.
*/
@@ -247,14 +247,57 @@ _CRTIMP int __cdecl fgetc (FILE*);
_CRTIMP char* __cdecl fgets (char*, int, FILE*);
_CRTIMP int __cdecl fputc (int, FILE*);
_CRTIMP int __cdecl fputs (const char*, FILE*);
-_CRTIMP int __cdecl getc (FILE*);
-_CRTIMP int __cdecl getchar (void);
_CRTIMP char* __cdecl gets (char*);
-_CRTIMP int __cdecl putc (int, FILE*);
-_CRTIMP int __cdecl putchar (int);
_CRTIMP int __cdecl puts (const char*);
_CRTIMP int __cdecl ungetc (int, FILE*);
+/* Traditionally, getc and putc are defined as macros. but the
+ standard doesn't say that they must be macros.
+ We use inline functions here to allow the fast versions
+ to be used in C++ with namespace qualification, eg., ::getc.
+
+ _filbuf and _flsbuf are not thread-safe. */
+_CRTIMP int __cdecl _filbuf (FILE*);
+_CRTIMP int __cdecl _flsbuf (int, FILE*);
+
+#if !defined _MT
+
+__CRT_INLINE int __cdecl getc (FILE* __F)
+{
+ return (--__F->_cnt >= 0)
+ ? (int) *__F->_ptr++
+ : _filbuf (__F);
+}
+
+__CRT_INLINE int __cdecl putc (int __c, FILE* __F)
+{
+ return (--__F->_cnt >= 0)
+ ? (int)(*__F->_ptr++ = (char)__c)
+ : _flsbuf (__c, __F);
+}
+
+__CRT_INLINE int __cdecl getchar (void)
+{
+ return (--stdin->_cnt >= 0)
+ ? (int) *stdin->_ptr++
+ : _filbuf (stdin);
+}
+
+__CRT_INLINE int __cdecl putchar(int __c)
+{
+ return (--stdout->_cnt >= 0)
+ ? (int)(*stdout->_ptr++ = (char)__c)
+ : _flsbuf (__c, stdout);}
+
+#else /* Use library functions. */
+
+_CRTIMP int __cdecl getc (FILE*);
+_CRTIMP int __cdecl putc (int, FILE*);
+_CRTIMP int __cdecl getchar (void);
+_CRTIMP int __cdecl putchar (int);
+
+#endif
+
/*
* Direct Input and Output Functions
*/