summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/findfp.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2010-03-11 17:03:32 +0000
committerjhb <jhb@FreeBSD.org>2010-03-11 17:03:32 +0000
commit2684d78c89ad7cfd18346398691e6e03d263f6c6 (patch)
treee077a892f44aba8196f30652e58ab6d758a2af4a /lib/libc/stdio/findfp.c
parent03101f1cf6eaf4791f0ae5844d6c40b9f282a3ef (diff)
downloadFreeBSD-src-2684d78c89ad7cfd18346398691e6e03d263f6c6.zip
FreeBSD-src-2684d78c89ad7cfd18346398691e6e03d263f6c6.tar.gz
- Use an initializer macro to initialize fields in 'fake' FILE objects used
by *sprintf(), etc. - Explicitly initialize _fl_mutex to PTHREAD_MUTEX_INITIALIZER for all FILE objects. This is currently a nop on FreeBSD, but is import for other platforms (or in the future) where PTHREAD_MUTEX_INITIALIZER is not simply zero. PR: threads/141198 Reported by: Jeremy Huddleston @ Apple MFC after: 2 weeks
Diffstat (limited to 'lib/libc/stdio/findfp.c')
-rw-r--r--lib/libc/stdio/findfp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c
index 5bc4af7..89c0536 100644
--- a/lib/libc/stdio/findfp.c
+++ b/lib/libc/stdio/findfp.c
@@ -61,6 +61,7 @@ int __sdidinit;
._read = __sread, \
._seek = __sseek, \
._write = __swrite, \
+ ._fl_mutex = PTHREAD_MUTEX_INITIALIZER, \
}
/* the usual - (stdin + stdout + stderr) */
static FILE usual[FOPEN_MAX - 3];
@@ -96,7 +97,7 @@ moreglue(n)
int n;
{
struct glue *g;
- static FILE empty;
+ static FILE empty = { ._fl_mutex = PTHREAD_MUTEX_INITIALIZER };
FILE *p;
g = (struct glue *)malloc(sizeof(*g) + ALIGNBYTES + n * sizeof(FILE));
@@ -154,7 +155,7 @@ found:
fp->_ub._size = 0;
fp->_lb._base = NULL; /* no line buffer */
fp->_lb._size = 0;
-/* fp->_lock = NULL; */ /* once set always set (reused) */
+/* fp->_fl_mutex = NULL; */ /* once set always set (reused) */
fp->_orientation = 0;
memset(&fp->_mbstate, 0, sizeof(mbstate_t));
return (fp);
OpenPOWER on IntegriCloud