#include "../../SDL_internal.h"
#include "SDL_assert.h"
#include "SDL_poll.h"
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
Go to the source code of this file.
◆ SDL_IOReady()
int SDL_IOReady |
( |
int |
fd, |
|
|
SDL_bool |
forWrite, |
|
|
int |
timeoutMS |
|
) |
| |
Definition at line 38 of file SDL_poll.c.
39{
41
42
43 do
44 {
45#ifdef HAVE_POLL
46 struct pollfd info;
47
49 if (forWrite) {
50 info.events = POLLOUT;
51 } else {
52 info.events = POLLIN | POLLPRI;
53 }
54 result = poll(&info, 1, timeoutMS);
55#else
56 fd_set rfdset, *rfdp =
NULL;
57 fd_set wfdset, *wfdp =
NULL;
58 struct timeval tv, *tvp =
NULL;
59
60
62
63 if (forWrite) {
64 FD_ZERO(&wfdset);
66 wfdp = &wfdset;
67 } else {
68 FD_ZERO(&rfdset);
70 rfdp = &rfdset;
71 }
72
73 if (timeoutMS >= 0) {
74 tv.tv_sec = timeoutMS / 1000;
75 tv.tv_usec = (timeoutMS % 1000) * 1000;
76 tvp = &tv;
77 }
78
80#endif
81
82 }
while (
result < 0 && errno == EINTR );
83
85}
#define SDL_assert(condition)
References NULL, and SDL_assert.