]> sourceware.org Git - newlib-cygwin.git/commitdiff
2006-06-14 Jeff Johnston <jjohnstn@redhat.com>
authorJeff Johnston <jjohnstn@redhat.com>
Wed, 14 Jun 2006 20:49:11 +0000 (20:49 +0000)
committerJeff Johnston <jjohnstn@redhat.com>
Wed, 14 Jun 2006 20:49:11 +0000 (20:49 +0000)
        * 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>.

27 files changed:
newlib/ChangeLog
newlib/libc/include/stdio.h
newlib/libc/stdio/fgetc.c
newlib/libc/stdio/fgets.c
newlib/libc/stdio/fputc.c
newlib/libc/stdio/fputs.c
newlib/libc/stdio/fread.c
newlib/libc/stdio/fseek.c
newlib/libc/stdio/fvwrite.c
newlib/libc/stdio/fvwrite.h
newlib/libc/stdio/fwrite.c
newlib/libc/stdio/getc.c
newlib/libc/stdio/getc_u.c
newlib/libc/stdio/getchar.c
newlib/libc/stdio/getchar_u.c
newlib/libc/stdio/local.h
newlib/libc/stdio/putc.c
newlib/libc/stdio/putc_u.c
newlib/libc/stdio/putchar.c
newlib/libc/stdio/puts.c
newlib/libc/stdio/refill.c
newlib/libc/stdio/rget.c
newlib/libc/stdio/vfprintf.c
newlib/libc/stdio/vfscanf.c
newlib/libc/stdio/wbuf.c
newlib/libc/stdio64/fseeko64.c
newlib/libc/sys/linux/machine/i386/huge_val.h

index 608b40990102a89777db9784261b4084d70d4d39..9754387091ee422a78271a3562768688968cce2a 100644 (file)
@@ -1,3 +1,42 @@
+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>.
+
 2006-06-13  Sandra Loosemore <sandra@codesourcery.com>
 
        * /libc/sys/arm/syscalls.c (_unlink, isatty, _system, _rename):
index 5fc2f4bfdd6493c7403b77988f31f208bb322515..fb132f6af18f0350e6287690f9eecf393ac68ed4 100644 (file)
@@ -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__
index 020b2da3a86cb7bc6acc09151b7394fa2b885443..1802acf7ea3e5258e90edc75c97b58405ac0d40d 100644 (file)
@@ -21,16 +21,26 @@ FUNCTION
 
 INDEX
        fgetc
+INDEX
+       _fgetc_r
 
 ANSI_SYNOPSIS
        #include <stdio.h>
        int fgetc(FILE *<[fp]>);
 
+       #include <stdio.h>
+       int _fgetc_r(struct _reent *<[ptr]>, FILE *<[fp]>);
+
 TRAD_SYNOPSIS
        #include <stdio.h>
        int fgetc(<[fp]>)
        FILE *<[fp]>;
 
+       #include <stdio.h>
+       int _fgetc_r(<[ptr]>, <[fp]>)
+       struct _reent *<[ptr]>;
+       FILE *<[fp]>;
+
 DESCRIPTION
 Use <<fgetc>> to get the next single character from the file or stream
 identified by <[fp]>.  As a side effect, <<fgetc>> advances the file's
@@ -38,6 +48,10 @@ current position indicator.
 
 For a macro version of this function, see <<getc>>.
 
+The function <<_fgetc_r>> is simply a reentrant version of
+<<fgetc>> that is passed the additional reentrant structure
+pointer argument: <[ptr]>.
+
 RETURNS
 The next character (read as an <<unsigned char>>, and cast to
 <<int>>), unless there is no more data, or the host system reports a
@@ -57,14 +71,36 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
 #include <stdio.h>
 #include "local.h"
 
+int
+_DEFUN(_fgetc_r, (ptr, fp),
+       struct _reent * ptr _AND
+       FILE * fp)
+{
+  int result;
+  CHECK_INIT(ptr);
+  _flockfile (fp);
+  result = __sgetc_r (ptr, fp);
+  _funlockfile (fp);
+  return result;
+}
+
+#ifndef _REENT_ONLY
+
 int
 _DEFUN(fgetc, (fp),
        FILE * fp)
 {
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
   int result;
   CHECK_INIT(_REENT);
   _flockfile (fp);
-  result = __sgetc (fp);
+  result = __sgetc_r (_REENT, fp);
   _funlockfile (fp);
   return result;
+#else
+  return _fgetc_r (_REENT, fp);
+#endif
 }
+
+#endif /* !_REENT_ONLY */
+
index f5dde49031d2ccb86afcc80c50aace7faa12767a..7416187059c9f6d2288ba1e2ee28caff9a5bb127 100644 (file)
@@ -21,11 +21,16 @@ FUNCTION
 
 INDEX
        fgets
+INDEX
+       _fgets_r
 
 ANSI_SYNOPSIS
         #include <stdio.h>
        char *fgets(char *<[buf]>, int <[n]>, FILE *<[fp]>);
 
+        #include <stdio.h>
+       char *_fgets_r(struct _reent *<[ptr]>, char *<[buf]>, int <[n]>, FILE *<[fp]>);
+
 TRAD_SYNOPSIS
        #include <stdio.h>
        char *fgets(<[buf]>,<[n]>,<[fp]>)
@@ -33,11 +38,21 @@ TRAD_SYNOPSIS
        int <[n]>;
        FILE *<[fp]>;
 
+       #include <stdio.h>
+       char *_fgets_r(<[ptr]>, <[buf]>,<[n]>,<[fp]>)
+       struct _reent *<[ptr]>;
+        char *<[buf]>;
+       int <[n]>;
+       FILE *<[fp]>;
+
 DESCRIPTION
        Reads at most <[n-1]> characters from <[fp]> until a newline
        is found. The characters including to the newline are stored
        in <[buf]>. The buffer is terminated with a 0.
 
