Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2006-09-27 23:57:15 +0400
committerPaul Brook <paul@codesourcery.com>2006-09-27 23:57:15 +0400
commit44e26f0f07d437c6d179e8d9aff4b465218747bf (patch)
treecb1cdf104a8cc61fa1e588788cc980354d84ec39
parent589fdbe7ba7411d2fb2277441d80d082a9b6317e (diff)
2006-09-17 Paul Brook <paul@codesourcery.com>
newlib/ Backport form mainline 2006-09-26 Jeff Johnston <jjohnstn@redhat.com> * libc/include/stdio.h: Do not allow macros for clearerr, feof, or fileno. * libc/include/sys/reent.h[_REENT_SMALL](struct _reent): Change the dummy std stream scheme to use pointers to const external fake files, one for each standard stream. * libc/stdio/local.h (CHECK_INIT): Change to take a file pointer argument. For _REENT_SMALL, reset the file pointer if it matches one of the fake std stream pointers. * libc/stdio/clearerr.c: Fix CHECK_INIT macro to add file pointer argument. * libc/stdio/fclose.c: Ditto. * libc/stdio/feof.c: Ditto. * libc/stdio/ferror.c: Ditto. * libc/stdio/fflush.c: Ditto. * libc/stdio/fgetc.c: Ditto. * libc/stdio/fgets.c: Ditto. * libc/stdio/fileno.c: Ditto. * libc/stdio/findfp.c: Ditto. * libc/stdio/fputc.c: Ditto. * libc/stdio/fputs.c: Ditto. * libc/stdio/fread.c: Ditto. * libc/stdio/freopen.c: Ditto. * libc/stdio/fseek.c: Ditto. * libc/stdio/ftell.c: Ditto. * libc/stdio/fwrite.c: Ditto. * libc/stdio/getc.c: Ditto. * libc/stdio/getdelim.c: Ditto. * libc/stdio/putc.c: Ditto. * libc/stdio/refill.c: Ditto. * libc/stdio/setvbuf.c: Ditto. * libc/stdio/ungetc.c: Ditto. * libc/stdio/vfprintf.c: Ditto. * libc/stdio/vfscanf.c: Ditto. * libc/stdio/wbuf.c: Ditto.: Ditto. * libc/stdio/wsetup.c: Ditto. * libc/stdio64/freopen64.c: Ditto. * libc/stdio64/fseeko64.c: Ditto. * libc/stdio64/ftello64.c: Ditto. * libc/machine/powerpc/vfprintf.c: Ditto. * libc/machine/powerpc/vfscanf.c: Ditto.
-rw-r--r--ChangeLog.csl46
-rw-r--r--newlib/libc/include/stdio.h3
-rw-r--r--newlib/libc/include/sys/reent.h37
-rw-r--r--newlib/libc/machine/powerpc/vfprintf.c6
-rw-r--r--newlib/libc/machine/powerpc/vfscanf.c2
-rw-r--r--newlib/libc/stdio/clearerr.c2
-rw-r--r--newlib/libc/stdio/fclose.c2
-rw-r--r--newlib/libc/stdio/feof.c2
-rw-r--r--newlib/libc/stdio/ferror.c2
-rw-r--r--newlib/libc/stdio/fflush.c2
-rw-r--r--newlib/libc/stdio/fgetc.c2
-rw-r--r--newlib/libc/stdio/fgets.c2
-rw-r--r--newlib/libc/stdio/fileno.c2
-rw-r--r--newlib/libc/stdio/findfp.c9
-rw-r--r--newlib/libc/stdio/fputc.c2
-rw-r--r--newlib/libc/stdio/fputs.c2
-rw-r--r--newlib/libc/stdio/fread.c2
-rw-r--r--newlib/libc/stdio/freopen.c2
-rw-r--r--newlib/libc/stdio/fseek.c2
-rw-r--r--newlib/libc/stdio/ftell.c2
-rw-r--r--newlib/libc/stdio/fwrite.c2
-rw-r--r--newlib/libc/stdio/getc.c2
-rw-r--r--newlib/libc/stdio/getdelim.c2
-rw-r--r--newlib/libc/stdio/local.h26
-rw-r--r--newlib/libc/stdio/putc.c2
-rw-r--r--newlib/libc/stdio/refill.c2
-rw-r--r--newlib/libc/stdio/setvbuf.c2
-rw-r--r--newlib/libc/stdio/ungetc.c2
-rw-r--r--newlib/libc/stdio/vfprintf.c2
-rw-r--r--newlib/libc/stdio/vfscanf.c4
-rw-r--r--newlib/libc/stdio/wbuf.c2
-rw-r--r--newlib/libc/stdio/wsetup.c2
-rw-r--r--newlib/libc/stdio64/freopen64.c2
-rw-r--r--newlib/libc/stdio64/fseeko64.c2
-rw-r--r--newlib/libc/stdio64/ftello64.c2
35 files changed, 129 insertions, 58 deletions
diff --git a/ChangeLog.csl b/ChangeLog.csl
index acb4d0e7e..1265310de 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,3 +1,49 @@
+2006-09-17 Paul Brook <paul@codesourcery.com>
+
+ newlib/
+ Backport form mainline
+ 2006-09-26 Jeff Johnston <jjohnstn@redhat.com>
+ * libc/include/stdio.h: Do not allow macros
+ for clearerr, feof, or fileno.
+ * libc/include/sys/reent.h[_REENT_SMALL](struct _reent): Change
+ the dummy std stream scheme to use pointers to const external
+ fake files, one for each standard stream.
+ * libc/stdio/local.h (CHECK_INIT): Change to take a file pointer
+ argument. For _REENT_SMALL, reset the file pointer if it
+ matches one of the fake std stream pointers.
+ * libc/stdio/clearerr.c: Fix CHECK_INIT macro to add file pointer
+ argument.
+ * libc/stdio/fclose.c: Ditto.
+ * libc/stdio/feof.c: Ditto.
+ * libc/stdio/ferror.c: Ditto.
+ * libc/stdio/fflush.c: Ditto.
+ * libc/stdio/fgetc.c: Ditto.
+ * libc/stdio/fgets.c: Ditto.
+ * libc/stdio/fileno.c: Ditto.
+ * libc/stdio/findfp.c: Ditto.
+ * libc/stdio/fputc.c: Ditto.
+ * libc/stdio/fputs.c: Ditto.
+ * libc/stdio/fread.c: Ditto.
+ * libc/stdio/freopen.c: Ditto.
+ * libc/stdio/fseek.c: Ditto.
+ * libc/stdio/ftell.c: Ditto.
+ * libc/stdio/fwrite.c: Ditto.
+ * libc/stdio/getc.c: Ditto.
+ * libc/stdio/getdelim.c: Ditto.
+ * libc/stdio/putc.c: Ditto.
+ * libc/stdio/refill.c: Ditto.
+ * libc/stdio/setvbuf.c: Ditto.
+ * libc/stdio/ungetc.c: Ditto.
+ * libc/stdio/vfprintf.c: Ditto.
+ * libc/stdio/vfscanf.c: Ditto.
+ * libc/stdio/wbuf.c: Ditto.: Ditto.
+ * libc/stdio/wsetup.c: Ditto.
+ * libc/stdio64/freopen64.c: Ditto.
+ * libc/stdio64/fseeko64.c: Ditto.
+ * libc/stdio64/ftello64.c: Ditto.
+ * libc/machine/powerpc/vfprintf.c: Ditto.
+ * libc/machine/powerpc/vfscanf.c: Ditto.
+
2006-09-22 Nathan Sidwell <nathan@codesourcery.com>
libgloss/
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
index ef8c2db18..976086e07 100644
--- a/newlib/libc/include/stdio.h
+++ b/newlib/libc/include/stdio.h
@@ -439,9 +439,6 @@ static __inline int __sputc(int _c, FILE *_p) {
#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
#define __sfileno(p) ((p)->_file)
-#define feof(p) __sfeof(p)
-#define ferror(p) __sferror(p)
-#define clearerr(p) __sclearerr(p)
#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */
#define fileno(p) __sfileno(p)
diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h
index 1fe3ed20f..e0314b30c 100644
--- a/newlib/libc/include/sys/reent.h
+++ b/newlib/libc/include/sys/reent.h
@@ -13,6 +13,8 @@ extern "C" {
#include <_ansi.h>
#include <sys/_types.h>
+#define _NULL 0
+
#ifndef __Long
#if __LONG_MAX__ == 2147483647L
#define __Long long
@@ -157,8 +159,8 @@ struct __sFILE_fake {
struct _reent *_data;
};
-/* CHECK_INIT() comes from stdio/local.h; be sure to include that. */
-# define _REENT_SMALL_CHECK_INIT(ptr) CHECK_INIT(ptr)
+/* CHECK_STD_INIT() comes from stdio/local.h; be sure to include that. */
+# define _REENT_SMALL_CHECK_INIT(ptr) CHECK_STD_INIT(ptr)
#else
# define _REENT_SMALL_CHECK_INIT(ptr) /* nothing */
#endif
@@ -383,16 +385,19 @@ struct _reent
struct _glue __sglue; /* root of glue chain */
__FILE *__sf; /* file descriptors */
- struct __sFILE_fake __sf_fake; /* fake initial stdin/out/err */
struct _misc_reent *_misc; /* strtok, multibyte states */
char *_signal_buf; /* strsignal */
};
+extern const struct __sFILE_fake __sf_fake_stdin;
+extern const struct __sFILE_fake __sf_fake_stdout;
+extern const struct __sFILE_fake __sf_fake_stderr;
+
#define _REENT_INIT(var) \
- { (__FILE *)&var.__sf_fake, \
- (__FILE *)&var.__sf_fake, \
- (__FILE *)&var.__sf_fake, \
- 0, \
+ { 0, \
+ (__FILE *)&__sf_fake_stdin, \
+ (__FILE *)&__sf_fake_stdout, \
+ (__FILE *)&__sf_fake_stderr, \
0, \
_NULL, \
0, \
@@ -411,15 +416,14 @@ struct _reent
{_NULL, 0, {_NULL}, _NULL}, \
{_NULL, 0, _NULL}, \
_NULL, \
- {_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL}, \
_NULL, \
_NULL \
}
#define _REENT_INIT_PTR(var) \
- { var->_stdin = (__FILE *)&var->__sf_fake; \
- var->_stdout = (__FILE *)&var->__sf_fake; \
- var->_stderr = (__FILE *)&var->__sf_fake; \
+ { var->_stdin = (__FILE *)&__sf_fake_stdin; \
+ var->_stdout = (__FILE *)&__sf_fake_stdout; \
+ var->_stderr = (__FILE *)&__sf_fake_stderr; \
var->_errno = 0; \
var->_inc = 0; \
var->_emergency = _NULL; \
@@ -444,15 +448,6 @@ struct _reent
var->__sglue._niobs = 0; \
var->__sglue._iobs = _NULL; \
var->__sf = 0; \
- var->__sf_fake._p = _NULL; \
- var->__sf_fake._r = 0; \
- var->__sf_fake._w = 0; \
- var->__sf_fake._flags = 0; \
- var->__sf_fake._file = 0; \
- var->__sf_fake._bf._base = _NULL; \
- var->__sf_fake._bf._size = 0; \
- var->__sf_fake._lbfsize = 0; \
- var->__sf_fake._data = _NULL; \
var->_misc = _NULL; \
var->_signal_buf = _NULL; \
}
@@ -787,8 +782,6 @@ struct _reent
#endif /* !_REENT_SMALL */
-#define _NULL 0
-
/*
* All references to struct _reent are via this pointer.
* Internally, newlib routines that need to reference it should use _REENT.
diff --git a/newlib/libc/machine/powerpc/vfprintf.c b/newlib/libc/machine/powerpc/vfprintf.c
index 8aadb4b15..e84be15aa 100644
--- a/newlib/libc/machine/powerpc/vfprintf.c
+++ b/newlib/libc/machine/powerpc/vfprintf.c
@@ -321,7 +321,7 @@ _DEFUN (VFPRINTF, (fp, fmt0, ap),
_CONST char *fmt0 _AND
va_list ap)
{
- CHECK_INIT (_REENT);
+ CHECK_INIT (_REENT, fp);
return _VFPRINTF_R (_REENT, fp, fmt0, ap);
}
@@ -875,7 +875,9 @@ reswitch: switch (ch) {
if (prec || flags & ALT)
size += prec + 1;
} else /* "0.X" */
- size = prec + 2;
+ size = (prec || flags & ALT)
+ ? prec + 2
+ : 1;
} else if (expt >= ndig) { /* fixed g fmt */
size = expt;
if (flags & ALT)
diff --git a/newlib/libc/machine/powerpc/vfscanf.c b/newlib/libc/machine/powerpc/vfscanf.c
index 47b0d1c61..4f14d3a50 100644
--- a/newlib/libc/machine/powerpc/vfscanf.c
+++ b/newlib/libc/machine/powerpc/vfscanf.c
@@ -224,7 +224,7 @@ _DEFUN (vfscanf, (fp, fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, fp);
return __svfscanf_r (_REENT, fp, fmt, ap);
}
diff --git a/newlib/libc/stdio/clearerr.c b/newlib/libc/stdio/clearerr.c
index 0923ff84d..d3b620bed 100644
--- a/newlib/libc/stdio/clearerr.c
+++ b/newlib/libc/stdio/clearerr.c
@@ -64,7 +64,7 @@ _VOID
_DEFUN(clearerr, (fp),
FILE * fp)
{
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, fp);
_flockfile (fp);
__sclearerr (fp);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c
index 66d71c2d4..bb3acb624 100644
--- a/newlib/libc/stdio/fclose.c
+++ b/newlib/libc/stdio/fclose.c
@@ -76,7 +76,7 @@ _DEFUN(_fclose_r, (rptr, fp),
__sfp_lock_acquire ();
- CHECK_INIT (rptr);
+ CHECK_INIT (rptr, fp);
_flockfile (fp);
diff --git a/newlib/libc/stdio/feof.c b/newlib/libc/stdio/feof.c
index aff4e84c8..e8db65b86 100644
--- a/newlib/libc/stdio/feof.c
+++ b/newlib/libc/stdio/feof.c
@@ -57,7 +57,7 @@ _DEFUN(feof, (fp),
FILE * fp)
{
int result;
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, fp);
_flockfile (fp);
result = __sfeof (fp);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/ferror.c b/newlib/libc/stdio/ferror.c
index ea701bec7..72b7ce2c5 100644
--- a/newlib/libc/stdio/ferror.c
+++ b/newlib/libc/stdio/ferror.c
@@ -66,7 +66,7 @@ _DEFUN(ferror, (fp),
FILE * fp)
{
int result;
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, fp);
_flockfile (fp);
result = __sferror (fp);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c
index 05084dde0..bac49804f 100644
--- a/newlib/libc/stdio/fflush.c
+++ b/newlib/libc/stdio/fflush.c
@@ -67,7 +67,7 @@ _DEFUN(fflush, (fp),
if (fp == NULL)
return _fwalk (_GLOBAL_REENT, fflush);
- CHECK_INIT (_REENT);
+ CHECK_INIT (_REENT, fp);
_flockfile (fp);
diff --git a/newlib/libc/stdio/fgetc.c b/newlib/libc/stdio/fgetc.c
index 020b2da3a..87a1693f2 100644
--- a/newlib/libc/stdio/fgetc.c
+++ b/newlib/libc/stdio/fgetc.c
@@ -62,7 +62,7 @@ _DEFUN(fgetc, (fp),
FILE * fp)
{
int result;
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, fp);
_flockfile (fp);
result = __sgetc (fp);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c
index f5dde4903..0de70fe13 100644
--- a/newlib/libc/stdio/fgets.c
+++ b/newlib/libc/stdio/fgets.c
@@ -80,7 +80,7 @@ _DEFUN(fgets, (buf, n, fp),
s = buf;
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, fp);
_flockfile (fp);
#ifdef __SCLE
diff --git a/newlib/libc/stdio/fileno.c b/newlib/libc/stdio/fileno.c
index b202cc5e3..db399eb12 100644
--- a/newlib/libc/stdio/fileno.c
+++ b/newlib/libc/stdio/fileno.c
@@ -54,7 +54,7 @@ _DEFUN(fileno, (f),
FILE * f)
{
int result;
- CHECK_INIT (_REENT);
+ CHECK_INIT (_REENT, f);
_flockfile (f);
result = __sfileno (f);
_funlockfile (f);
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index e3270af38..ac1354619 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -26,6 +26,15 @@
#include <sys/lock.h>
#include "local.h"
+#ifdef _REENT_SMALL
+const struct __sFILE_fake __sf_fake_stdin =
+ {_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL};
+const struct __sFILE_fake __sf_fake_stdout =
+ {_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL};
+const struct __sFILE_fake __sf_fake_stderr =
+ {_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL};
+#endif
+
static _VOID
_DEFUN(std, (ptr, flags, file, data),
FILE *ptr _AND
diff --git a/newlib/libc/stdio/fputc.c b/newlib/libc/stdio/fputc.c
index 422f6753a..c4bcb3234 100644
--- a/newlib/libc/stdio/fputc.c
+++ b/newlib/libc/stdio/fputc.c
@@ -67,7 +67,7 @@ _DEFUN(fputc, (ch, file),
FILE * file)
{
int result;
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, file);
_flockfile (file);
result = putc (ch, file);
_funlockfile (file);
diff --git a/newlib/libc/stdio/fputs.c b/newlib/libc/stdio/fputs.c
index 8d02107df..9b28d8543 100644
--- a/newlib/libc/stdio/fputs.c
+++ b/newlib/libc/stdio/fputs.c
@@ -71,7 +71,7 @@ _DEFUN(fputs, (s, fp),
uio.uio_iov = &iov;
uio.uio_iovcnt = 1;
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, fp);
_flockfile (fp);
result = __sfvwrite (fp, &uio);
diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c
index 1354c04ba..29fc78fe0 100644
--- a/newlib/libc/stdio/fread.c
+++ b/newlib/libc/stdio/fread.c
@@ -125,7 +125,7 @@ _DEFUN(fread, (buf, size, count, fp),
if ((resid = count * size) == 0)
return 0;
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, fp);
_flockfile (fp);
if (fp->_r < 0)
diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c
index ae3444b1b..9a7afe685 100644
--- a/newlib/libc/stdio/freopen.c
+++ b/newlib/libc/stdio/freopen.c
@@ -99,7 +99,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
__sfp_lock_acquire ();
- CHECK_INIT (ptr);
+ CHECK_INIT (ptr, fp);
_flockfile (fp);
diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c
index 8b189ba17..cee49d759 100644
--- a/newlib/libc/stdio/fseek.c
+++ b/newlib/libc/stdio/fseek.c
@@ -131,7 +131,7 @@ _DEFUN(_fseek_r, (ptr, fp, offset, whence),
/* Make sure stdio is set up. */
- CHECK_INIT (ptr);
+ CHECK_INIT (ptr, fp);
_flockfile (fp);
diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c
index 74d6d906c..de5d55d44 100644
--- a/newlib/libc/stdio/ftell.c
+++ b/newlib/libc/stdio/ftell.c
@@ -107,7 +107,7 @@ _DEFUN(_ftell_r, (ptr, fp),
/* Ensure stdio is set up. */
- CHECK_INIT (ptr);
+ CHECK_INIT (ptr, fp);
_flockfile (fp);
diff --git a/newlib/libc/stdio/fwrite.c b/newlib/libc/stdio/fwrite.c
index 663fff62c..cfcdc7479 100644
--- a/newlib/libc/stdio/fwrite.c
+++ b/newlib/libc/stdio/fwrite.c
@@ -99,7 +99,7 @@ _DEFUN(fwrite, (buf, size, count, fp),
* generally slow and since this occurs whenever size==0.
*/
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, fp);
_flockfile (fp);
if (__sfvwrite (fp, &uio) == 0)
diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c
index 9628a8740..5dfd76ec6 100644
--- a/newlib/libc/stdio/getc.c
+++ b/newlib/libc/stdio/getc.c
@@ -77,7 +77,7 @@ _DEFUN(getc, (fp),
register FILE *fp)
{
int result;
- CHECK_INIT (_REENT);
+ CHECK_INIT (_REENT, fp);
_flockfile (fp);
result = __sgetc (fp);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/getdelim.c b/newlib/libc/stdio/getdelim.c
index 0fdfb3add..23fc50218 100644
--- a/newlib/libc/stdio/getdelim.c
+++ b/newlib/libc/stdio/getdelim.c
@@ -79,7 +79,7 @@ _DEFUN(__getdelim, (bufptr, n, delim, fp),
*n = DEFAULT_LINE_SIZE;
}
- CHECK_INIT (_REENT);
+ CHECK_INIT (_REENT, fp);
_flockfile (fp);
diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h
index f7093b697..e1ac0c450 100644
--- a/newlib/libc/stdio/local.h
+++ b/newlib/libc/stdio/local.h
@@ -49,7 +49,31 @@ extern int _EXFUN(__srefill,(FILE *fp));
/* Called by the main entry point fns to ensure stdio has been initialized. */
-#define CHECK_INIT(ptr) \
+#ifdef _REENT_SMALL
+#define CHECK_INIT(ptr, fp) \
+ do \
+ { \
+ if ((ptr) && !(ptr)->__sdidinit) \
+ __sinit (ptr); \
+ if ((fp) == (FILE *)&__sf_fake_stdin) \
+ (fp) = stdin; \
+ else if ((fp) == (FILE *)&__sf_fake_stdout) \
+ (fp) = stdout; \
+ else if ((fp) == (FILE *)&__sf_fake_stderr) \
+ (fp) = stderr; \
+ } \
+ while (0)
+#else /* !_REENT_SMALL */
+#define CHECK_INIT(ptr, fp) \
+ do \
+ { \
+ if ((ptr) && !(ptr)->__sdidinit) \
+ __sinit (ptr); \
+ } \
+ while (0)
+#endif /* !_REENT_SMALL */
+
+#define CHECK_STD_INIT(ptr) \
do \
{ \
if ((ptr) && !(ptr)->__sdidinit) \
diff --git a/newlib/libc/stdio/putc.c b/newlib/libc/stdio/putc.c
index 097323417..3aa4e609d 100644
--- a/newlib/libc/stdio/putc.c
+++ b/newlib/libc/stdio/putc.c
@@ -81,7 +81,7 @@ _DEFUN(putc, (c, fp),
register FILE *fp)
{
int result;
- CHECK_INIT (_REENT);
+ CHECK_INIT (_REENT, fp);
_flockfile (fp);
result = __sputc (c, fp);
_funlockfile (fp);
diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c
index 639ce6e24..b98013fdb 100644
--- a/newlib/libc/stdio/refill.c
+++ b/newlib/libc/stdio/refill.c
@@ -41,7 +41,7 @@ _DEFUN(__srefill, (fp),
{
/* make sure stdio is set up */
- CHECK_INIT (_REENT);
+ CHECK_INIT (_REENT, fp);
fp->_r = 0; /* largely a convenience for callers */
diff --git a/newlib/libc/stdio/setvbuf.c b/newlib/libc/stdio/setvbuf.c
index f6871c59d..561f68b54 100644
--- a/newlib/libc/stdio/setvbuf.c
+++ b/newlib/libc/stdio/setvbuf.c
@@ -104,7 +104,7 @@ _DEFUN(setvbuf, (fp, buf, mode, size),
{
int ret = 0;
- CHECK_INIT (_REENT);
+ CHECK_INIT (_REENT, fp);
_flockfile (fp);
diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c
index fc6fa3160..333baa278 100644
--- a/newlib/libc/stdio/ungetc.c
+++ b/newlib/libc/stdio/ungetc.c
@@ -81,7 +81,7 @@ _DEFUN(_ungetc_r, (rptr, c, fp),
??? Might be able to remove this as some other stdio routine should
have already been called to get the char we are un-getting. */
- CHECK_INIT (rptr);
+ CHECK_INIT (rptr, fp);
_flockfile (fp);
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c
index a8c1f9bca..bdd5a83f9 100644
--- a/newlib/libc/stdio/vfprintf.c
+++ b/newlib/libc/stdio/vfprintf.c
@@ -533,7 +533,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
(u_long)GET_ARG (N, ap, u_int))
#endif
- CHECK_INIT (data);
+ CHECK_INIT (data, fp);
_flockfile (fp);
/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c
index 4788938c9..bd29b56bb 100644
--- a/newlib/libc/stdio/vfscanf.c
+++ b/newlib/libc/stdio/vfscanf.c
@@ -231,7 +231,7 @@ _DEFUN(VFSCANF, (fp, fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
- CHECK_INIT(_REENT);
+ CHECK_INIT(_REENT, fp);
return __SVFSCANF_R (_REENT, fp, fmt, ap);
}
@@ -253,7 +253,7 @@ _DEFUN(_VFSCANF_R, (data, fp, fmt, ap),
_CONST char *fmt _AND
va_list ap)
{
- CHECK_INIT(data);
+ CHECK_INIT(data, fp);
return __SVFSCANF_R (data, fp, fmt, ap);
}
diff --git a/newlib/libc/stdio/wbuf.c b/newlib/libc/stdio/wbuf.c
index e7ddb4913..f75af3ed6 100644
--- a/newlib/libc/stdio/wbuf.c
+++ b/newlib/libc/stdio/wbuf.c
@@ -40,7 +40,7 @@ _DEFUN(__swbuf, (c, fp),
/* Ensure stdio has been initialized. */
- CHECK_INIT (_REENT);
+ CHECK_INIT (_REENT, fp);
/*
* In case we cannot write, or longjmp takes us out early,
diff --git a/newlib/libc/stdio/wsetup.c b/newlib/libc/stdio/wsetup.c
index cf56c2abc..ba98813b3 100644
--- a/newlib/libc/stdio/wsetup.c
+++ b/newlib/libc/stdio/wsetup.c
@@ -34,7 +34,7 @@ _DEFUN(__swsetup, (fp),
{
/* Make sure stdio is set up. */
- CHECK_INIT (_REENT);
+ CHECK_INIT (_REENT, fp);
/*
* If we are not writing, we had better be reading and writing.
diff --git a/newlib/libc/stdio64/freopen64.c b/newlib/libc/stdio64/freopen64.c
index 6081e03dc..7dde38d43 100644
--- a/newlib/libc/stdio64/freopen64.c
+++ b/newlib/libc/stdio64/freopen64.c
@@ -99,7 +99,7 @@ _DEFUN (_freopen64_r, (ptr, file, mode, fp),
__sfp_lock_acquire ();
- CHECK_INIT (ptr);
+ CHECK_INIT (ptr, fp);
_flockfile(fp);
diff --git a/newlib/libc/stdio64/fseeko64.c b/newlib/libc/stdio64/fseeko64.c
index edd764009..491370e10 100644
--- a/newlib/libc/stdio64/fseeko64.c
+++ b/newlib/libc/stdio64/fseeko64.c
@@ -113,7 +113,7 @@ _DEFUN (_fseeko64_r, (ptr, fp, offset, whence),
/* Make sure stdio is set up. */
- CHECK_INIT (ptr);
+ CHECK_INIT (ptr, fp);
_flockfile(fp);
diff --git a/newlib/libc/stdio64/ftello64.c b/newlib/libc/stdio64/ftello64.c
index ef3317561..2a8d30925 100644
--- a/newlib/libc/stdio64/ftello64.c
+++ b/newlib/libc/stdio64/ftello64.c
@@ -93,7 +93,7 @@ _DEFUN (_ftello64_r, (ptr, fp),
/* Ensure stdio is set up. */
- CHECK_INIT (ptr);
+ CHECK_INIT (ptr, fp);
_flockfile(fp);