Welcome to mirror list, hosted at ThFree Co, Russian Federation.

select.h « cygwin « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f9df95d93c2a99460b700d0db7c05c2c6416d3de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* select.h

   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
   2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.

This file is part of Cygwin.

This software is a copyrighted work licensed under the terms of the
Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
details. */

#ifndef _SELECT_H_
#define _SELECT_H_

struct select_record
{
  int fd;
  HANDLE h;
  fhandler_base *fh;
  int thread_errno;
  bool windows_handle;
  bool read_ready, write_ready, except_ready;
  bool read_selected, write_selected, except_selected;
  bool except_on_write;
  int (*startup) (select_record *me, class select_stuff *stuff);
  int (*peek) (select_record *, bool);
  int (*verify) (select_record *me, fd_set *readfds, fd_set *writefds,
		 fd_set *exceptfds);
  void (*cleanup) (select_record *me, class select_stuff *stuff);
  struct select_record *next;
  void set_select_errno () {__seterrno (); thread_errno = errno;}
  int saw_error () {return thread_errno;}
  select_record (int): next (NULL) {}
  select_record (): fd (0), h (NULL), fh (NULL), thread_errno (0),
    windows_handle (false), read_ready (false), write_ready (false),
    except_ready (false), read_selected (false), write_selected (false),
    except_selected (false), except_on_write (false),
    startup (NULL), peek (NULL), verify (NULL), cleanup (NULL),
    next (NULL) {}
};

struct select_info
{
  cygthread *thread;
  bool stop_thread;
  select_record *start;
  select_info () {}
};

struct select_pipe_info: public select_info
{
};

struct select_socket_info: public select_info
{
  int num_w4;
  LONG *ser_num;
  HANDLE *w4;
};

struct select_serial_info: public select_info
{
};

struct select_mailslot_info: public select_info
{
};

class select_stuff
{
public:
  enum wait_states
  {
    select_signalled = -3,
    select_loop = -2,
    select_error = -1,
    select_ok = 0,
    select_set_zero = 1
  };

  ~select_stuff ();
  bool return_on_signal;
  bool always_ready, windows_used;
  select_record start;

  select_pipe_info *device_specific_pipe;
  select_socket_info *device_specific_socket;
  select_serial_info *device_specific_serial;
  select_mailslot_info *device_specific_mailslot;

  bool test_and_set (int i, fd_set *readfds, fd_set *writefds,
		     fd_set *exceptfds);
  int poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds);
  wait_states wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms);
  void cleanup ();
  void destroy ();

  select_stuff (): return_on_signal (false), always_ready (false),
  		   windows_used (false), start (0),
		   device_specific_pipe (NULL),
		   device_specific_socket (NULL),
		   device_specific_serial (NULL),
		   device_specific_mailslot (NULL) {}
};
#endif /* _SELECT_H_ */