From fd209cb880f6d2d39b6265c09727182b55446bdf Mon Sep 17 00:00:00 2001 From: heyuanjie Date: Sun, 12 Aug 2018 20:26:16 +0800 Subject: [PATCH] =?UTF-8?q?[lwp]=E6=B7=BB=E5=8A=A0select=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/src/select.c | 19 ++++++++++++++++--- components/lwp/lwp_syscall.c | 6 +++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/components/dfs/src/select.c b/components/dfs/src/select.c index c727763991..8b4e417f28 100644 --- a/components/dfs/src/select.c +++ b/components/dfs/src/select.c @@ -28,6 +28,19 @@ #include #include +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 */ diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 1b5aa411aa..0150e50b62 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -27,6 +27,8 @@ #include #include +#include + #if (defined(RT_USING_SAL) && defined(SAL_USING_POSIX)) #include @@ -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)