Add support for fflush and close syscalls

This commit is contained in:
2025-04-27 02:48:55 -04:00
parent f07d793e6c
commit adfdaa27f7
5 changed files with 84 additions and 0 deletions

View File

@@ -64,4 +64,28 @@ int32_t openat(int32_t fd, const char* filename, uint32_t flags, uint32_t mode)
return file;
}
#define SYS_CLOSE 3
int close(unsigned int fd) {
int rtn;
asm volatile(
"syscall"
: "=a"(rtn)
: "a"(SYS_CLOSE), "D"(fd)
: "rcx", "r11"
);
return rtn;
}
#define SYS_FSYNC 74
int fsync(unsigned int fd) {
int rtn;
asm volatile(
"syscall"
: "=a"(rtn)
: "a"(SYS_FSYNC), "D"(fd)
: "rcx", "r11"
);
return rtn;
}
#endif /* ifdef __x86_64__ */