diff options
author | Rich Felker <dalias@aerifal.cx> | 2014-07-16 20:44:22 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2014-07-16 20:44:22 -0400 |
commit | c463e11eda8326aacee2ac1d516954a9574a2dcd (patch) | |
tree | d184ab694ab4e47712752bfb78601609676de9fb /src/stdio/__towrite.c | |
parent | 781f26bc92b0710ac025fae3be42f5575468f1a5 (diff) | |
download | musl-c463e11eda8326aacee2ac1d516954a9574a2dcd.tar.gz musl-c463e11eda8326aacee2ac1d516954a9574a2dcd.tar.xz musl-c463e11eda8326aacee2ac1d516954a9574a2dcd.zip |
simplify __stdio_exit static linking logic
the purpose of this logic is to avoid linking __stdio_exit unless any stdio reads (which might require repositioning the file offset at exit time) or writes (which might require flushing at exit time) could have been performed. previously, exit called two wrapper functions for __stdio_exit named __flush_on_exit and __seek_on_exit. both of these functions actually performed both tasks (seek and flushing) by calling the underlying __stdio_exit. in order to avoid doing this twice, an overridable data object __towrite_used was used to cause __seek_on_exit to act as a nop when __towrite was linked. now, exit only makes one call, directly to __stdio_exit. this is satisfiable by a weak dummy definition in exit.c, but the real definition is pulled in by either __toread.c or __towrite.c through their referencing a symbol which is defined only in __stdio_exit.c.
Diffstat (limited to 'src/stdio/__towrite.c')
-rw-r--r-- | src/stdio/__towrite.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/stdio/__towrite.c b/src/stdio/__towrite.c index 380ea396..0a69d926 100644 --- a/src/stdio/__towrite.c +++ b/src/stdio/__towrite.c @@ -17,11 +17,9 @@ int __towrite(FILE *f) return 0; } -const int __towrite_used = 1; +void __stdio_exit_needed(void); -void __stdio_exit(void); - -void __flush_on_exit() +void __towrite_needs_stdio_exit() { - __stdio_exit(); + __stdio_exit_needed(); } |