26 #include "readline/readline.h"
44 char full_name[PATH_MAX];
46 if (GetModuleFileName (NULL, full_name, PATH_MAX))
47 return xstrdup (full_name);
48 return xstrdup (argv0);
59 gdb_select (
int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
62 static HANDLE never_handle;
63 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
69 struct serial *scbs[MAXIMUM_WAIT_OBJECTS];
79 for (fd = 0; fd < n; ++
fd)
81 HANDLE
read = NULL, except = NULL;
87 gdb_assert (!writefds || !FD_ISSET (fd, writefds));
89 if ((!readfds || !FD_ISSET (fd, readfds))
90 && (!exceptfds || !FD_ISSET (fd, exceptfds)))
96 serial_wait_handle (scb, &read, &except);
97 scbs[num_scbs++] = scb;
101 read = (HANDLE) _get_osfhandle (fd);
105 never_handle = CreateEvent (0, FALSE, FALSE, 0);
107 except = never_handle;
110 if (readfds && FD_ISSET (fd, readfds))
112 gdb_assert (num_handles < MAXIMUM_WAIT_OBJECTS);
113 handles[num_handles++] =
read;
116 if (exceptfds && FD_ISSET (fd, exceptfds))
118 gdb_assert (num_handles < MAXIMUM_WAIT_OBJECTS);
119 handles[num_handles++] = except;
123 gdb_assert (num_handles < MAXIMUM_WAIT_OBJECTS);
126 event = WaitForMultipleObjects (num_handles,
130 ? (timeout->tv_sec * 1000
131 + timeout->tv_usec / 1000)
137 && event < WAIT_ABANDONED_0 + num_handles));
139 for (indx = 0; indx < num_scbs; ++indx)
140 serial_done_wait_handle (scbs[indx]);
141 if (event == WAIT_FAILED)
143 if (event == WAIT_TIMEOUT)
147 h = handles[
event - WAIT_OBJECT_0];
148 for (fd = 0, indx = 0; fd < n; ++
fd)
152 if ((!readfds || !FD_ISSET (fd, readfds))
153 && (!exceptfds || !FD_ISSET (fd, exceptfds)))
156 if (readfds && FD_ISSET (fd, readfds))
158 fd_h = handles[indx++];
161 if (fd_h != h && WaitForSingleObject (fd_h, 0) != WAIT_OBJECT_0)
162 FD_CLR (fd, readfds);
167 if (exceptfds && FD_ISSET (fd, exceptfds))
169 fd_h = handles[indx++];
172 if (fd_h != h && WaitForSingleObject (fd_h, 0) != WAIT_OBJECT_0)
173 FD_CLR (fd, exceptfds);
184 while (RL_ISSTATE (RL_STATE_SIGHANDLER))
188 || WaitForSingleObject (
sigint_event, 0) == WAIT_OBJECT_0)
190 if (sigint_handler != NULL)
213 sigint_handler = handler;
217 sigint_handler = NULL;
ssize_t read(int fd, void *buf, size_t count)
initialize_file_ftype _initialize_mingw_hdep
int gdb_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
struct serial * serial_for_fd(int fd)
void mark_async_signal_handler(async_signal_handler *async_handler_ptr)
void call_async_signal_handler(struct async_signal_handler *handler)
void initialize_file_ftype(void)
void gdb_call_async_signal_handler(struct async_signal_handler *handler, int immediate_p)
struct async_signal_handler * sigint_handler
char * windows_get_absolute_argv0(const char *argv0)
static HANDLE sigint_event