From 1b0cdc8700d29ef018bf226d74b2b58b23bce91c Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 16 Jun 2015 07:11:19 +0000 Subject: 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. --- src/internal/libc.h | 2 -- src/internal/stdio_impl.h | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/internal') diff --git a/src/internal/libc.h b/src/internal/libc.h index 6810cd8b..98c7535a 100644 --- a/src/internal/libc.h +++ b/src/internal/libc.h @@ -17,8 +17,6 @@ struct __libc { int secure; volatile int threads_minus_1; size_t *auxv; - FILE *ofl_head; - volatile int ofl_lock[2]; size_t tls_size; size_t page_size; struct __locale_struct global_locale; diff --git a/src/internal/stdio_impl.h b/src/internal/stdio_impl.h index 72c55192..0dd7fb5e 100644 --- a/src/internal/stdio_impl.h +++ b/src/internal/stdio_impl.h @@ -76,8 +76,9 @@ int __putc_unlocked(int, FILE *); FILE *__fdopen(int, const char *); int __fmodeflags(const char *); -#define OFLLOCK() LOCK(libc.ofl_lock) -#define OFLUNLOCK() UNLOCK(libc.ofl_lock) +FILE *__ofl_add(FILE *f); +FILE **__ofl_lock(void); +void __ofl_unlock(void); #define feof(f) ((f)->flags & F_EOF) #define ferror(f) ((f)->flags & F_ERR) -- cgit v1.2.1