fix: 增加内核epoll系统调用

【背景】增加内核epoll系统调用适配musl接口并增加测试用例

【修改方案】
1, 删除musl仓的porting
2,内核实现epoll对应接口及注册系统调用
3,testsuit目录添加对应的用例

【影响】
对现有的产品编译不会有影响。

re #I4FXPT
Signed-off-by: wangchen <253227059@qq.com>

Change-Id: Ia97ea49067aa1ff47b8c1c83675ac75e75d25955
This commit is contained in:
lnlan
2021-10-20 03:46:41 +00:00
parent 38163de8f3
commit 2251b8a2d1
14 changed files with 849 additions and 0 deletions

129
syscall/fs_syscall.c Normal file → Executable file
View File

@@ -43,6 +43,7 @@
#include "sys/uio.h"
#include "poll.h"
#include "sys/prctl.h"
#include "epoll.h"
#ifdef LOSCFG_KERNEL_DYNLOAD
#include "los_exec_elf.h"
#endif
@@ -2594,4 +2595,132 @@ int SysPselect6(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
return ret;
}
int SysEpollCreate(int size)
{
int ret;
int procFd;
if (size <= 0) {
return -EINVAL;
}
ret = epoll_create(size);
if (ret < 0) {
ret = -get_errno();
}
procFd = AllocAndAssocProcessFd((INTPTR)(ret), MIN_START_FD);
if (procFd == -1) {
epoll_close(ret);
return -EMFILE;
}
return procFd;
}
int SysEpollCreate1(int flags)
{
int ret;
int procFd;
ret = epoll_create(flags);
if (ret < 0) {
ret = -get_errno();
}
procFd = AllocAndAssocProcessFd((INTPTR)(ret), MIN_START_FD);
if (procFd == -1) {
epoll_close(ret);
return -EMFILE;
}
return procFd;
}
int SysEpollCtl(int epfd, int op, int fd, struct epoll_event *ev)
{
int ret;
CHECK_ASPACE(ev, sizeof(struct epoll_event));
CPY_FROM_USER(ev);
fd = GetAssociatedSystemFd(fd);
epfd = GetAssociatedSystemFd(epfd);
if ((fd < 0) || (epfd < 0)) {
ret = -EBADF;
goto OUT;
}
ret = epoll_ctl(epfd, op, fd, ev);
if (ret < 0) {
ret =-EBADF;
goto OUT;
}
CPY_TO_USER(ev);
OUT:
return (ret == -1)? -get_errno():ret;
}
int SysEpollWait(int epfd, struct epoll_event *evs, int maxevents, int timeout)
{
int ret = 0;
CHECK_ASPACE(evs, sizeof(struct epoll_event));
CPY_FROM_USER(evs);
epfd = GetAssociatedSystemFd(epfd);
if (epfd < 0) {
ret = -EBADF;
goto OUT;
}
ret = epoll_wait(epfd, evs, maxevents, timeout);
if (ret < 0) {
ret = -get_errno();
}
CPY_TO_USER(evs);
OUT:
return (ret == -1) ? -get_errno() : ret;
}
int SysEpollPwait(int epfd, struct epoll_event *evs, int maxevents, int timeout, const sigset_t *mask)
{
sigset_t_l origMask;
sigset_t_l setl;
int ret = 0;
CHECK_ASPACE(mask, sizeof(sigset_t));
if (mask != NULL) {
ret = LOS_ArchCopyFromUser(&setl, mask, sizeof(sigset_t));
if (ret != 0) {
return -EFAULT;
}
}
CHECK_ASPACE(evs, sizeof(struct epoll_event));
CPY_FROM_USER(evs);
epfd = GetAssociatedSystemFd(epfd);
if (epfd < 0) {
ret = -EBADF;
goto OUT;
}
OsSigprocMask(SIG_SETMASK, &setl, &origMask);
ret = epoll_wait(epfd, evs, maxevents, timeout);
if (ret < 0) {
ret = -get_errno();
}
OsSigprocMask(SIG_SETMASK, &origMask, NULL);
CPY_TO_USER(evs);
OUT:
return (ret == -1) ? -get_errno() : ret;
}
#endif