summaryrefslogtreecommitdiffstats
path: root/newlib/libc/include/stdio.h
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2006-06-14 20:49:11 +0000
committerJeff Johnston <jjohnstn@redhat.com>2006-06-14 20:49:11 +0000
commit4dc0c0c4e5f76c22b39976dd381e04699ab0f09d (patch)
treec3ac4ca00812cff8cbdaf27f698768a73f922ffb /newlib/libc/include/stdio.h
parent1b9cba59c38702b6bcdec116591d3c7191ea7ad7 (diff)
downloadcygnal-4dc0c0c4e5f76c22b39976dd381e04699ab0f09d.tar.gz
cygnal-4dc0c0c4e5f76c22b39976dd381e04699ab0f09d.tar.bz2
cygnal-4dc0c0c4e5f76c22b39976dd381e04699ab0f09d.zip
2006-06-14 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/stdio.h: Add new reentrant I/O prototypes for read/write functions. Change getc/putc macros to have reentrant underlying macros/functions. This includes __sgetc_raw_r, __sgetc_r, and __sputc_r. * libc/stdio/fgetc.c: Fix and/or add reentrant version to call new reentrant I/O functions/macros for reading/writing. * libc/stdio/fgets.c: Ditto. * libc/stdio/fputc.c: Ditto. * libc/stdio/fputs.c: Ditto. * libc/stdio/fread.c: Ditto. * libc/stdio/fseek.c: Ditto. * libc/stdio64/fseeko64.c: Ditto. * libc/stdio/fwrite.c: Ditto. * libc/stdio/getc.c: Ditto. * libc/stdio/getc_u.c: Ditto. * libc/stdio/getchar.c: Ditto. * libc/stdio/getchar_u.c: Ditto. * libc/stdio/putc.c: Ditto. * libc/stdio/putc_u.c: Ditto. * libc/stdio/putchar.c: Ditto. * libc/stdio/puts.c: Ditto. * libc/stdio/vfprintf.c: Ditto. * libc/stdio/vfscanf.c: Ditto. * libc/stdio/fvwrite.c: Change __sfvwrite into reentrant __sfvwrite_r. Change all previous callers of __sfvwrite. Set errno to EBADF and set error flag on if attempt is made to write to file that does not allow writing. * libc/stdio/fvwrite.h: Fix new reentrant prototypes. * libc/stdio/local.h: Ditto. * libc/stdio/refill.c: Turn __srefill into reentrant __srefill_r. Set errno to EBADF and the error flag on if attempt is made to read unreadable file. Change all previous callers of __srefill. * libc/stdio/rget.c * libc/stdio/wbuf.c: Turn __swbuf into reentrant __swbuf_r. Change all previous callers of __swbuf. * libc/sys/linux/machine/i386/huge_val.h: Ifdef out file contents since huge value macros are already defined correctly for i386 by <math.h>.
Diffstat (limited to 'newlib/libc/include/stdio.h')
-rw-r--r--newlib/libc/include/stdio.h61
1 files changed, 36 insertions, 25 deletions
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
index 5fc2f4bfd..fb132f6af 100644
--- a/newlib/libc/include/stdio.h
+++ b/newlib/libc/include/stdio.h
@@ -293,11 +293,19 @@ int _EXFUN(_fcloseall_r, (struct _reent *));
FILE * _EXFUN(_fdopen_r, (struct _reent *, int, const char *));
FILE * _EXFUN(_fopen_r, (struct _reent *, const char *, const char *));
int _EXFUN(_fclose_r, (struct _reent *, FILE *));
+char * _EXFUN(_fgets_r, (struct _reent *, char *, int, FILE *));
int _EXFUN(_fiscanf_r, (struct _reent *, FILE *, const char *, ...));
+int _EXFUN(_fputc_r, (struct _reent *, int, FILE *));
+int _EXFUN(_fputs_r, (struct _reent *, const char *, FILE *));
+size_t _EXFUN(_fread_r, (struct _reent *, _PTR, size_t _size, size_t _n, FILE *));
int _EXFUN(_fscanf_r, (struct _reent *, FILE *, const char *, ...));
int _EXFUN(_fseek_r, (struct _reent *, FILE *, long, int));
long _EXFUN(_ftell_r, (struct _reent *, FILE *));
+size_t _EXFUN(_fwrite_r, (struct _reent *, const _PTR , size_t _size, size_t _n, FILE *));
+int _EXFUN(_getc_r, (struct _reent *, FILE *));
+int _EXFUN(_getc_unlocked_r, (struct _reent *, FILE *));
int _EXFUN(_getchar_r, (struct _reent *));
+int _EXFUN(_getchar_unlocked_r, (struct _reent *));
char * _EXFUN(_gets_r, (struct _reent *, char *));
int _EXFUN(_iprintf_r, (struct _reent *, const char *, ...));
int _EXFUN(_iscanf_r, (struct _reent *, const char *, ...));
@@ -305,6 +313,9 @@ int _EXFUN(_mkstemp_r, (struct _reent *, char *));
char * _EXFUN(_mktemp_r, (struct _reent *, char *));
void _EXFUN(_perror_r, (struct _reent *, const char *));
int _EXFUN(_printf_r, (struct _reent *, const char *, ...));
+int _EXFUN(_putc_r, (struct _reent *, int, FILE *));
+int _EXFUN(_putc_unlocked_r, (struct _reent *, int, FILE *));
+int _EXFUN(_putchar_unlocked_r, (struct _reent *, int));
int _EXFUN(_putchar_r, (struct _reent *, int));
int _EXFUN(_puts_r, (struct _reent *, const char *));
int _EXFUN(_remove_r, (struct _reent *, const char *));
@@ -366,8 +377,8 @@ FILE * _EXFUN(_tmpfile64_r, (struct _reent *));
* Routines internal to the implementation.
*/
-int _EXFUN(__srget, (FILE *));
-int _EXFUN(__swbuf, (int, FILE *));
+int _EXFUN(__srget_r, (struct _reent *, FILE *));
+int _EXFUN(__swbuf_r, (struct _reent *, int, FILE *));
/*
* Stdio function-access interface.
@@ -388,15 +399,15 @@ FILE *_EXFUN(funopen,(const _PTR _cookie,
* The __sfoo macros are here so that we can
* define function versions in the C library.
*/
-#define __sgetc_raw(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
+#define __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++))
#ifdef __SCLE
-static __inline__ int __sgetc(FILE *__p)
+static __inline__ int __sgetc_r(struct _REENT *__ptr, FILE *__p)
{
- int __c = __sgetc_raw(__p);
+ int __c = __sgetc_raw_r(__ptr, __p);
if ((__p->_flags & __SCLE) && (__c == '\r'))
{
- int __c2 = __sgetc_raw(__p);
+ int __c2 = __sgetc_raw_r(__ptr, __p);
if (__c2 == '\n')
__c = __c2;
else
@@ -405,37 +416,37 @@ static __inline__ int __sgetc(FILE *__p)
return __c;
}
#else
-#define __sgetc(p) __sgetc_raw(p)
+#define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p)
#endif
#ifdef _never /* __GNUC__ */
/* If this inline is actually used, then systems using coff debugging
info get hopelessly confused. 21sept93 rich@cygnus.com. */
-static __inline int __sputc(int _c, FILE *_p) {
+static __inline int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
return (*_p->_p++ = _c);
else
- return (__swbuf(_c, _p));
+ return (__swbuf_r(_ptr, _c, _p));
}
#else
/*
* This has been tuned to generate reasonable code on the vax using pcc
*/
-#define __sputc_raw(c, p) \
- (--(p)->_w < 0 ? \
- (p)->_w >= (p)->_lbfsize ? \
- (*(p)->_p = (c)), *(p)->_p != '\n' ? \
- (int)*(p)->_p++ : \
- __swbuf('\n', p) : \
- __swbuf((int)(c), p) : \
- (*(p)->_p = (c), (int)*(p)->_p++))
+#define __sputc_raw_r(__ptr, __c, __p) \
+ (--(__p)->_w < 0 ? \
+ (__p)->_w >= (__p)->_lbfsize ? \
+ (*(__p)->_p = (__c)), *(__p)->_p != '\n' ? \
+ (int)*(__p)->_p++ : \
+ __swbuf_r(__ptr, '\n', __p) : \
+ __swbuf_r(__ptr, (int)(__c), __p) : \
+ (*(__p)->_p = (__c), (int)*(__p)->_p++))
#ifdef __SCLE
-#define __sputc(c, p) \
- ((((p)->_flags & __SCLE) && ((c) == '\n')) \
- ? __sputc_raw('\r', (p)) : 0 , \
- __sputc_raw((c), (p)))
+#define __sputc_r(__ptr, __c, __p) \
+ ((((__p)->_flags & __SCLE) && ((__c) == '\n')) \
+ ? __sputc_raw_r(__ptr, '\r', (__p)) : 0 , \
+ __sputc_raw_r((__ptr), (__c), (__p)))
#else
-#define __sputc(c, p) __sputc_raw(c, p)
+#define __sputc_r(__ptr, __c, __p) __sputc_raw_r(__ptr, __c, __p)
#endif
#endif
@@ -454,8 +465,8 @@ static __inline int __sputc(int _c, FILE *_p) {
#ifndef __CYGWIN__
#ifndef lint
-#define getc(fp) __sgetc(fp)
-#define putc(x, fp) __sputc(x, fp)
+#define getc(fp) __sgetc_r(_REENT, fp)
+#define putc(x, fp) __sputc_r(_REENT, x, fp)
#endif /* lint */
#endif /* __CYGWIN__ */
@@ -465,7 +476,7 @@ static __inline int __sputc(int _c, FILE *_p) {
#ifndef __STRICT_ANSI__
/* fast always-buffered version, true iff error */
#define fast_putc(x,p) (--(p)->_w < 0 ? \
- __swbuf((int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))
+ __swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))
#define L_cuserid 9 /* posix says it goes in stdio.h :( */
#ifdef __CYGWIN__