xref: /third_party/musl/src/stdio/__stdio_exit.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/src/stdio/
1570af302Sopenharmony_ci#include "stdio_impl.h"
2570af302Sopenharmony_ci
3570af302Sopenharmony_cistatic FILE *volatile dummy_file = 0;
4570af302Sopenharmony_ciweak_alias(dummy_file, __stdin_used);
5570af302Sopenharmony_ciweak_alias(dummy_file, __stdout_used);
6570af302Sopenharmony_ciweak_alias(dummy_file, __stderr_used);
7570af302Sopenharmony_ci
8570af302Sopenharmony_cistatic void close_file(FILE *f)
9570af302Sopenharmony_ci{
10570af302Sopenharmony_ci	if (!f) return;
11570af302Sopenharmony_ci#ifndef __LITEOS_A__
12570af302Sopenharmony_ci	FFINALLOCK(f);
13570af302Sopenharmony_ci#endif
14570af302Sopenharmony_ci	if (f->wpos != f->wbase) f->write(f, 0, 0);
15570af302Sopenharmony_ci	if (f->rpos != f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR);
16570af302Sopenharmony_ci}
17570af302Sopenharmony_ci
18570af302Sopenharmony_civoid __stdio_exit(void)
19570af302Sopenharmony_ci{
20570af302Sopenharmony_ci	FILE *f;
21570af302Sopenharmony_ci	for (f=*__ofl_lock(); f; f=f->next) close_file(f);
22570af302Sopenharmony_ci	close_file(__stdin_used);
23570af302Sopenharmony_ci	close_file(__stdout_used);
24570af302Sopenharmony_ci	close_file(__stderr_used);
25570af302Sopenharmony_ci}
26570af302Sopenharmony_ci
27570af302Sopenharmony_ciweak_alias(__stdio_exit, __stdio_exit_needed);
28

Indexes created Thu Nov 07 10:32:03 CST 2024