ReactOS  0.4.13-dev-464-g6b95727
SSelect.c
Go to the documentation of this file.
1 #include "syshdrs.h"
2 
3 void
4 SelectSetInit(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 
22 void
23 SelectSetAdd(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 
36 void
37 SelectSetRemove(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 
50 int
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 
64 int
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 */
#define SELECT_TYPE_ARG234
Definition: wincfg.h:4
int maxfd
Definition: sio.h:9
#define EINTR
Definition: acclib.h:80
static int fd
Definition: io.c:51
Definition: dhcpd.h:245
int errno
#define FD_SET(fd, set)
Definition: winsock.h:89
struct timeval timeout
Definition: sio.h:8
void SelectSetInit(SelectSetPtr const ssp, const double timeout)
Definition: SSelect.c:4
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
void SelectSetRemove(SelectSetPtr const ssp, const int fd)
Definition: SSelect.c:37
#define FD_ISSET(fd, set)
Definition: winsock.h:100
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
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
smooth NULL
Definition: ftsmooth.c:416
int numfds
Definition: sio.h:10
r l[0]
Definition: byte_order.h:167
#define SELECT_TYPE_ARG5
Definition: wincfg.h:7
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: sio.h:6
int SelectW(SelectSetPtr ssp, SelectSetPtr resultssp)
Definition: SSelect.c:51
#define long
Definition: qsort.c:33
int SelectR(SelectSetPtr ssp, SelectSetPtr resultssp)
Definition: SSelect.c:65
void SelectSetAdd(SelectSetPtr const ssp, const int fd)
Definition: SSelect.c:23
#define FD_CLR(fd, set)
Definition: winsock.h:74
#define memset(x, y, z)
Definition: compat.h:39
fd_set fds
Definition: sio.h:7