ReactOS 0.4.15-dev-8028-g8e799e2
SSelect.c
Go to the documentation of this file.
1#include "syshdrs.h"
2
3void
4SelectSetInit(SelectSetPtr const ssp, const double timeout)
5{
6 double i;
7 long l;
8
9 /* Inititalize SelectSet, which will clear the fd_set, the
10 * timeval, and the maxfd and numfds to 0.
11 */
12 memset(ssp, 0, sizeof(SelectSet));
13 l = (long) timeout;
14 i = (double) l;
15 ssp->timeout.tv_sec = l;
16 ssp->timeout.tv_usec = (long) ((timeout - i) * 1000000.0);
17} /* SelectSetInit */
18
19
20
21
22void
23SelectSetAdd(SelectSetPtr const ssp, const int fd)
24{
25 if (fd >= 0) {
26 FD_SET(fd, &ssp->fds);
27 if (ssp->maxfd < (fd + 1))
28 ssp->maxfd = (fd + 1);
29 ++ssp->numfds;
30 }
31} /* SelectSetAdd */
32
33
34
35
36void
37SelectSetRemove(SelectSetPtr const ssp, const int fd)
38{
39 if ((fd >= 0) && (FD_ISSET(fd, &ssp->fds))) {
40 FD_CLR(fd, &ssp->fds);
41 /* Note that maxfd is left alone, even if maxfd was
42 * this one. That is okay.
43 */
44 --ssp->numfds;
45 }
46} /* SelectSetRemove */
47
48
49
50int
52{
53 int rc;
54
55 do {
56 memcpy(resultssp, ssp, sizeof(SelectSet));
57 rc = select(resultssp->maxfd, NULL, SELECT_TYPE_ARG234 &resultssp->fds, NULL, SELECT_TYPE_ARG5 &resultssp->timeout);
58 } while ((rc < 0) && (errno == EINTR));
59 return (rc);
60} /* SelectW */
61
62
63
64int
66{
67 int rc;
68
69 do {
70 memcpy(resultssp, ssp, sizeof(SelectSet));
71 rc = select(resultssp->maxfd, SELECT_TYPE_ARG234 &resultssp->fds, NULL, NULL, SELECT_TYPE_ARG5 &resultssp->timeout);
72 } while ((rc < 0) && (errno == EINTR));
73 return (rc);
74} /* SelectR */
void SelectSetRemove(SelectSetPtr const ssp, const int fd)
Definition: SSelect.c:37
int SelectW(SelectSetPtr ssp, SelectSetPtr resultssp)
Definition: SSelect.c:51
void SelectSetAdd(SelectSetPtr const ssp, const int fd)
Definition: SSelect.c:23
int SelectR(SelectSetPtr ssp, SelectSetPtr resultssp)
Definition: SSelect.c:65
void SelectSetInit(SelectSetPtr const ssp, const double timeout)
Definition: SSelect.c:4
#define EINTR
Definition: acclib.h:80
r l[0]
Definition: byte_order.h:168
#define NULL
Definition: types.h:112
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SELECT_TYPE_ARG234
Definition: wincfg.h:4
#define SELECT_TYPE_ARG5
Definition: wincfg.h:7
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define long
Definition: qsort.c:33
#define errno
Definition: errno.h:18
static int fd
Definition: io.c:51
#define memset(x, y, z)
Definition: compat.h:39
Definition: sio.h:6
int numfds
Definition: sio.h:10
struct timeval timeout
Definition: sio.h:8
int maxfd
Definition: sio.h:9
fd_set fds
Definition: sio.h:7
Definition: dhcpd.h:245
#define FD_ISSET(fd, set)
Definition: winsock.h:100
#define FD_SET(fd, set)
Definition: winsock.h:89
#define FD_CLR(fd, set)
Definition: winsock.h:74