🆕 fork vfork

This commit is contained in:
fslongjin 2022-05-06 11:44:38 +08:00
parent ffb0a3c961
commit c9784b457c

View File

@ -1,18 +1,17 @@
#include <libc/unistd.h>
#include <libsystem/syscall.h>
/**
* @brief
*
*
* @param str
* @param front_color
* @param bg_color
* @return int64_t
* @return int64_t
*/
int64_t put_string(char* str, uint64_t front_color, uint64_t bg_color)
int64_t put_string(char *str, uint64_t front_color, uint64_t bg_color)
{
return syscall_invoke(SYS_PUT_STRING, str, front_color, bg_color,0,0,0,0,0);
return syscall_invoke(SYS_PUT_STRING, (uint64_t)str, front_color, bg_color, 0, 0, 0, 0, 0);
}
/**
* @brief
@ -35,7 +34,7 @@ int close(int fd)
*/
ssize_t read(int fd, void *buf, size_t count)
{
return (ssize_t)syscall_invoke(SYS_READ, fd, buf, count,0,0,0,0,0);
return (ssize_t)syscall_invoke(SYS_READ, fd, (uint64_t)buf, count, 0, 0, 0, 0, 0);
}
/**
@ -48,7 +47,7 @@ ssize_t read(int fd, void *buf, size_t count)
*/
ssize_t write(int fd, void const *buf, size_t count)
{
return (ssize_t)syscall_invoke(SYS_WRITE, fd, buf, count,0,0,0,0,0);
return (ssize_t)syscall_invoke(SYS_WRITE, fd, (uint64_t)buf, count, 0, 0, 0, 0, 0);
}
/**
@ -61,5 +60,25 @@ ssize_t write(int fd, void const *buf, size_t count)
*/
off_t lseek(int fd, off_t offset, int whence)
{
return (off_t)syscall_invoke(SYS_LSEEK, fd, offset, whence, 0,0,0,0,0);
return (off_t)syscall_invoke(SYS_LSEEK, fd, offset, whence, 0, 0, 0, 0, 0);
}
/**
* @brief fork当前进程
*
* @return pid_t
*/
pid_t fork(void)
{
return (pid_t)syscall_invoke(SYS_FORK, 0, 0, 0, 0, 0, 0, 0, 0);
}
/**
* @brief fork当前进程VMflagsfd
*
* @return pid_t
*/
pid_t vfork(void)
{
return (pid_t)syscall_invoke(SYS_VFORK, 0, 0, 0, 0, 0, 0, 0, 0);
}