Luna/libs/libc/src/unistd.cpp

77 lines
1.5 KiB
C++
Raw Normal View History

#include <fcntl.h>
#include <luna.h>
#include <sys/syscall.h>
#include <unistd.h>
extern "C"
{
int execv(const char* program, char* const[])
{
return (int)syscall(SYS_exec, program);
}
int execve(const char*, char* const[], char* const[])
{
NOT_IMPLEMENTED("execve");
}
int execvp(const char*, char* const[])
{
NOT_IMPLEMENTED("execvp");
}
pid_t fork(void)
{
return syscall(SYS_fork);
}
pid_t getpid(void)
{
return getprocid(ID_PID);
}
pid_t getppid(void)
{
return getprocid(ID_PPID);
}
unsigned int sleep(unsigned int seconds)
{
return msleep(seconds * 1000);
}
ssize_t read(int fd, void* buf, size_t count)
{
return syscall(SYS_read, fd, count, buf); // yes, our read() syscall is in the wrong order.
}
ssize_t write(int fd, const void* buf, size_t count)
{
2022-10-11 19:17:07 +00:00
return syscall(SYS_write, fd, count, buf); // yes, our write() syscall is in the wrong order.
}
int close(int fd)
{
return (int)syscall(SYS_close, fd);
}
2022-10-12 13:37:29 +00:00
off_t lseek(int fd, off_t offset, int whence)
{
return syscall(SYS_seek, fd, offset, whence);
}
__lc_noreturn void _exit(int status)
{
syscall(SYS_exit, status);
__lc_unreachable();
}
int dup(int fd)
{
return fcntl(fd, F_DUPFD, 0);
}
2022-10-20 17:03:24 +00:00
int access(const char* path, int amode)
{
return (int)syscall(SYS_access, path, amode);
}
}