[libc] include <sys/select.h> when enable HAVE_SYS_SELECT_H

This commit is contained in:
bernard 2017-12-22 14:45:36 +08:00 committed by Bernard Xiong
parent 5326bd55a5
commit 9644678dcb
1 changed files with 16 additions and 13 deletions

View File

@ -29,6 +29,10 @@
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
#include <sys/types.h>
#if defined(HAVE_SYS_SELECT_H)
#include <sys/select.h>
#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