mirror of
https://github.com/fluencelabs/musl
synced 2025-05-28 23:21:34 +00:00
these functions must behave as if they obtain the lock via flockfile to satisfy POSIX requirements. since another thread can provably hold the lock when they are called, they must wait to obtain the lock before they can return, even if the correct return value could be obtained without locking. in the case of fclose and freopen, failure to do so could cause correct (albeit obscure) programs to crash or otherwise misbehave; in the case of feof, ferror, and fwide, failure to obtain the lock could sometimes return incorrect results. in any case, having these functions proceed and return while another thread held the lock was wrong.
15 lines
201 B
C
15 lines
201 B
C
#include "stdio_impl.h"
|
|
|
|
#undef feof
|
|
|
|
int feof(FILE *f)
|
|
{
|
|
FLOCK(f);
|
|
int ret = !!(f->flags & F_EOF);
|
|
FUNLOCK(f);
|
|
return ret;
|
|
}
|
|
|
|
weak_alias(feof, feof_unlocked);
|
|
weak_alias(feof, _IO_feof_unlocked);
|