提交 b212fb05 编写于 作者: L li-tao116

Optimize fileno_unlocked

Implement fileno_unlocked without FLOCK.

Issue: #I7L16Z
Test: libctest, benchmark
Signed-off-by: Nlitao <litao@kaihong.com>
Change-Id: Iee03e7a561e5bedde74054910a0e7ecebf7afe67
上级 e932e671
......@@ -2214,6 +2214,7 @@ musl_src_porting_file = [
"src/misc/aarch64/syscall.s",
"src/stdlib/strtod.c",
"src/stdio/vfscanf.c",
"src/stdio/fileno.c",
]
musl_inc_hook_files = [
......
#include "stdio_impl.h"
#include <errno.h>
int fileno_unlocked(FILE *f)
{
int fd = f->fd;
if (fd < 0) {
errno = EBADF;
return -1;
}
return fd;
}
int fileno(FILE *f)
{
FLOCK(f);
int fd = fileno_unlocked(f);
FUNLOCK(f);
return fd;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册