+Sat Jan 29 07:44:59 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
+
+ * ser-unix.c (wait_for, hardwire_readchar) [HAVE_TERMIO, HAVE_TERMIOS]:
+ If the timeout is too big to fit in c_cc[VTIME], then do multiple reads
+ to achieve the desired timeout.
+ * serial.h (serial_t): Add field timeout_remaining.
+
Fri Jan 28 08:45:02 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
* c-exp.y (yylex): Reenable nested type code.
addition to the standard serial support.
Fri Jan 28 08:45:02 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
->>>>>>> 1.2186
* mdebugread.c (psymtab_to_symtab_1): Don't complain on stLabel with
index indexNil.
serial_t scb;
int timeout;
{
+ scb->timeout_remaining = 0;
+
#ifdef HAVE_SGTTY
- struct timeval tv;
- fd_set readfds;
+ {
+ struct timeval tv;
+ fd_set readfds;
- FD_ZERO (&readfds);
+ FD_ZERO (&readfds);
- tv.tv_sec = timeout;
- tv.tv_usec = 0;
+ tv.tv_sec = timeout;
+ tv.tv_usec = 0;
- FD_SET(scb->fd, &readfds);
+ FD_SET(scb->fd, &readfds);
- while (1)
- {
- int numfds;
-
- if (timeout >= 0)
- numfds = select(scb->fd+1, &readfds, 0, 0, &tv);
- else
- numfds = select(scb->fd+1, &readfds, 0, 0, 0);
-
- if (numfds <= 0)
- if (numfds == 0)
- return SERIAL_TIMEOUT;
- else if (errno == EINTR)
- continue;
+ while (1)
+ {
+ int numfds;
+
+ if (timeout >= 0)
+ numfds = select(scb->fd+1, &readfds, 0, 0, &tv);
else
- return SERIAL_ERROR; /* Got an error from select or poll */
+ numfds = select(scb->fd+1, &readfds, 0, 0, 0);
- return 0;
- }
+ if (numfds <= 0)
+ if (numfds == 0)
+ return SERIAL_TIMEOUT;
+ else if (errno == EINTR)
+ continue;
+ else
+ return SERIAL_ERROR; /* Got an error from select or poll */
+ return 0;
+ }
+ }
#endif /* HAVE_SGTTY */
#if defined HAVE_TERMIO || defined HAVE_TERMIOS
if (timeout == scb->current_timeout)
return 0;
+ scb->current_timeout = timeout;
+
{
struct hardwire_ttystate state;
state.termios.c_cc[VTIME] = timeout * 10;
if (state.termios.c_cc[VTIME] != timeout * 10)
{
- warning ("Timeout value %d too large, using %d", timeout,
- state.termios.c_cc[VTIME] / 10);
+
+ /* If c_cc is an 8-bit signed character, we can't go
+ bigger than this. If it is always unsigned, we could use
+ 25. */
+
+ scb->current_timeout = 12;
+ state.termios.c_cc[VTIME] = scb->current_timeout * 10;
+ scb->timeout_remaining = timeout - scb->current_timeout;
}
}
#endif
state.termio.c_cc[VTIME] = timeout * 10;
if (state.termio.c_cc[VTIME] != timeout * 10)
{
- warning ("Timeout value %d too large, using %d", timeout,
- state.termio.c_cc[VTIME] / 10);
+ /* If c_cc is an 8-bit signed character, we can't go
+ bigger than this. If it is always unsigned, we could use
+ 25. */
+
+ scb->current_timeout = 12;
+ state.termios.c_cc[VTIME] = scb->current_timeout * 10;
+ scb->timeout_remaining = timeout - scb->current_timeout;
}
}
#endif
- scb->current_timeout = timeout;
-
if (set_tty_state (scb, &state))
fprintf_unfiltered(gdb_stderr, "set_tty_state failed: %s\n", safe_strerror(errno));
if (scb->bufcnt-- > 0)
return *scb->bufp++;
- status = wait_for(scb, timeout);
-
- if (status < 0)
- return status;
-
- scb->bufcnt = read(scb->fd, scb->buf, BUFSIZ);
-
- if (scb->bufcnt <= 0)
- if (scb->bufcnt == 0)
- return SERIAL_TIMEOUT; /* 0 chars means timeout [may need to
- distinguish between EOF & timeouts
- someday] */
- else
- return SERIAL_ERROR; /* Got an error from read */
-
- scb->bufcnt--;
- scb->bufp = scb->buf;
- return *scb->bufp++;
+ while (1)
+ {
+ status = wait_for (scb, timeout);
+
+ if (status < 0)
+ return status;
+
+ scb->bufcnt = read (scb->fd, scb->buf, BUFSIZ);
+
+ if (scb->bufcnt <= 0)
+ {
+ if (scb->bufcnt == 0)
+ {
+ /* Zero characters means timeout (it could also be EOF, but
+ we don't (yet at least) distinguish). */
+ if (scb->timeout_remaining > 0)
+ {
+ timeout = scb->timeout_remaining;
+ continue;
+ }
+ else
+ return SERIAL_TIMEOUT;
+ }
+ else
+ return SERIAL_ERROR; /* Got an error from read */
+ }
+
+ scb->bufcnt--;
+ scb->bufp = scb->buf;
+ return *scb->bufp++;
+ }
}
#ifndef B19200