summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libc/stdio/findfp.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c
index e0f0e29..4911400 100644
--- a/lib/libc/stdio/findfp.c
+++ b/lib/libc/stdio/findfp.c
@@ -66,6 +66,7 @@ int __sdidinit;
/* _ub _extra */
/* the usual - (stdin + stdout + stderr) */
static FILE usual[FOPEN_MAX - 3];
+static struct __sFILEX usual_extra[FOPEN_MAX - 3];
static struct glue uglue = { NULL, FOPEN_MAX - 3, usual };
static struct __sFILEX __sFX[3];
@@ -215,7 +216,17 @@ _cleanup()
void
__sinit()
{
- /* Make sure we clean up on exit. */
- __cleanup = _cleanup; /* conservative */
- __sdidinit = 1;
+ int i;
+
+ THREAD_LOCK();
+ if (__sdidinit == 0) {
+ /* Set _extra for the usual suspects. */
+ for (i = 0; i < FOPEN_MAX - 3; i++)
+ usual[i]._extra = &usual_extra[i];
+
+ /* Make sure we clean up on exit. */
+ __cleanup = _cleanup; /* conservative */
+ __sdidinit = 1;
+ }
+ THREAD_UNLOCK();
}
OpenPOWER on IntegriCloud