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:
authorMatt Joyce <matthew.joyce@embedded-brains.de>2022-02-22 13:18:38 +0300
committerCorinna Vinschen <corinna@vinschen.de>2022-02-22 14:38:46 +0300
commit44b60f0c4ba597c55dcac4f2d3119a3055c80ba1 (patch)
treee5286802e8b24fcbb7437f00163daaab0f439f2c /newlib/libc/stdio
parent054b00d96a81ca1169a1dd2d63d79b7ac03919ac (diff)
Make __sdidinit unused
Remove dependency on __sdidinit member of struct _reent to check object initialization. Like __sdidinit, the __cleanup member of struct _reent is initialized in the __sinit() function. Checking initialization against __cleanup serves the same purpose and will reduce overhead in the __sfp() function in a follow up patch.
Diffstat (limited to 'newlib/libc/stdio')
-rw-r--r--newlib/libc/stdio/findfp.c11
-rw-r--r--newlib/libc/stdio/local.h6
-rw-r--r--newlib/libc/stdio/setvbuf.c2
3 files changed, 6 insertions, 13 deletions
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index 896be99e9..9877c1f2c 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -152,7 +152,7 @@ __sfp (struct _reent *d)
_newlib_sfp_lock_start ();
- if (!_GLOBAL_REENT->__sdidinit)
+ if (_GLOBAL_REENT->__cleanup == NULL)
__sinit (_GLOBAL_REENT);
for (g = &_GLOBAL_REENT->__sglue;; g = g->_next)
{
@@ -246,7 +246,7 @@ __sinit (struct _reent *s)
{
__sinit_lock_acquire ();
- if (s->__sdidinit)
+ if (s->__cleanup)
{
__sinit_lock_release ();
return;
@@ -264,11 +264,6 @@ __sinit (struct _reent *s)
#else
s->__sglue._niobs = 0;
s->__sglue._iobs = NULL;
- /* Avoid infinite recursion when calling __sfp for _GLOBAL_REENT. The
- problem is that __sfp checks for _GLOBAL_REENT->__sdidinit and calls
- __sinit if it's 0. */
- if (s == _GLOBAL_REENT)
- s->__sdidinit = 1;
# ifndef _REENT_GLOBAL_STDIO_STREAMS
s->_stdin = __sfp(s);
s->_stdout = __sfp(s);
@@ -294,8 +289,6 @@ __sinit (struct _reent *s)
stderr_init (s->_stderr);
#endif /* _REENT_GLOBAL_STDIO_STREAMS */
- s->__sdidinit = 1;
-
__sinit_lock_release ();
}
diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h
index 84ff40b49..f63c5fb10 100644
--- a/newlib/libc/stdio/local.h
+++ b/newlib/libc/stdio/local.h
@@ -202,7 +202,7 @@ extern _READ_WRITE_RETURN_TYPE __swrite64 (struct _reent *, void *,
do \
{ \
struct _reent *_check_init_ptr = (ptr); \
- if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \
+ if ((_check_init_ptr) && !(_check_init_ptr)->__cleanup) \
__sinit (_check_init_ptr); \
if ((fp) == (FILE *)&__sf_fake_stdin) \
(fp) = _stdin_r(_check_init_ptr); \
@@ -217,7 +217,7 @@ extern _READ_WRITE_RETURN_TYPE __swrite64 (struct _reent *, void *,
do \
{ \
struct _reent *_check_init_ptr = (ptr); \
- if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \
+ if ((_check_init_ptr) && !(_check_init_ptr)->__cleanup) \
__sinit (_check_init_ptr); \
} \
while (0)
@@ -227,7 +227,7 @@ extern _READ_WRITE_RETURN_TYPE __swrite64 (struct _reent *, void *,
do \
{ \
struct _reent *_check_init_ptr = (ptr); \
- if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \
+ if ((_check_init_ptr) && !(_check_init_ptr)->__cleanup) \
__sinit (_check_init_ptr); \
} \
while (0)
diff --git a/newlib/libc/stdio/setvbuf.c b/newlib/libc/stdio/setvbuf.c
index f9eeefd1c..46c58a7b8 100644
--- a/newlib/libc/stdio/setvbuf.c
+++ b/newlib/libc/stdio/setvbuf.c
@@ -174,7 +174,7 @@ nbf:
* We're committed to buffering from here, so make sure we've
* registered to flush buffers on exit.
*/
- if (!reent->__sdidinit)
+ if (!reent->__cleanup)
__sinit(reent);
#ifdef _FSEEK_OPTIMIZATION