mescc: Tinycc support: lseek.

* mlibc/include/unistd.h (lseek): Declare.
* stage0/x86.M1 (SYS_lseek): New define.
* mlibc/libc-mes+tcc.c (lseek): New function.
This commit is contained in:
Jan Nieuwenhuizen 2017-07-24 17:33:33 +02:00
parent a8f22ea993
commit 9f60904d1c
3 changed files with 19 additions and 0 deletions

View File

@ -29,6 +29,11 @@
#else // ! (__GNUC__ && POSIX)
#ifndef __MES_OFF_T
#define __MES_OFF_T
typedef unsigned long off_t;
#endif
#ifndef __MES_SIZE_T
#define __MES_SIZE_T
typedef unsigned long size_t;
@ -42,6 +47,7 @@ typedef long ssize_t;
int access (char const *s, int mode);
int close (int fd);
char *getcwd (char *buf, size_t size);
off_t lseek (int fd, off_t offset, int whence);
int read (int fd, void* buf, size_t n);
int unlink (char const *file_name);
int write (int fd, char const* s, int n);

View File

@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
void
close ()
@ -52,6 +53,17 @@ unlink (char const *file_name)
asm ("int____$0x80");
}
off_t
lseek (int fd, off_t offset, int whence)
{
asm ("mov____0x8(%ebp),%ebx !8");
asm ("mov____0x8(%ebp),%ecx !12");
asm ("mov____0x8(%ebp),%edx !16");
asm ("mov____$i32,%eax SYS_lseek");
asm ("int____$0x80");
}
int
fclose (FILE *stream)

View File

@ -164,6 +164,7 @@ DEFINE SYS_write 04000000
DEFINE SYS_open 05000000
DEFINE SYS_close 06000000
DEFINE SYS_unlink 0a000000
DEFINE SYS_lseek 13000000
DEFINE SYS_access 21000000
DEFINE SYS_brk 2d000000
DEFINE SYS_fsync 76000000