mirror of
https://github.com/fluencelabs/musl
synced 2025-05-30 08:01:38 +00:00
some of these were coming from stdio functions locking files without unlocking them. I believe it's useful for this to throw a warning, so I added a new macro that's self-documenting that the file will never be unlocked to avoid the warning in the few places where it's wrong.
24 lines
511 B
C
24 lines
511 B
C
#include "stdio_impl.h"
|
|
|
|
static FILE *const dummy_file = 0;
|
|
weak_alias(dummy_file, __stdin_used);
|
|
weak_alias(dummy_file, __stdout_used);
|
|
weak_alias(dummy_file, __stderr_used);
|
|
|
|
static void close_file(FILE *f)
|
|
{
|
|
if (!f) return;
|
|
FFINALLOCK(f);
|
|
if (f->wpos > f->wbase) f->write(f, 0, 0);
|
|
if (f->rpos < f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR);
|
|
}
|
|
|
|
void __stdio_exit(void)
|
|
{
|
|
FILE *f;
|
|
OFLLOCK();
|
|
for (f=libc.ofl_head; f; f=f->next) close_file(f);
|
|
close_file(__stdin_used);
|
|
close_file(__stdout_used);
|
|
}
|