2009-06-30 23:18:44 +02:00
|
|
|
/* select.h
|
|
|
|
|
2013-01-21 05:38:31 +01:00
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
2013-04-23 11:44:36 +02:00
|
|
|
2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
|
2009-06-30 23:18:44 +02:00
|
|
|
|
|
|
|
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;
|
2012-12-22 20:35:41 +01:00
|
|
|
int (*startup) (select_record *, class select_stuff *);
|
2009-06-30 23:18:44 +02:00
|
|
|
int (*peek) (select_record *, bool);
|
2012-12-22 20:35:41 +01:00
|
|
|
int (*verify) (select_record *, fd_set *, fd_set *, fd_set *);
|
|
|
|
void (*cleanup) (select_record *, class select_stuff *);
|
2009-06-30 23:18:44 +02:00
|
|
|
struct select_record *next;
|
|
|
|
void set_select_errno () {__seterrno (); thread_errno = errno;}
|
|
|
|
int saw_error () {return thread_errno;}
|
2012-12-19 23:07:14 +01:00
|
|
|
select_record (int): next (NULL) {}
|
|
|
|
select_record (): fd (0), h (NULL), fh (NULL), thread_errno (0),
|
2009-06-30 23:18:44 +02:00
|
|
|
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) {}
|
2012-12-22 20:35:41 +01:00
|
|
|
#ifdef DEBUGGING
|
|
|
|
void dump_select_record ();
|
|
|
|
#endif
|
2009-06-30 23:18:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct select_info
|
|
|
|
{
|
|
|
|
cygthread *thread;
|
|
|
|
bool stop_thread;
|
|
|
|
select_record *start;
|
2012-12-22 20:35:41 +01:00
|
|
|
select_info (): thread (NULL), stop_thread (0), start (NULL) {}
|
2009-06-30 23:18:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct select_pipe_info: public select_info
|
|
|
|
{
|
2012-12-22 20:35:41 +01:00
|
|
|
select_pipe_info (): select_info () {}
|
2009-06-30 23:18:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct select_socket_info: public select_info
|
|
|
|
{
|
|
|
|
int num_w4;
|
|
|
|
LONG *ser_num;
|
|
|
|
HANDLE *w4;
|
2013-03-31 14:37:45 +02:00
|
|
|
select_socket_info (): select_info (), num_w4 (0), ser_num (0), w4 (NULL) {}
|
2009-06-30 23:18:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct select_serial_info: public select_info
|
|
|
|
{
|
2012-12-22 20:35:41 +01:00
|
|
|
select_serial_info (): select_info () {}
|
2009-06-30 23:18:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct select_mailslot_info: public select_info
|
|
|
|
{
|
2012-12-22 20:35:41 +01:00
|
|
|
select_mailslot_info (): select_info () {}
|
2009-06-30 23:18:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class select_stuff
|
|
|
|
{
|
|
|
|
public:
|
2012-06-03 04:59:20 +02:00
|
|
|
enum wait_states
|
|
|
|
{
|
|
|
|
select_signalled = -3,
|
|
|
|
select_loop = -2,
|
|
|
|
select_error = -1,
|
|
|
|
select_ok = 0,
|
|
|
|
select_set_zero = 1
|
|
|
|
};
|
|
|
|
|
2009-06-30 23:18:44 +02:00
|
|
|
~select_stuff ();
|
2012-01-22 07:45:08 +01:00
|
|
|
bool return_on_signal;
|
2009-06-30 23:18:44 +02:00
|
|
|
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;
|
|
|
|
|
2012-12-22 20:35:41 +01:00
|
|
|
bool test_and_set (int, fd_set *, fd_set *, fd_set *);
|
|
|
|
int poll (fd_set *, fd_set *, fd_set *);
|
|
|
|
wait_states wait (fd_set *, fd_set *, fd_set *, DWORD);
|
2009-06-30 23:18:44 +02:00
|
|
|
void cleanup ();
|
2011-05-03 17:58:52 +02:00
|
|
|
void destroy ();
|
2012-06-03 04:59:20 +02:00
|
|
|
|
2012-01-22 07:45:08 +01:00
|
|
|
select_stuff (): return_on_signal (false), always_ready (false),
|
|
|
|
windows_used (false), start (0),
|
2012-06-27 23:42:11 +02:00
|
|
|
device_specific_pipe (NULL),
|
|
|
|
device_specific_socket (NULL),
|
|
|
|
device_specific_serial (NULL),
|
|
|
|
device_specific_mailslot (NULL) {}
|
2009-06-30 23:18:44 +02:00
|
|
|
};
|
|
|
|
#endif /* _SELECT_H_ */
|