diff --git a/newlib/src/libgloss/metalsvm/read.c b/newlib/src/libgloss/metalsvm/read.c index ab4ff5cc..a240d838 100644 --- a/newlib/src/libgloss/metalsvm/read.c +++ b/newlib/src/libgloss/metalsvm/read.c @@ -24,6 +24,7 @@ #undef errno extern int errno; #include "warning.h" +#include "syscall.h" int _DEFUN (_read, (file, ptr, len), @@ -31,5 +32,13 @@ _DEFUN (_read, (file, ptr, len), char *ptr _AND int len) { - return 0; + int ret; + + ret = SYSCALL3(__NR_read, file, ptr, len); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; } diff --git a/newlib/src/libgloss/metalsvm/syscall.h b/newlib/src/libgloss/metalsvm/syscall.h index e5d18093..478447ed 100644 --- a/newlib/src/libgloss/metalsvm/syscall.h +++ b/newlib/src/libgloss/metalsvm/syscall.h @@ -36,6 +36,7 @@ extern "C" { #define __NR_fstat 10 #define __NR_sbrk 11 #define __NR_fork 12 +#define __NR_wait 13 #define _STR(token) #token #define _SYSCALLSTR(x) "int $" _STR(x) " " diff --git a/newlib/src/libgloss/metalsvm/wait.c b/newlib/src/libgloss/metalsvm/wait.c index 420dc860..166bef02 100644 --- a/newlib/src/libgloss/metalsvm/wait.c +++ b/newlib/src/libgloss/metalsvm/wait.c @@ -23,14 +23,21 @@ #include #undef errno extern int errno; +#include "syscall.h" #include "warning.h" int _DEFUN (_wait, (status), int *status) { - errno = ENOSYS; - return -1; -} + int ret; -stub_warning(_wait) + /* create a child process */ + ret = SYSCALL1(__NR_wait, status); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; +}