early-access version 2281
This commit is contained in:
27
externals/SDL/src/core/unix/SDL_poll.c
vendored
27
externals/SDL/src/core/unix/SDL_poll.c
vendored
@@ -34,10 +34,12 @@
|
||||
|
||||
|
||||
int
|
||||
SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
||||
SDL_IOReady(int fd, int flags, int timeoutMS)
|
||||
{
|
||||
int result;
|
||||
|
||||
SDL_assert(flags & (SDL_IOR_READ | SDL_IOR_WRITE));
|
||||
|
||||
/* Note: We don't bother to account for elapsed time if we get EINTR */
|
||||
do
|
||||
{
|
||||
@@ -45,10 +47,12 @@ SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
||||
struct pollfd info;
|
||||
|
||||
info.fd = fd;
|
||||
if (forWrite) {
|
||||
info.events = POLLOUT;
|
||||
} else {
|
||||
info.events = POLLIN | POLLPRI;
|
||||
info.events = 0;
|
||||
if (flags & SDL_IOR_READ) {
|
||||
info.events |= POLLIN | POLLPRI;
|
||||
}
|
||||
if (flags & SDL_IOR_WRITE) {
|
||||
info.events |= POLLOUT;
|
||||
}
|
||||
result = poll(&info, 1, timeoutMS);
|
||||
#else
|
||||
@@ -59,15 +63,16 @@ SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
||||
/* If this assert triggers we'll corrupt memory here */
|
||||
SDL_assert(fd >= 0 && fd < FD_SETSIZE);
|
||||
|
||||
if (forWrite) {
|
||||
FD_ZERO(&wfdset);
|
||||
FD_SET(fd, &wfdset);
|
||||
wfdp = &wfdset;
|
||||
} else {
|
||||
if (flags & SDL_IOR_READ) {
|
||||
FD_ZERO(&rfdset);
|
||||
FD_SET(fd, &rfdset);
|
||||
rfdp = &rfdset;
|
||||
}
|
||||
if (flags & SDL_IOR_WRITE) {
|
||||
FD_ZERO(&wfdset);
|
||||
FD_SET(fd, &wfdset);
|
||||
wfdp = &wfdset;
|
||||
}
|
||||
|
||||
if (timeoutMS >= 0) {
|
||||
tv.tv_sec = timeoutMS / 1000;
|
||||
@@ -78,7 +83,7 @@ SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
|
||||
result = select(fd + 1, rfdp, wfdp, NULL, tvp);
|
||||
#endif /* HAVE_POLL */
|
||||
|
||||
} while ( result < 0 && errno == EINTR );
|
||||
} while ( result < 0 && errno == EINTR && !(flags & SDL_IOR_NO_RETRY));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
5
externals/SDL/src/core/unix/SDL_poll.h
vendored
5
externals/SDL/src/core/unix/SDL_poll.h
vendored
@@ -26,8 +26,11 @@
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#define SDL_IOR_READ 0x1
|
||||
#define SDL_IOR_WRITE 0x2
|
||||
#define SDL_IOR_NO_RETRY 0x4
|
||||
|
||||
extern int SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS);
|
||||
extern int SDL_IOReady(int fd, int flags, int timeoutMS);
|
||||
|
||||
#endif /* SDL_poll_h_ */
|
||||
|
||||
|
Reference in New Issue
Block a user