about summary refs log tree commit diff
path: root/src/thread
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2015-06-16 07:11:19 +0000
committerRich Felker <dalias@aerifal.cx>2015-06-16 07:11:19 +0000
commit1b0cdc8700d29ef018bf226d74b2b58b23bce91c (patch)
tree53c58824a9d73de47296b5a8885aefc9a1f39d0b /src/thread
parentf22a9edaf8a6f2ca1d314d18b3785558279a5c03 (diff)
downloadmusl-1b0cdc8700d29ef018bf226d74b2b58b23bce91c.tar.gz
musl-1b0cdc8700d29ef018bf226d74b2b58b23bce91c.tar.xz
musl-1b0cdc8700d29ef018bf226d74b2b58b23bce91c.zip
refactor stdio open file list handling, move it out of global libc struct
functions which open in-memory FILE stream variants all shared a tail
with __fdopen, adding the FILE structure to stdio's open file list.
replacing this common tail with a function call reduces code size and
duplication of logic. the list is also partially encapsulated now.

function signatures were chosen to facilitate tail call optimization
and reduce the need for additional accessor functions.

with these changes, static linked programs that do not use stdio no
longer have an open file list at all.
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/pthread_create.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
index de72818d..6e2e4816 100644
--- a/src/thread/pthread_create.c
+++ b/src/thread/pthread_create.c
@@ -191,8 +191,9 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
 	if (!libc.can_do_threads) return ENOSYS;
 	self = __pthread_self();
 	if (!libc.threaded) {
-		for (FILE *f=libc.ofl_head; f; f=f->next)
+		for (FILE *f=*__ofl_lock(); f; f=f->next)
 			init_file_lock(f);
+		__ofl_unlock();
 		init_file_lock(__stdin_used);
 		init_file_lock(__stdout_used);
 		init_file_lock(__stderr_used);