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
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2004-01-23 01:06:57 +0300
committerJeff Johnston <jjohnstn@redhat.com>2004-01-23 01:06:57 +0300
commited1a95dc2529af31b0c622da451334a12ef6d436 (patch)
tree2df670892645fd4888b1bd47b782532c4415bba2 /newlib
parentfba870ac948ba9132be02dfde3a3aaf041d1c8c8 (diff)
2004-01-22 Thomas Pfaff <tpfaff@gmx.net>
* libc/stdio/findfp.c (__sfp): Protect global FILE pointer list by a lock when newlib is multithreaded.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog5
-rw-r--r--newlib/libc/stdio/findfp.c12
2 files changed, 17 insertions, 0 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index a3e0ff9a9..0421e7ee2 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,8 @@
+2004-01-22 Thomas Pfaff <tpfaff@gmx.net>
+
+ * libc/stdio/findfp.c (__sfp): Protect global FILE pointer list
+ by a lock when newlib is multithreaded.
+
2004-01-21 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/mbrtowc.c (_mbrtowc_r): Fix case where s is null
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index aff231ed4..0ea7e31a2 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -86,6 +86,12 @@ __sfp (d)
int n;
struct _glue *g;
+#ifndef __SINGLE_THREAD__
+ __LOCK_INIT(static, lock);
+
+ __lock_acquire(lock);
+#endif
+
if (!_GLOBAL_REENT->__sdidinit)
__sinit (_GLOBAL_REENT);
for (g = &_GLOBAL_REENT->__sglue;; g = g->_next)
@@ -97,11 +103,17 @@ __sfp (d)
(g->_next = __sfmoreglue (d, NDYNAMIC)) == NULL)
break;
}
+#ifndef __SINGLE_THREAD__
+ __lock_release(lock);
+#endif
d->_errno = ENOMEM;
return NULL;
found:
fp->_flags = 1; /* reserve this slot; caller sets real flags */
+#ifndef __SINGLE_THREAD__
+ __lock_release(lock);
+#endif
fp->_p = NULL; /* no current pointer */
fp->_w = 0; /* nothing to read or write */
fp->_r = 0;