diff --git a/mlibc/include/unistd.h b/mlibc/include/unistd.h index a6b3ae3f..0ef60562 100644 --- a/mlibc/include/unistd.h +++ b/mlibc/include/unistd.h @@ -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); diff --git a/mlibc/libc-mes+tcc.c b/mlibc/libc-mes+tcc.c index 3e0c1146..5857d7de 100644 --- a/mlibc/libc-mes+tcc.c +++ b/mlibc/libc-mes+tcc.c @@ -23,6 +23,7 @@ #include #include #include +#include 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) diff --git a/stage0/x86.M1 b/stage0/x86.M1 index 5db4febb..f37f3747 100644 --- a/stage0/x86.M1 +++ b/stage0/x86.M1 @@ -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