From 9644678dcbc0cfb52d1fdcc8817730edba11afc6 Mon Sep 17 00:00:00 2001 From: bernard Date: Fri, 22 Dec 2017 14:45:36 +0800 Subject: [PATCH] [libc] include when enable HAVE_SYS_SELECT_H --- include/libc/libc_fdset.h | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h index 386c040206..057cc7fed2 100644 --- a/include/libc/libc_fdset.h +++ b/include/libc/libc_fdset.h @@ -29,6 +29,10 @@ #if defined(RT_USING_NEWLIB) || defined(_WIN32) #include +#if defined(HAVE_SYS_SELECT_H) +#include +#endif + #else #ifdef RT_USING_DFS_NET @@ -40,32 +44,31 @@ #define FD_SETSIZE DFS_FD_MAX #endif -# ifndef FD_SETSIZE -# define FD_SETSIZE 32 +# ifndef FD_SETSIZE +# define FD_SETSIZE 32 # endif -# define NBBY 8 /* number of bits in a byte */ +# define NBBY 8 /* number of bits in a byte */ -typedef long fd_mask; -# define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ -# ifndef howmany -# define howmany(x,y) (((x)+((y)-1))/(y)) +typedef long fd_mask; +# define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ +# ifndef howmany +# define howmany(x,y) (((x)+((y)-1))/(y)) # endif /* We use a macro for fd_set so that including Sockets.h afterwards can work. */ -typedef struct _types_fd_set { - fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; +typedef struct _types_fd_set { + fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; } _types_fd_set; #define fd_set _types_fd_set -# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) -# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) -# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) +# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) +# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) +# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) # define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p))) #endif #endif -