/* Generic serial interface functions.
- Copyright (C) 1992-1996, 1998-2001, 2003-2012 Free Software
- Foundation, Inc.
+ Copyright (C) 1992-2016 Free Software Foundation, Inc.
This file is part of GDB.
#include "event-loop.h"
#include "gdb_select.h"
-#include "gdb_string.h"
-#include "gdb_assert.h"
-#include <sys/time.h>
+#include "gdb_sys_time.h"
#ifdef USE_WIN32API
#include <winsock2.h>
#endif
static void
fd_event (int error, void *context)
{
- struct serial *scb = context;
+ struct serial *scb = (struct serial *) context;
if (error != 0)
{
scb->bufcnt = SERIAL_ERROR;
pull characters out of the buffer. See also
generic_readchar(). */
int nr;
- nr = scb->ops->read_prim (scb, BUFSIZ);
+
+ do
+ {
+ nr = scb->ops->read_prim (scb, BUFSIZ);
+ }
+ while (nr < 0 && errno == EINTR);
+
if (nr == 0)
{
scb->bufcnt = SERIAL_EOF;
static void
push_event (void *context)
{
- struct serial *scb = context;
+ struct serial *scb = (struct serial *) context;
scb->async_state = NOTHING_SCHEDULED; /* Timers are one-off */
run_async_handler_and_reschedule (scb);
int numfds;
struct timeval tv;
fd_set readfds, exceptfds;
+ int nfds;
/* NOTE: Some OS's can scramble the READFDS when the select()
call fails (ex the kernel with Red Hat 5.2). Initialize all
FD_SET (scb->fd, &readfds);
FD_SET (scb->fd, &exceptfds);
+ QUIT;
+
+ nfds = scb->fd + 1;
if (timeout >= 0)
- numfds = gdb_select (scb->fd + 1, &readfds, 0, &exceptfds, &tv);
+ numfds = interruptible_select (nfds, &readfds, 0, &exceptfds, &tv);
else
- numfds = gdb_select (scb->fd + 1, &readfds, 0, &exceptfds, 0);
+ numfds = interruptible_select (nfds, &readfds, 0, &exceptfds, 0);
if (numfds <= 0)
{
if (status < 0)
return status;
- status = scb->ops->read_prim (scb, BUFSIZ);
+ do
+ {
+ status = scb->ops->read_prim (scb, BUFSIZ);
+ }
+ while (status < 0 && errno == EINTR);
if (status <= 0)
{
}
int
-ser_base_write (struct serial *scb, const char *str, int len)
+ser_base_write (struct serial *scb, const void *buf, size_t count)
{
+ const char *str = (const char *) buf;
int cc;
- while (len > 0)
+ while (count > 0)
{
- cc = scb->ops->write_prim (scb, str, len);
+ QUIT;
+
+ cc = scb->ops->write_prim (scb, str, count);
if (cc < 0)
- return 1;
- len -= cc;
+ {
+ if (errno == EINTR)
+ continue;
+ return 1;
+ }
+ count -= cc;
str += cc;
}
return 0;
ser_base_get_tty_state (struct serial *scb)
{
/* Allocate a dummy. */
- return (serial_ttystate) XMALLOC (int);
+ return (serial_ttystate) XNEW (int);
}
serial_ttystate
ser_base_copy_tty_state (struct serial *scb, serial_ttystate ttystate)
{
/* Allocate another dummy. */
- return (serial_ttystate) XMALLOC (int);
+ return (serial_ttystate) XNEW (int);
}
int
return 0; /* Never fails! */
}
+/* Implement the "setparity" serial_ops callback. */
+
+int
+ser_base_setparity (struct serial *scb, int parity)
+{
+ return 0; /* Never fails! */
+}
+
/* Put the SERIAL device into/out-of ASYNC mode. */
void