diff options
author | Rich Felker <dalias@aerifal.cx> | 2015-06-16 07:11:19 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2015-06-16 07:11:19 +0000 |
commit | 1b0cdc8700d29ef018bf226d74b2b58b23bce91c (patch) | |
tree | 53c58824a9d73de47296b5a8885aefc9a1f39d0b /src/internal | |
parent | f22a9edaf8a6f2ca1d314d18b3785558279a5c03 (diff) | |
download | musl-1b0cdc8700d29ef018bf226d74b2b58b23bce91c.tar.gz musl-1b0cdc8700d29ef018bf226d74b2b58b23bce91c.tar.bz2 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/internal')
-rw-r--r-- | src/internal/libc.h | 2 | ||||
-rw-r--r-- | src/internal/stdio_impl.h | 5 |
2 files changed, 3 insertions, 4 deletions
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) |