windows: Provide a poll(2) wrapper calling WSAPoll()
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
# include <netdb.h>
|
# include <netdb.h>
|
||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
# include <sched.h>
|
# include <sched.h>
|
||||||
|
# include <poll.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* WSAPoll() */
|
||||||
|
#define _WIN32_WINNT 0x0600
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -639,3 +642,11 @@ ssize_t windows_sendto(int sockfd, const void *buf, size_t len, int flags,
|
|||||||
}
|
}
|
||||||
return outlen;
|
return outlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See header
|
||||||
|
*/
|
||||||
|
int poll(struct pollfd *fds, int nfds, int timeout)
|
||||||
|
{
|
||||||
|
return wserr(WSAPoll(fds, nfds, timeout));
|
||||||
|
}
|
||||||
|
|||||||
@@ -362,6 +362,34 @@ ssize_t windows_send(int sockfd, const void *buf, size_t len, int flags);
|
|||||||
ssize_t windows_sendto(int sockfd, const void *buf, size_t len, int flags,
|
ssize_t windows_sendto(int sockfd, const void *buf, size_t len, int flags,
|
||||||
const struct sockaddr *dest_addr, socklen_t addrlen);
|
const struct sockaddr *dest_addr, socklen_t addrlen);
|
||||||
|
|
||||||
|
#if _WIN32_WINNT < 0x0600
|
||||||
|
/**
|
||||||
|
* Define pollfd and flags on our own if not specified
|
||||||
|
*/
|
||||||
|
struct pollfd {
|
||||||
|
SOCKET fd;
|
||||||
|
short events;
|
||||||
|
short revents;
|
||||||
|
};
|
||||||
|
enum {
|
||||||
|
POLLERR = 0x0001,
|
||||||
|
POLLHUP = 0x0002,
|
||||||
|
POLLNVAL = 0x0004,
|
||||||
|
POLLWRNORM = 0x0010,
|
||||||
|
POLLWRBAND = 0x0020,
|
||||||
|
POLLPRI = 0x0400,
|
||||||
|
POLLRDNORM = 0x0100,
|
||||||
|
POLLRDBAND = 0x0200,
|
||||||
|
POLLIN = POLLRDNORM | POLLRDBAND,
|
||||||
|
POLLOUT = POLLWRNORM,
|
||||||
|
};
|
||||||
|
#endif /* _WIN32_WINNT < 0x0600 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* poll(2), implemented using Winsock2 WSAPoll()
|
||||||
|
*/
|
||||||
|
int poll(struct pollfd *fds, int nfds, int timeout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declaration missing on older WinGW
|
* Declaration missing on older WinGW
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user