mescc: Add fsync.

* module/mes/libc-i386.mes (i386:fsync): New function.
  (i386:libc): Export it.
* mlibc.c (fsync): New function.
This commit is contained in:
Jan Nieuwenhuizen 2017-04-15 15:13:38 +02:00
parent b41e35cf6f
commit 8460c4ab52
2 changed files with 31 additions and 0 deletions

18
mlibc.c
View File

@ -114,6 +114,24 @@ write (int fd, char const* s, int n)
);
}
int
fsync (int fd)
{
int r;
//syscall (SYS_fsync, fd));
asm (
"mov %1,%%ebx\n\t"
"mov $0x76, %%eax\n\t"
"int $0x80\n\t"
"mov %%eax,%0\n\t"
: "=r" (r)
: "" (fd)
: "eax", "ebx"
);
return r;
}
void *
brk (void *p)
{

View File

@ -92,6 +92,18 @@
#xc3 ; ret
))
(define (i386:fsync f g ta t d)
'(
#x55 ; push %ebp
#x89 #xe5 ; mov %esp,%ebp
#x8b #x5d #x08 ; mov 0x8(%ebp),%ebx
#xb8 #x76 #x00 #x00 #x00 ; mov $0x76,%eax
#xcd #x80 ; int $0x80
#xc9 ; leave
#xc3 ; ret
))
(define (i386:_start)
(string-append ".byte"
@ -110,4 +122,5 @@
(cons "open" (list i386:open))
(cons "read" (list i386:read))
(cons "write" (list i386:write))
(cons "fsync" (list i386:fsync))
(cons "brk" (list i386:brk))))