26 #include "readline/readline.h" 36 char full_name[PATH_MAX];
38 if (GetModuleFileName (NULL, full_name, PATH_MAX))
39 return xstrdup (full_name);
40 return xstrdup (argv0);
51 gdb_select (
int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
52 struct timeval *timeout)
54 static HANDLE never_handle;
55 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
61 struct serial *scbs[MAXIMUM_WAIT_OBJECTS];
73 HANDLE
read = NULL, except = NULL;
81 if ((!readfds || !FD_ISSET (
fd, readfds))
82 && (!exceptfds || !FD_ISSET (
fd, exceptfds)))
88 serial_wait_handle (scb, &
read, &except);
89 scbs[num_scbs++] = scb;
93 read = (HANDLE) _get_osfhandle (
fd);
97 never_handle = CreateEvent (0, FALSE, FALSE, 0);
99 except = never_handle;
102 if (readfds && FD_ISSET (
fd, readfds))
104 gdb_assert (num_handles < MAXIMUM_WAIT_OBJECTS);
105 handles[num_handles++] =
read;
108 if (exceptfds && FD_ISSET (
fd, exceptfds))
110 gdb_assert (num_handles < MAXIMUM_WAIT_OBJECTS);
111 handles[num_handles++] = except;
115 gdb_assert (num_handles <= MAXIMUM_WAIT_OBJECTS);
117 event = WaitForMultipleObjects (num_handles,
121 ? (timeout->tv_sec * 1000
122 + timeout->tv_usec / 1000)
128 && event < WAIT_ABANDONED_0 + num_handles));
130 for (indx = 0; indx < num_scbs; ++indx)
131 serial_done_wait_handle (scbs[indx]);
132 if (event == WAIT_FAILED)
134 if (event == WAIT_TIMEOUT)
138 h = handles[
event - WAIT_OBJECT_0];
139 for (
fd = 0, indx = 0;
fd < n; ++
fd)
143 if ((!readfds || !FD_ISSET (
fd, readfds))
144 && (!exceptfds || !FD_ISSET (
fd, exceptfds)))
147 if (readfds && FD_ISSET (
fd, readfds))
149 fd_h = handles[indx++];
152 if (fd_h != h && WaitForSingleObject (fd_h, 0) != WAIT_OBJECT_0)
153 FD_CLR (
fd, readfds);
158 if (exceptfds && FD_ISSET (
fd, exceptfds))
160 fd_h = handles[indx++];
163 if (fd_h != h && WaitForSingleObject (fd_h, 0) != WAIT_OBJECT_0)
164 FD_CLR (
fd, exceptfds);
175 while (RL_ISSTATE (RL_STATE_SIGHANDLER))
ssize_t read(int fd, void *buf, size_t count)
int gdb_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
struct serial * serial_for_fd(int fd)
char * windows_get_absolute_argv0(const char *argv0)