aboutsummaryrefslogtreecommitdiff
path: root/gdb/ser-unix.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>1999-04-26 18:34:20 +0000
committerStan Shebs <shebs@codesourcery.com>1999-04-26 18:34:20 +0000
commit7a292a7adf506b866905b06b3024c0fd411c4583 (patch)
tree5b208bb48269b8a82d5c3a5f19c87b45a62a22f4 /gdb/ser-unix.c
parent1996fae84682e8ddd146215dd2959ad1ec924c09 (diff)
downloadgdb-7a292a7adf506b866905b06b3024c0fd411c4583.zip
gdb-7a292a7adf506b866905b06b3024c0fd411c4583.tar.gz
gdb-7a292a7adf506b866905b06b3024c0fd411c4583.tar.bz2
import gdb-19990422 snapshot
Diffstat (limited to 'gdb/ser-unix.c')
-rw-r--r--gdb/ser-unix.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index f279c94..dc5236f 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -85,9 +85,7 @@ static int hardwire_setstopbits PARAMS ((serial_t, int));
void _initialize_ser_hardwire PARAMS ((void));
-#ifdef __CYGWIN32__
-extern void (*ui_loop_hook) PARAMS ((int));
-#endif
+extern int (*ui_loop_hook) PARAMS ((int));
/* Open up a real live device for serial I/O */
@@ -434,10 +432,6 @@ wait_for(scb, timeout)
serial_t scb;
int timeout;
{
-#ifndef __CYGWIN32__
- scb->timeout_remaining = 0;
-#endif
-
#ifdef HAVE_SGTTY
{
struct timeval tv;
@@ -550,32 +544,40 @@ hardwire_readchar (scb, timeout)
serial_t scb;
int timeout;
{
- int status;
-#ifdef __CYGWIN32__
- int t;
-#endif
+ int status, delta;
+ int detach = 0;
if (scb->bufcnt-- > 0)
return *scb->bufp++;
-#ifdef __CYGWIN32__
if (timeout > 0)
timeout++;
-#endif
+ /* We have to be able to keep the GUI alive here, so we break the original
+ timeout into steps of 1 second, running the "keep the GUI alive" hook
+ each time through the loop.
+ Also, timeout = 0 means to poll, so we just set the delta to 0, so we
+ will only go through the loop once. */
+
+ delta = (timeout == 0 ? 0 : 1);
while (1)
{
-#ifdef __CYGWIN32__
- t = timeout == 0 ? 0 : 1;
- scb->timeout_remaining = timeout < 0 ? timeout : timeout - t;
- status = wait_for (scb, t);
- /* -2 means disable timer */
+ /* N.B. The UI may destroy our world (for instance by calling
+ remote_stop,) in which case we want to get out of here as
+ quickly as possible. It is not safe to touch scb, since
+ someone else might have freed it. The ui_loop_hook signals that
+ we should exit by returning 1. */
+
if (ui_loop_hook)
- ui_loop_hook (-2);
-#else
- status = wait_for (scb, timeout);
-#endif
+ detach = ui_loop_hook (0);
+
+ if (detach)
+ return SERIAL_TIMEOUT;
+
+ scb->timeout_remaining = (timeout < 0 ? timeout : timeout - delta);
+ status = wait_for (scb, delta);
+
if (status < 0)
return status;
@@ -592,10 +594,8 @@ hardwire_readchar (scb, timeout)
timeout = scb->timeout_remaining;
continue;
}
-#ifdef __CYGWIN32__
else if (scb->timeout_remaining < 0)
continue;
-#endif
else
return SERIAL_TIMEOUT;
}