1 #include "stdio_impl.h"
2 
3 static FILE *volatile dummy_file = 0;
4 weak_alias(dummy_file, __stdin_used);
5 weak_alias(dummy_file, __stdout_used);
6 weak_alias(dummy_file, __stderr_used);
7 
close_file(FILE *f)8 static void close_file(FILE *f)
9 {
10 	if (!f) return;
11 #ifndef __LITEOS_A__
12 	FFINALLOCK(f);
13 #endif
14 	if (f->wpos != f->wbase) f->write(f, 0, 0);
15 	if (f->rpos != f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR);
16 }
17 
__stdio_exit(void)18 void __stdio_exit(void)
19 {
20 	FILE *f;
21 	for (f=*__ofl_lock(); f; f=f->next) close_file(f);
22 	close_file(__stdin_used);
23 	close_file(__stdout_used);
24 	close_file(__stderr_used);
25 }
26 
27 weak_alias(__stdio_exit, __stdio_exit_needed);
28