From 07c004bf3cf7fcb6e875bddb1a7fb0793377ebfb Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Mon, 24 Feb 2020 17:39:40 +1100 Subject: Changed read() and write() calls to now accept an integer file descriptor as their first parameter. read()/write() calls to descriptors other than stdin/stdout respectively, are currently discared as the file table has yet to be fully implemented. --- include/stdio.h | 4 ++-- include/unistd.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/stdio.h b/include/stdio.h index 5387db0..9a599fe 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -14,8 +14,8 @@ int sprintf(char*, char*, ...); int vsprintf(char*, char*, va_list); -ssize_t read(void*, size_t); -ssize_t write(void*, size_t); +ssize_t read(int, void*, size_t); +ssize_t write(int, void*, size_t); int ctty(int); diff --git a/include/unistd.h b/include/unistd.h index 47e1621..0b3c666 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -8,6 +8,10 @@ typedef int32_t ssize_t; #endif +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + typedef int16_t pid_t; #define __SYS_alarm 0 @@ -55,6 +59,17 @@ typedef int16_t pid_t; return __res; \ } +#define _syscall3(type, name, atype, a, btype, b, ctype, c) \ + type name(atype a, btype b, ctype c) { \ + type __res; \ + __asm__ volatile ( \ + "int $0x80" \ + : "=a" (__res) \ + : "a" (__SYS_##name), "b" (a), "c" (b), "d" (c) \ + ); \ + return __res; \ + } + pid_t getpid(void); void *getpdir(void); -- cgit v1.3