[lwp]添加select系统调用
This commit is contained in:
parent
68edd04cbb
commit
fd209cb880
|
@ -28,6 +28,19 @@
|
|||
#include <dfs_poll.h>
|
||||
#include <dfs_select.h>
|
||||
|
||||
static void fdzero(fd_set *set, int nfds)
|
||||
{
|
||||
fd_mask *m;
|
||||
int n;
|
||||
|
||||
m = (fd_mask*)set;
|
||||
for (n = 0; n < nfds; n += sizeof(fd_mask))
|
||||
{
|
||||
rt_memset(m, 0, sizeof(fd_mask));
|
||||
m ++;
|
||||
}
|
||||
}
|
||||
|
||||
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
|
||||
{
|
||||
int fd;
|
||||
|
@ -113,17 +126,17 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struc
|
|||
/* Now set up the return values */
|
||||
if (readfds)
|
||||
{
|
||||
memset(readfds, 0, sizeof(fd_set));
|
||||
fdzero(readfds, nfds);
|
||||
}
|
||||
|
||||
if (writefds)
|
||||
{
|
||||
memset(writefds, 0, sizeof(fd_set));
|
||||
fdzero(writefds, nfds);
|
||||
}
|
||||
|
||||
if (exceptfds)
|
||||
{
|
||||
memset(exceptfds, 0, sizeof(fd_set));
|
||||
fdzero(exceptfds, nfds);
|
||||
}
|
||||
|
||||
/* Convert the poll descriptor list back into selects 3 bitsets */
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include <lwp_syscall.h>
|
||||
|
||||
#include <dfs_poll.h>
|
||||
#include <dfs_select.h>
|
||||
|
||||
#if (defined(RT_USING_SAL) && defined(SAL_USING_POSIX))
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
@ -235,7 +237,7 @@ const static void* func_table[] =
|
|||
|
||||
(void *)sys_gettimeofday, // 0x0b
|
||||
(void *)sys_settimeofday, // 0x0c
|
||||
|
||||
|
||||
(void *)sys_malloc, // 0x0d
|
||||
(void *)sys_free, // 0x0e
|
||||
(void *)sys_realloc, //0x0f
|
||||
|
@ -256,6 +258,8 @@ const static void* func_table[] =
|
|||
SYSCALL_NET(send), // 0x1d
|
||||
SYSCALL_NET(sendto), // 0x1e
|
||||
SYSCALL_NET(socket), // 0x1f
|
||||
|
||||
select, // 0x20
|
||||
};
|
||||
|
||||
const void *lwp_get_sys_api(rt_uint32_t number)
|
||||
|
|
Loading…
Reference in New Issue