+       The <<_fgets_r>> function is simply the reentrant version of
+       <<fgets>> and is passed an additional reentrancy structure
+       pointer: <[ptr]>.
 
 RETURNS
        <<fgets>> returns the buffer passed to it, with the data
@@ -66,7 +81,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
  */
 
 char *
-_DEFUN(fgets, (buf, n, fp),
+_DEFUN(_fgets_r, (ptr, buf, n, fp),
+       struct _reent * ptr _AND
        char *buf _AND
        int n     _AND
        FILE * fp)
@@ -80,7 +96,7 @@ _DEFUN(fgets, (buf, n, fp),
 
   s = buf;
 
-  CHECK_INIT(_REENT);
+  CHECK_INIT(ptr);
 
   _flockfile (fp);
 #ifdef __SCLE
@@ -88,7 +104,7 @@ _DEFUN(fgets, (buf, n, fp),
     {
       int c;
       /* Sorry, have to do it the slow way */
-      while (--n > 0 && (c = __sgetc (fp)) != EOF)
+      while (--n > 0 && (c = __sgetc_r (ptr, fp)) != EOF)
        {
          *s++ = c;
          if (c == '\n')
@@ -113,7 +129,7 @@ _DEFUN(fgets, (buf, n, fp),
        */
       if ((len = fp->_r) <= 0)
        {
-         if (__srefill (fp))
+         if (__srefill_r (ptr, fp))
            {
              /* EOF: stop with partial or no line */
              if (s == buf)
@@ -156,3 +172,16 @@ _DEFUN(fgets, (buf, n, fp),
   _funlockfile (fp);
   return buf;
 }
+
+#ifndef _REENT_ONLY
+
+char *
+_DEFUN(fgets, (buf, n, fp),
+       char *buf _AND
+       int n     _AND
+       FILE * fp)
+{
+  return _fgets_r (_REENT, buf, n, fp);
+}
+
+#endif /* !_REENT_ONLY */
index 422f6753a67c0e14b66f79c62c762582aceb3651..520fc0250f76d8e49f0c6f6b050c12289c57d3fd 100644 (file)
@@ -21,17 +21,28 @@ FUNCTION
 
 INDEX
        fputc
+INDEX
+       _fputc_r
 
 ANSI_SYNOPSIS
        #include <stdio.h>
        int fputc(int <[ch]>, FILE *<[fp]>);
 
+       #include <stdio.h>
+       int _fputc_r(struct _rent *<[ptr]>, int <[ch]>, FILE *<[fp]>);
+
 TRAD_SYNOPSIS
        #include <stdio.h>
        int fputc(<[ch]>, <[fp]>)
        int <[ch]>;
        FILE *<[fp]>;
 
+       #include <stdio.h>
+       int _fputc_r(<[ptr]>, <[ch]>, <[fp]>)
+       struct _reent *<[ptr]>;
+       int <[ch]>;
+       FILE *<[fp]>;
+
 DESCRIPTION
 <<fputc>> converts the argument <[ch]> from an <<int>> to an
 <<unsigned char>>, then writes it to the file or stream identified by
@@ -45,6 +56,9 @@ oadvances by one.
 
 For a macro version of this function, see <<putc>>.
 
+The <<_fputc_r>> function is simply a reentrant version of <<fputc>>
+that takes an additional reentrant structure argument: <[ptr]>.
+
 RETURNS
 If successful, <<fputc>> returns its argument <[ch]>.  If an error
 intervenes, the result is <<EOF>>.  You can use `<<ferror(<[fp]>)>>' to
@@ -61,15 +75,35 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
 #include <stdio.h>
 #include "local.h"
 
+int
+_DEFUN(_fputc_r, (ptr, ch, file),
+       struct _reent *ptr _AND
+       int ch _AND
+       FILE * file)
+{
+  int result;
+  CHECK_INIT(ptr);
+   _flockfile (file);
+  result = _putc_r (ptr, ch, file);
+  _funlockfile (file);
+  return result;
+}
+
+#ifndef _REENT_ONLY
 int
 _DEFUN(fputc, (ch, file),
        int ch _AND
        FILE * file)
 {
+#if !defined(__OPTIMIZE_SIZE__) && !defined(PREFER_SIZE_OVER_SPEED)
   int result;
   CHECK_INIT(_REENT);
    _flockfile (file);
-  result = putc (ch, file);
+  result = _putc_r (_REENT, ch, file);
   _funlockfile (file);
   return result;
+#else
+  return _fputc_r (_REENT, ch, file);
+#endif
 }
+#endif /* !_REENT_ONLY */
index 8d02107df081c16d9208549871ebb02073eed71a..93537b9e45ed9c983cea89e4b04ebc32c2c5193b 100644 (file)
@@ -21,21 +21,35 @@ FUNCTION
 
 INDEX
        fputs
+INDEX
+       _fputs_r
 
 ANSI_SYNOPSIS
        #include <stdio.h>
        int fputs(const char *<[s]>, FILE *<[fp]>);
 
+       #include <stdio.h>
+       int _fputs_r(struct _reent *<[ptr]>, const char *<[s]>, FILE *<[fp]>);
+
 TRAD_SYNOPSIS
        #include <stdio.h>
        int fputs(<[s]>, <[fp]>)
        char *<[s]>;
        FILE *<[fp]>;
 
+       #include <stdio.h>
+       int _fputs_r(<[ptr]>, <[s]>, <[fp]>)
+       struct _reent *<[ptr]>;
+       char *<[s]>;
+       FILE *<[fp]>;
+
 DESCRIPTION
 <<fputs>> writes the string at <[s]> (but without the trailing null)
 to the file or stream identified by <[fp]>.
 
+<<_fputs_r>> is simply the reentrant version of <<fputs>> that takes
+an additional reentrant struct pointer argument: <[ptr]>.
+
 RETURNS
 If successful, the result is <<0>>; otherwise, the result is <<EOF>>.
 
@@ -58,7 +72,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
  */
 
 int
-_DEFUN(fputs, (s, fp),
+_DEFUN(_fputs_r, (ptr, s, fp),
+       struct _reent * ptr _AND
        char _CONST * s _AND
        FILE * fp)
 {
@@ -71,10 +86,20 @@ _DEFUN(fputs, (s, fp),
   uio.uio_iov = &iov;
   uio.uio_iovcnt = 1;
 
-  CHECK_INIT(_REENT);
+  CHECK_INIT(ptr);
 
   _flockfile (fp);
-  result = __sfvwrite (fp, &uio);
+  result = __sfvwrite_r (ptr, fp, &uio);
   _funlockfile (fp);
   return result;
 }
+
+#ifndef _REENT_ONLY
+int
+_DEFUN(fputs, (s, fp),
+       char _CONST * s _AND
+       FILE * fp)
+{
+  return _fputs_r (_REENT, s, fp);
+}
+#endif /* !_REENT_ONLY */
index 1354c04ba6a385fab5b94b0539308e347df1f2d5..8df57700645ff3c87918e0e386ccb3bbcdfd26f5 100644 (file)
@@ -21,12 +21,19 @@ FUNCTION
 
 INDEX
        fread
+INDEX
+       _fread_r
 
 ANSI_SYNOPSIS
        #include <stdio.h>
        size_t fread(void *<[buf]>, size_t <[size]>, size_t <[count]>,
                     FILE *<[fp]>);
 
+       #include <stdio.h>
+       size_t _fread_r(struct _reent *<[ptr]>, void *<[buf]>,
+                       size_t <[size]>, size_t <[count]>,
+                       FILE *<[fp]>);
+
 TRAD_SYNOPSIS
        #include <stdio.h>
        size_t fread(<[buf]>, <[size]>, <[count]>, <[fp]>)
@@ -35,6 +42,14 @@ TRAD_SYNOPSIS
        size_t <[count]>;
        FILE *<[fp]>;
 
+       #include <stdio.h>
+       size_t _fread_r(<[ptr]>, <[buf]>, <[size]>, <[count]>, <[fp]>)
+       struct _reent *<[ptr]>;
+       char *<[buf]>;
+       size_t <[size]>;
+       size_t <[count]>;
+       FILE *<[fp]>;
+
 DESCRIPTION
 <<fread>> attempts to copy, from the file or stream identified by
 <[fp]>, <[count]> elements (each of size <[size]>) into memory,
@@ -44,6 +59,9 @@ starting at <[buf]>.   <<fread>> may copy fewer elements than
 <<fread>> also advances the file position indicator (if any) for
 <[fp]> by the number of @emph{characters} actually read.
 
+<<_fread_r>> is simply the reentrant version of <<fread>> that
+takes an additional reentrant structure pointer argument: <[ptr]>.
+
 RETURNS
 The result of <<fread>> is the number of elements it succeeded in
 reading.
@@ -63,7 +81,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
 
 #ifdef __SCLE
 static size_t
-_DEFUN(crlf, (fp, buf, count, eof),
+_DEFUN(crlf_r, (ptr, fp, buf, count, eof),
+       struct _reent * ptr _AND
        FILE * fp _AND
        char * buf _AND
        size_t count _AND
@@ -86,7 +105,7 @@ _DEFUN(crlf, (fp, buf, count, eof),
     {
       if (*s == '\r')
         {
-          int c = __sgetc_raw (fp);
+          int c = __sgetc_raw_r (ptr, fp);
           if (c == '\n')
             *s = '\n';
           else
@@ -98,7 +117,7 @@ _DEFUN(crlf, (fp, buf, count, eof),
 
   while (d < e)
     {
-      r = getc (fp);
+      r = _getc_r (ptr, fp);
       if (r == EOF)
         return count - (e-d);
       *d++ = r;
@@ -111,7 +130,8 @@ _DEFUN(crlf, (fp, buf, count, eof),
 #endif
 
 size_t
-_DEFUN(fread, (buf, size, count, fp),
+_DEFUN(_fread_r, (ptr, buf, size, count, fp),
+       struct _reent * ptr _AND
        _PTR buf _AND
        size_t size _AND
        size_t count _AND
@@ -125,7 +145,7 @@ _DEFUN(fread, (buf, size, count, fp),
   if ((resid = count * size) == 0)
     return 0;
 
-  CHECK_INIT(_REENT);
+  CHECK_INIT(ptr);
 
   _flockfile (fp);
   if (fp->_r < 0)
@@ -162,7 +182,7 @@ _DEFUN(fread, (buf, size, count, fp),
          fp->_bf._base = p;
          fp->_bf._size = resid;
          fp->_p = p;
-         rc = __srefill (fp);
+         rc = __srefill_r (ptr, fp);
          /* restore fp buffering back to original state */
          fp->_bf._base = old_base;
          fp->_bf._size = old_size;
@@ -194,7 +214,7 @@ _DEFUN(fread, (buf, size, count, fp),
          /* fp->_r = 0 ... done in __srefill */
          p += r;
          resid -= r;
-         if (__srefill (fp))
+         if (__srefill_r (ptr, fp))
            {
              /* no more input: return partial result */
 #ifdef __SCLE
@@ -224,3 +244,15 @@ _DEFUN(fread, (buf, size, count, fp),
   _funlockfile (fp);
   return count;
 }
+
+#ifndef _REENT_ONLY
+size_t
+_DEFUN(fread, (buf, size, count, fp),
+       _PTR buf _AND
+       size_t size _AND
+       size_t count _AND
+       FILE * fp)
+{
+   return _fread_r (_REENT, buf, size, count, fp);
+}
+#endif
index 8b189ba17ff13098c54c90a1af61e49dac57db9a..09edc42d1167ce56b42a97be29e9724ab39d3289 100644 (file)
@@ -333,7 +333,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence),
   n = target - curoff;
   if (n)
     {
-      if (__srefill (fp) || fp->_r < n)
+      if (__srefill_r (ptr, fp) || fp->_r < n)
        goto dumb;
       fp->_p += n;
       fp->_r -= n;
index f036d7483d04be93a54f96e9f2cd93b7f80158fb..1cb6e0d1e63c6917d5e158306d49dc6f28c8aaf4 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <errno.h>
 #include "local.h"
 #include "fvwrite.h"
 
@@ -43,7 +44,8 @@
  */
 
 int
-_DEFUN(__sfvwrite, (fp, uio),
+_DEFUN(__sfvwrite_r, (ptr, fp, uio),
+       struct _reent *ptr _AND
        register FILE *fp _AND
        register struct __suio *uio)
 {
@@ -59,7 +61,11 @@ _DEFUN(__sfvwrite, (fp, uio),
 
   /* make sure we can write */
   if (cantwrite (fp))
-    return EOF;
+    {
+      fp->_flags |= __SERR;
+      ptr->_errno = EBADF;
+      return EOF;
+    }
 
   iov = uio->uio_iov;
   len = 0;
index f27abdf815b45301f1eee5a90a15acdcc5edead9..901b56058a55ab5816317259a8294c25195e0b00 100644 (file)
@@ -19,7 +19,7 @@
 #include <_ansi.h>
 
 /*
- * I/O descriptors for __sfvwrite().
+ * I/O descriptors for __sfvwrite_r().
  */
 struct __siov {
        _CONST _PTR     iov_base;
@@ -32,7 +32,7 @@ struct __suio {
 };
 
 
-extern int _EXFUN(__sfvwrite,(FILE *, struct __suio *));
+extern int _EXFUN(__sfvwrite_r,(struct _reent *, FILE *, struct __suio *));
 extern int _EXFUN(__swsetup,(FILE *));
 
 
index 663fff62c33548e308c03ec2dd0216ae3fae1a4d..8a2159c4a0f388e3c7bf5e0a43b2cfde513fd59d 100644 (file)
@@ -21,12 +21,18 @@ FUNCTION
 
 INDEX
        fwrite
+INDEX
+       _fwrite_r
 
 ANSI_SYNOPSIS
        #include <stdio.h>
        size_t fwrite(const void *<[buf]>, size_t <[size]>,
                      size_t <[count]>, FILE *<[fp]>);
 
+       #include <stdio.h>
+       size_t _fwrite_r(struct _reent *<[ptr[>, const void *<[buf]>, size_t <[size]>,
+                     size_t <[count]>, FILE *<[fp]>);
+
 TRAD_SYNOPSIS
        #include <stdio.h>
        size_t fwrite(<[buf]>, <[size]>, <[count]>, <[fp]>)
@@ -35,6 +41,14 @@ TRAD_SYNOPSIS
        size_t <[count]>;
        FILE *<[fp]>;
 
+       #include <stdio.h>
+       size_t _fwrite_r(<[ptr]>, <[buf]>, <[size]>, <[count]>, <[fp]>)
+       struct _reent *<[ptr]>;
+       char *<[buf]>;
+       size_t <[size]>;
+       size_t <[count]>;
+       FILE *<[fp]>;
+
 DESCRIPTION
 <<fwrite>> attempts to copy, starting from the memory location
 <[buf]>, <[count]> elements (each of size <[size]>) into the file or
@@ -44,6 +58,9 @@ stream identified by <[fp]>.  <<fwrite>> may copy fewer elements than
 <<fwrite>> also advances the file position indicator (if any) for
 <[fp]> by the number of @emph{characters} actually written.
 
+<<_fwrite_r>> is simply the reentrant version of <<fwrite>> that
+takes an additional reentrant structure argument: <[ptr]>.
+
 RETURNS
 If <<fwrite>> succeeds in writing all the elements you specify, the
 result is the same as the argument <[count]>.  In any event, the
@@ -78,7 +95,8 @@ static char sccsid[] = "%W% (Berkeley) %G%";
  */
 
 size_t
-_DEFUN(fwrite, (buf, size, count, fp),
+_DEFUN(_fwrite_r, (ptr, buf, size, count, fp),
+       struct _reent * ptr _AND
        _CONST _PTR buf _AND
        size_t size     _AND
        size_t count    _AND
@@ -94,15 +112,15 @@ _DEFUN(fwrite, (buf, size, count, fp),
   uio.uio_iovcnt = 1;
 
   /*
-   * The usual case is success (__sfvwrite returns 0);
+   * The usual case is success (__sfvwrite_r returns 0);
    * skip the divide if this happens, since divides are
    * generally slow and since this occurs whenever size==0.
    */
 
-  CHECK_INIT(_REENT);
+  CHECK_INIT(ptr);
 
   _flockfile (fp);
-  if (__sfvwrite (fp, &uio) == 0)
+  if (__sfvwrite_r (ptr, fp, &uio) == 0)
     {
       _funlockfile (fp);
       return count;
@@ -110,3 +128,15 @@ _DEFUN(fwrite, (buf, size, count, fp),
   _funlockfile (fp);
   return (n - uio.uio_resid) / size;
 }
+
+#ifndef _REENT_ONLY
+size_t
+_DEFUN(fwrite, (buf, size, count, fp),
+       _CONST _PTR buf _AND
+       size_t size     _AND
+       size_t count    _AND
+       FILE * fp)
+{
+  return _fwrite_r (_REENT, buf, size, count, fp);
+}
+#endif
index 9628a8740134a8e03abe7925b8ca1fe2bd12a31e..c02fe6b3d1fb02e8f297947e180559f899008a21 100644 (file)
@@ -21,16 +21,26 @@ FUNCTION
 
 INDEX
        getc
+INDEX
+       _getc_r
 
 ANSI_SYNOPSIS
        #include <stdio.h>
        int getc(FILE *<[fp]>);
 
+       #include <stdio.h>
+       int _getc_r(struct _reent *<[ptr]>, FILE *<[fp]>);
+
 TRAD_SYNOPSIS
        #include <stdio.h>
        int getc(<[fp]>)
        FILE *<[fp]>;
 
+       #include <stdio.h>
+       int _getc_r(<[ptr]>, <[fp]>)
+       struct _reent *<[ptr]>;
+       FILE *<[fp]>;
+
 DESCRIPTION
 <<getc>> is a macro, defined in <<stdio.h>>.  You can use <<getc>>
 to get the next single character from the file or stream
@@ -39,6 +49,9 @@ current position indicator.
 
 For a subroutine version of this macro, see <<fgetc>>.
 
+The <<_getc_r>> function is simply the reentrant version of <<getc>>
+which passes an additional reentrancy structure pointer argument: <[ptr]>.
+
 RETURNS
 The next character (read as an <<unsigned char>>, and cast to
 <<int>>), unless there is no more data, or the host system reports a
@@ -72,6 +85,21 @@ static char sccsid[] = "%W% (Berkeley) %G%";
 
 #undef getc
 
+int
+_DEFUN(_getc_r, (ptr, fp),
+       struct _reent *ptr _AND
+       register FILE *fp)
+{
+  int result;
+  CHECK_INIT (ptr);
+  _flockfile (fp);
+  result = __sgetc_r (ptr, fp);
+  _funlockfile (fp);
+  return result;
+}
+
+#ifndef _REENT_ONLY
+
 int
 _DEFUN(getc, (fp),
        register FILE *fp)
@@ -79,7 +107,9 @@ _DEFUN(getc, (fp),
   int result;
   CHECK_INIT (_REENT);
   _flockfile (fp);
-  result = __sgetc (fp);
+  result = __sgetc_r (_REENT, fp);
   _funlockfile (fp);
   return result;
 }
+
+#endif /* !_REENT_ONLY */
index 9c05fa6f563a5575abb349483003b2bc8ce6f048..7d7adde60c35fd91f365ec33ddbfcba915b06a8a 100644 (file)
@@ -21,11 +21,16 @@ FUNCTION
 
 INDEX
        getc_unlocked
+INDEX
+       _getc_unlocked_r
 
 POSIX_SYNOPSIS
        #include <stdio.h>
        int getc_unlocked(FILE *<[fp]>);
 
+       #include <stdio.h>
+       int _getc_unlocked_r(FILE *<[fp]>);
+
 DESCRIPTION
 <<getc_unlocked>> is a non-thread-safe version of <<getc>> declared in
 <<stdio.h>>.  <<getc_unlocked>> may only safely be used within a scope
@@ -36,6 +41,10 @@ object, as is the case after a successful call to the flockfile() or
 ftrylockfile() functions.  If threads are disabled, then
 <<getc_unlocked>> is equivalent to <<getc>>.
 
+The <<_getc_unlocked_r>> function is simply the reentrant version of
+<<get_unlocked>> which passes an additional reentrancy structure pointer
+argument: <[ptr]>.
+
 RETURNS
 See <<getc>>.
 
@@ -60,10 +69,22 @@ static char sccsid[] = "%W% (Berkeley) %G%";
 #undef getc_unlocked
 
 int
-_DEFUN(getc_unlocked, (fp),
+_DEFUN(_getc_unlocked_r, (ptr, fp),
+       struct _reent *ptr _AND
        register FILE *fp)
 {
-  /* CHECK_INIT is called (eventually) by __srefill.  */
+  /* CHECK_INIT is called (eventually) by __srefill_r.  */
 
-  return __sgetc (fp);
+  return __sgetc_r (ptr, fp);
 }
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN(getc_unlocked, (fp),
+       register FILE *fp)
+{
+  return __sgetc_r (_REENT, fp);
+}
+
+#endif /* !_REENT_ONLY */
index 19301c11367d25bebe92285ff3ba2e80b044e418..da2f5dfaf6b50b8ee9d8522dc67a93acab03575a 100644 (file)
@@ -79,11 +79,11 @@ static char sccsid[] = "%W% (Berkeley) %G%";
 #undef getchar
 
 int
-_DEFUN(_getchar_r, (f),
-       struct _reent *f)
+_DEFUN(_getchar_r, (reent),
+       struct _reent *reent)
 {
-  _REENT_SMALL_CHECK_INIT (f);
-  return getc (_stdin_r (f));
+  _REENT_SMALL_CHECK_INIT (reent);
+  return _getc_r (reent, _stdin_r (reent));
 }
 
 #ifndef _REENT_ONLY
@@ -91,9 +91,9 @@ _DEFUN(_getchar_r, (f),
 int
 _DEFUN_VOID(getchar)
 {
-  /* CHECK_INIT is called (eventually) by __srefill.  */
-
-  return _getchar_r (_REENT);
+  /* CHECK_INIT is called (eventually) by __srefill_r.  */
+  _REENT_SMALL_CHECK_INIT (_REENT);
+  return _getc_r (_REENT, _stdin_r (_REENT));
 }
 
 #endif
index be566ea26928fa1e622ffc4d89324cc52610e085..ce40145199fbf4ba446cd623041facd3865fdc80 100644 (file)
@@ -21,11 +21,16 @@ FUNCTION
 
 INDEX
        getchar_unlocked
+INDEX
+       _getchar_unlocked_r
 
 POSIX_SYNOPSIS
        #include <stdio.h>
        int getchar_unlocked();
 
+       #include <stdio.h>
+       int _getchar_unlocked_r(struct _reent *<[ptr]>);
+
 DESCRIPTION
 <<getchar_unlocked>> is a non-thread-safe version of <<getchar>>
 declared in <<stdio.h>>.  <<getchar_unlocked>> may only safely be used
@@ -36,6 +41,10 @@ the ( FILE *) object, as is the case after a successful call to the
 flockfile() or ftrylockfile() functions.  If threads are disabled,
 then <<getchar_unlocked>> is equivalent to <<getchar>>.
 
+The <<_getchar_unlocked_r>> function is simply the reentrant version of
+<<getchar_unlocked>> which passes an addtional reentrancy structure pointer
+argument: <[ptr]>.
+
 RETURNS
 See <<getchar>>.
 
@@ -61,10 +70,10 @@ static char sccsid[] = "%W% (Berkeley) %G%";
 #undef getchar_unlocked
 
 int
-_DEFUN(_getchar_unlocked_r, (f),
-       struct _reent *f)
+_DEFUN(_getchar_unlocked_r, (ptr),
+       struct _reent *ptr)
 {
-  return getc_unlocked (_stdin_r (f));
+  return _getc_unlocked_r (ptr, _stdin_r (ptr));
 }
 
 #ifndef _REENT_ONLY
@@ -72,9 +81,9 @@ _DEFUN(_getchar_unlocked_r, (f),
 int
 _DEFUN_VOID(getchar_unlocked)
 {
-  /* CHECK_INIT is called (eventually) by __srefill.  */
+  /* CHECK_INIT is called (eventually) by __srefill_r.  */
 
-  return _getchar_unlocked_r (_REENT);
+  return _getc_unlocked_r (_REENT, _stdin_r (_REENT));
 }
 
 #endif
index f7093b697e2f24d8cc457c5c4c1fc7f66ad24dbb..301abce33fe048ecbeebf10e98007302f0f33699 100644 (file)
@@ -33,7 +33,7 @@ extern int    _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list
 extern int    _EXFUN(__svfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
 extern FILE  *_EXFUN(__sfp,(struct _reent *));
 extern int    _EXFUN(__sflags,(struct _reent *,_CONST char*, int*));
-extern int    _EXFUN(__srefill,(FILE *));
+extern int    _EXFUN(__srefill_r,(struct _reent *,FILE *));
 extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(_PTR, char *, int));
 extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(_PTR, char _CONST *, int));
 extern _fpos_t _EXFUN(__sseek,(_PTR, _fpos_t, int));
@@ -45,7 +45,6 @@ extern _VOID   _EXFUN(__smakebuf,(FILE *));
 extern int    _EXFUN(_fwalk,(struct _reent *, int (*)(FILE *)));
 extern int    _EXFUN(_fwalk_reent,(struct _reent *, int (*)(struct _reent *, FILE *)));
 struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n));
-extern int   _EXFUN(__srefill,(FILE *fp));
 
 /* Called by the main entry point fns to ensure stdio has been initialized.  */
 
index 0973234173ff59d13a87a364180288797a4a812b..b3008e2879d831117d1f8f5160011af0a90416c7 100644 (file)
@@ -21,17 +21,28 @@ FUNCTION
 
 INDEX
        putc
+INDEX
+       _putc_r
 
 ANSI_SYNOPSIS
        #include <stdio.h>
        int putc(int <[ch]>, FILE *<[fp]>);
 
+       #include <stdio.h>
+       int _putc_r(struct _reent *<[ptr]>, int <[ch]>, FILE *<[fp]>);
+
 TRAD_SYNOPSIS
        #include <stdio.h>
        int putc(<[ch]>, <[fp]>)
        int <[ch]>;
        FILE *<[fp]>;
 
+       #include <stdio.h>
+       int _putc_r(<[ptr]>, <[ch]>, <[fp]>)
+       struct _reent *<[ptr]>;
+       int <[ch]>;
+       FILE *<[fp]>;
+
 DESCRIPTION
 <<putc>> is a macro, defined in <<stdio.h>>.  <<putc>>
 writes the argument <[ch]> to the file or stream identified by
@@ -45,6 +56,9 @@ advances by one.
 
 For a subroutine version of this macro, see <<fputc>>.
 
+The <<_putc_r>> function is simply the reentrant version of
+<<putc>> that takes an additional reentrant structure argument: <[ptr]>.
+
 RETURNS
 If successful, <<putc>> returns its argument <[ch]>.  If an error
 intervenes, the result is <<EOF>>.  You can use `<<ferror(<[fp]>)>>' to
@@ -75,15 +89,36 @@ static char sccsid[] = "%W% (Berkeley) %G%";
 
 #undef putc
 
+int
+_DEFUN(_putc_r, (ptr, c, fp),
+       struct _reent *ptr _AND
+       int c _AND
+       register FILE *fp)
+{
+  int result;
+  CHECK_INIT (ptr);
+  _flockfile (fp);
+  result = __sputc_r (ptr, c, fp);
+  _funlockfile (fp);
+  return result;
+}
+
+#ifndef _REENT_ONLY
 int
 _DEFUN(putc, (c, fp),
        int c _AND
        register FILE *fp)
 {
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
   int result;
   CHECK_INIT (_REENT);
   _flockfile (fp);
-  result = __sputc (c, fp);
+  result = __sputc_r (_REENT, c, fp);
   _funlockfile (fp);
   return result;
+#else
+  return _putc_r (_REENT, c, fp);
+#endif
 }
+#endif /* !_REENT_ONLY */
+
index aee11f4e7cdd4fd0d7a82d046b714336e3abfa7d..9960654d7a8859f6dd36aa9a82d83889e14f5e27 100644 (file)
@@ -21,11 +21,16 @@ FUNCTION
 
 INDEX
        putc_unlocked
+INDEX
+       _putc_unlocked_r
 
 POSIX_SYNOPSIS
        #include <stdio.h>
        int putc_unlocked(int <[ch]>, FILE *<[fp]>);
 
+       #include <stdio.h>
+       int _putc_unlocked_r(struct _reent *<[ptr]>, int <[ch]>, FILE *<[fp]>);
+
 DESCRIPTION
 <<putc_unlocked>> is a non-thread-safe version of <<putc>> declared in
 <<stdio.h>>.  <<putc_unlocked>> may only safely be used within a scope
@@ -36,6 +41,10 @@ object, as is the case after a successful call to the flockfile() or
 ftrylockfile() functions.  If threads are disabled, then
 <<putc_unlocked>> is equivalent to <<putc>>.
 
+The function <<_putc_unlocked_r>> is simply the reentrant version of
+<<putc_unlocked>> that takes an additional reentrant structure pointer
+argument: <[ptr]>.
+
 RETURNS
 See <<putc>>.
 
@@ -60,6 +69,18 @@ static char sccsid[] = "%W% (Berkeley) %G%";
 
 #undef putc_unlocked
 
+int
+_DEFUN(_putc_unlocked_r, (ptr, c, fp),
+       struct _reent *ptr _AND
+       int c _AND
+       register FILE *fp)
+{
+  /* CHECK_INIT is (eventually) called by __swbuf.  */
+
+  return __sputc_r (ptr, c, fp);
+}
+
+#ifndef _REENT_ONLY
 int
 _DEFUN(putc_unlocked, (c, fp),
        int c _AND
@@ -67,5 +88,6 @@ _DEFUN(putc_unlocked, (c, fp),
 {
   /* CHECK_INIT is (eventually) called by __swbuf.  */
 
-  return __sputc (c, fp);
+  return __sputc_r (_REENT, c, fp);
 }
+#endif /* !_REENT_ONLY */
index e1d748ae29e2251dc2463855ee68f08e17256a78..06bcbb46e193c009da06655aac26000ae4feb08a 100644 (file)
@@ -81,7 +81,7 @@ _DEFUN(_putchar_r, (ptr, c),
        int c)
 {
   _REENT_SMALL_CHECK_INIT (ptr);
-  return putc (c, _stdout_r (ptr));
+  return _putc_r (ptr, c, _stdout_r (ptr));
 }
 
 #ifndef _REENT_ONLY
@@ -90,9 +90,8 @@ int
 _DEFUN(putchar, (c),
        int c)
 {
-  /* CHECK_INIT is (eventually) called by __swbuf.  */
-
-  return _putchar_r (_REENT, c);
+  _REENT_SMALL_CHECK_INIT (_REENT);
+  return _putc_r (_REENT, c, _stdout_r (_REENT));
 }
 
 #endif
index bf32d0401b1eca93fb3152de91ca348aa51264f0..e6c4d2e1466c83be5cd1dbe42a40a478f0bef4cb 100644 (file)
@@ -91,7 +91,7 @@ _DEFUN(_puts_r, (ptr, s),
   uio.uio_iovcnt = 2;
 
   _REENT_SMALL_CHECK_INIT (ptr);
-  return (__sfvwrite (_stdout_r (ptr), &uio) ? EOF : '\n');
+  return (__sfvwrite_r (ptr, _stdout_r (ptr), &uio) ? EOF : '\n');
 }
 
 #ifndef _REENT_ONLY
index 639ce6e2490abbfc8530e5808e27142162d5a494..047387e7915bfd42aca50f5fe293f8f4266c1601 100644 (file)
@@ -19,6 +19,7 @@
 #include <_ansi.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <errno.h>
 #include "local.h"
 
 static int
@@ -36,7 +37,8 @@ _DEFUN(lflush, (fp),
  */
 
 int
-_DEFUN(__srefill, (fp),
+_DEFUN(__srefill_r, (ptr, fp),
+       struct _reent * ptr _AND
        register FILE * fp)
 {
   /* make sure stdio is set up */
@@ -55,7 +57,11 @@ _DEFUN(__srefill, (fp),
   if ((fp->_flags & __SRD) == 0)
     {
       if ((fp->_flags & __SRW) == 0)
-       return EOF;
+       {
+         ptr->_errno = EBADF;
+         fp->_flags |= __SERR;
+         return EOF;
+       }
       /* switch to reading */
       if (fp->_flags & __SWR)
        {
index ee4e49ec96ec7f0ff644878265792c4bfd181e1f..1c0bc474c8fad2425e5e4d2c02889fc72d17b68a 100644 (file)
@@ -22,6 +22,7 @@ static char sccsid[] = "%W% (Berkeley) %G%";
 
 #include <_ansi.h>
 #include <stdio.h>
+#include <errno.h>
 #include "local.h"
 
 /*
@@ -31,10 +32,11 @@ static char sccsid[] = "%W% (Berkeley) %G%";
  */
 
 int
-_DEFUN(__srget, (fp),
+_DEFUN(__srget_r, (ptr, fp),
+       struct _reent *ptr _AND
        register FILE *fp)
 {
-  if (__srefill (fp) == 0)
+  if (__srefill_r (ptr, fp) == 0)
     {
       fp->_r--;
       return *fp->_p++;
index a8c1f9bcad7ddfb858ab6d4fabc1c5f2ab8bbd7e..370ffe0e59850e15f253c3d36f1c89034a206fdf 100644 (file)
@@ -212,7 +212,8 @@ static char *rcsid = "$Id$";
  * then reset it so that it can be reused.
  */
 static int
-_DEFUN(__sprint, (fp, uio),
+_DEFUN(__sprint_r, (ptr, fp, uio),
+       struct _reent *ptr _AND
        FILE *fp _AND
        register struct __suio *uio)
 {
@@ -222,7 +223,7 @@ _DEFUN(__sprint, (fp, uio),
                uio->uio_iovcnt = 0;
                return (0);
        }
-       err = __sfvwrite(fp, uio);
+       err = __sfvwrite_r(ptr, fp, uio);
        uio->uio_resid = 0;
        uio->uio_iovcnt = 0;
        return (err);
@@ -469,7 +470,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
        uio.uio_resid += (len); \
        iovp++; \
        if (++uio.uio_iovcnt >= NIOV) { \
-               if (__sprint(fp, &uio)) \
+               if (__sprint_r(data, fp, &uio)) \
                        goto error; \
                iovp = iov; \
        } \
@@ -484,7 +485,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
        } \
 }
 #define        FLUSH() { \
-       if (uio.uio_resid && __sprint(fp, &uio)) \
+       if (uio.uio_resid && __sprint_r(data, fp, &uio)) \
                goto error; \
        uio.uio_iovcnt = 0; \
        iovp = iov; \
index 4788938c992e24b62292953f4f5d9f6d3371560e..7bf0aaf9aa867f3c7a240a56f42900d34e83deb9 100644 (file)
@@ -221,7 +221,7 @@ typedef unsigned long long u_long_long;
  * vfscanf
  */
 
-#define BufferEmpty (fp->_r <= 0 && __srefill(fp))
+#define BufferEmpty (fp->_r <= 0 && __srefill_r(rptr, fp))
 
 #ifndef _REENT_ONLY
 
@@ -547,7 +547,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
              if (--fp->_r > 0)
                fp->_p++;
              else
-             if (__srefill (fp))
+             if (__srefill_r (rptr, fp))
                goto input_failure;
            }
          /*
@@ -615,7 +615,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
                      sum += n;
                      width -= n;
                      fp->_p += n;
-                     if (__srefill (fp))
+                     if (__srefill_r (rptr, fp))
                        {
                          if (sum == 0)
                            goto input_failure;
@@ -910,7 +910,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
              if (--fp->_r > 0)
                fp->_p++;
              else
-             if (__srefill (fp))
+             if (__srefill_r (rptr, fp))
                break;          /* EOF */
            }
          /*
@@ -1107,7 +1107,7 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap),
              if (--fp->_r > 0)
                fp->_p++;
              else
-             if (__srefill (fp))
+             if (__srefill_r (rptr, fp))
                break;          /* EOF */
            }
          if (zeroes)
index e7ddb4913a3510074e00a03768462b1be5a776e9..95d0e4d7104ada5d6bcf0337aa0dc29f9f0572da 100644 (file)
@@ -22,6 +22,7 @@ static char sccsid[] = "%W% (Berkeley) %G%";
 
 #include <_ansi.h>
 #include <stdio.h>
+#include <errno.h>
 #include "local.h"
 #include "fvwrite.h"
 
@@ -32,7 +33,8 @@ static char sccsid[] = "%W% (Berkeley) %G%";
  */
 
 int
-_DEFUN(__swbuf, (c, fp),
+_DEFUN(__swbuf_r, (ptr, c, fp),
+       struct _reent *ptr _AND
        register int c _AND
        register FILE *fp)
 {
@@ -40,7 +42,7 @@ _DEFUN(__swbuf, (c, fp),
 
   /* Ensure stdio has been initialized.  */
 
-  CHECK_INIT (_REENT);
+  CHECK_INIT (ptr);
 
   /*
    * In case we cannot write, or longjmp takes us out early,
@@ -52,7 +54,11 @@ _DEFUN(__swbuf, (c, fp),
 
   fp->_w = fp->_lbfsize;
   if (cantwrite (fp))
-    return EOF;
+    {
+      fp->_flags |= __SERR;
+      ptr->_errno = EBADF;
+      return EOF;
+    }
   c = (unsigned char) c;
 
   /*
index edd764009653a21e25ffe155a9ded1dfca4f7ae3..971bd4d0898ceee88bd798ff789df0476b41dd09 100644 (file)
@@ -309,7 +309,7 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence),
   n = target - curoff;
   if (n)
     {
-      if (__srefill (fp) || fp->_r < n)
+      if (__srefill_r (ptr, fp) || fp->_r < n)
        goto dumb;
       fp->_p += n;
       fp->_r -= n;
index 171517710b25234a1c9f9c90e2d9c576500cf02a..8ead007d71384647b19697a9638d5730dc18c9a9 100644 (file)
@@ -1,3 +1,5 @@
+#if 0 /* We don't need this file because math.h defines these values.  */
+
 /* `HUGE_VAL' constants for ix86 (where it is infinity).
    Used by <stdlib.h> and <math.h> functions for overflow.
    Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
@@ -54,3 +56,4 @@ static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes };
 
 # endif /* GCC 2.95 */
 
+#endif /* if 0 */
This page took 0.105423 seconds and 5 git commands to generate.