New sockets function: lwip_poll

Signed-off-by: goldsimon <goldsimon@gmx.de>
This commit is contained in:
Kalle Olavi Niemitalo
2017-09-21 21:50:36 +02:00
committed by goldsimon
parent 333f1bf2bd
commit 1152fd02c0
4 changed files with 371 additions and 15 deletions

View File

@@ -2016,6 +2016,14 @@
#if !defined LWIP_SOCKET_SELECT || defined __DOXYGEN__
#define LWIP_SOCKET_SELECT 1
#endif
/**
* LWIP_SOCKET_POLL==1 (default): enable poll() for sockets (including
* struct pollfd, nfds_t, and constants)
*/
#if !defined LWIP_SOCKET_POLL || defined __DOXYGEN__
#define LWIP_SOCKET_POLL 1
#endif
/**
* @}
*/

View File

@@ -155,6 +155,12 @@ struct lwip_select_cb {
fd_set *writeset;
/** unimplemented: exceptset passed to select */
fd_set *exceptset;
#if LWIP_SOCKET_POLL
/** fds passed to poll; NULL if select */
struct pollfd *poll_fds;
/** nfds passed to poll; 0 if select */
nfds_t poll_nfds;
#endif
/** don't signal the same semaphore twice: set to 1 when signalled */
int sem_signalled;
/** semaphore to wake up a task waiting for select */

View File

@@ -486,6 +486,23 @@ typedef struct fd_set
#error "external FD_SETSIZE too small for number of sockets"
#endif /* FD_SET */
/* poll-related defines and types */
/* @todo: find a better way to guard the definition of these defines and types if already defined */
#if !defined(POLLIN) && !defined(POLLOUT)
#define POLLIN 1
#define POLLOUT 2
#define POLLERR 4
#define POLLNVAL 8
/* No support for POLLPRI, POLLHUP, POLLMSG, POLLRDBAND, POLLWRBAND. */
typedef int nfds_t;
struct pollfd
{
int fd;
short events;
short revents;
};
#endif
/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
* by your system, set this to 0 and include <sys/time.h> in cc.h */
#ifndef LWIP_TIMEVAL_PRIVATE
@@ -525,6 +542,9 @@ void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destro
#if LWIP_SOCKET_SELECT
#define lwip_select select
#endif
#if LWIP_SOCKET_POLL
#define lwip_poll poll
#endif
#define lwip_ioctlsocket ioctl
#define lwip_inet_ntop inet_ntop
#define lwip_inet_pton inet_pton
@@ -569,6 +589,9 @@ ssize_t lwip_writev(int s, const struct iovec *iov, int iovcnt);
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
struct timeval *timeout);
#endif
#if LWIP_SOCKET_POLL
int lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout);
#endif
int lwip_ioctl(int s, long cmd, void *argp);
int lwip_fcntl(int s, int cmd, int val);
const char *lwip_inet_ntop(int af, const void *src, char *dst, socklen_t size);
@@ -614,6 +637,10 @@ int lwip_inet_pton(int af, const char *src, void *dst);
/** @ingroup socket */
#define select(maxfdp1,readset,writeset,exceptset,timeout) lwip_select(maxfdp1,readset,writeset,exceptset,timeout)
#endif
#if LWIP_SOCKET_POLL
/** @ingroup socket */
#define poll(fds,nfds,timeout) lwip_poll(fds,nfds,timeout)
#endif
/** @ingroup socket */
#define ioctlsocket(s,cmd,argp) lwip_ioctl(s,cmd,argp)
/** @ingroup socket */