+2013-04-19 Pedro Alves <palves@redhat.com>
+
+ * ser-base.c (ser_base_write): Change prototype -- take 'void *'
+ buffer and size_t size. Adjust.
+ * ser-base.h (ser_base_write): Adjust.
+ * ser-go32.c (cnts): Change type to size_t.
+ (dos_write): Change prototype -- take 'void *'
+ buffer and size_t size. Adjust.
+ (dos_info): Print elements of 'cnts' as unsigned long.
+ * serial.c (serial_write): Likewise.
+ * serial.h (serial_write): Adjust.
+ (struct serial_ops) <write>: Change prototype -- take 'void *'
+ buffer and size_t size. Adjust.
+
2013-04-19 Pedro Alves <palves@redhat.com>
* c-lang.c (evaluate_subexp_c): Cast result of obstack_base to
}
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 = buf;
int cc;
- while (len > 0)
+ while (count > 0)
{
- cc = scb->ops->write_prim (scb, str, len);
+ cc = scb->ops->write_prim (scb, str, count);
if (cc < 0)
return 1;
- len -= cc;
+ count -= cc;
str += cc;
}
return 0;
extern int ser_base_setstopbits (struct serial *scb, int rate);
extern int ser_base_drain_output (struct serial *scb);
-extern int ser_base_write (struct serial *scb, const char *str, int len);
+extern int ser_base_write (struct serial *scb, const void *buf, size_t count);
extern void ser_base_async (struct serial *scb, int async_p);
extern int ser_base_readchar (struct serial *scb, int timeout);
#define NCNT 20
static int intrcnt;
-static int cnts[NCNT];
+static size_t cnts[NCNT];
static char *cntnames[NCNT] =
{
/* h/w interrupt counts. */
static void dos_raw (struct serial *scb);
static int dos_readchar (struct serial *scb, int timeout);
static int dos_setbaudrate (struct serial *scb, int rate);
-static int dos_write (struct serial *scb, const char *str, int len);
+static int dos_write (struct serial *scb, const void *buf, size_t count);
static void dos_close (struct serial *scb);
static serial_ttystate dos_get_tty_state (struct serial *scb);
static int dos_set_tty_state (struct serial *scb, serial_ttystate state);
}
static int
-dos_write (struct serial *scb, const char *str, int len)
+dos_write (struct serial *scb, const void *buf, size_t count)
{
volatile struct dos_ttystate *port = &ports[scb->fd];
- int fifosize = port->fifo ? 16 : 1;
+ size_t fifosize = port->fifo ? 16 : 1;
long then;
- int cnt;
+ size_t cnt;
+ const char *str = buf;
- while (len > 0)
+ while (count > 0)
{
/* Send the data, fifosize bytes at a time. */
- cnt = fifosize > len ? len : fifosize;
+ cnt = fifosize > count ? count : fifosize;
port->txbusy = 1;
/* Francisco Pastor <fpastor.etra-id@etra.es> says OUTSB messes
up the communications with UARTs with FIFOs. */
#ifdef UART_FIFO_WORKS
outportsb (port->base + com_data, str, cnt);
str += cnt;
- len -= cnt;
+ count -= cnt;
#else
- for ( ; cnt > 0; cnt--, len--)
+ for ( ; cnt > 0; cnt--, count--)
outportb (port->base + com_data, *str++);
#endif
#ifdef DOS_STATS
printf_filtered ("\nTotal interrupts: %d\n", intrcnt);
for (i = 0; i < NCNT; i++)
if (cnts[i])
- printf_filtered ("%s:\t%d\n", cntnames[i], cnts[i]);
+ printf_filtered ("%s:\t%lu\n", cntnames[i], (unsigned long) cnts[i]);
#endif
}
}
int
-serial_write (struct serial *scb, const char *str, int len)
+serial_write (struct serial *scb, const void *buf, size_t count)
{
if (serial_logfp != NULL)
{
- int count;
+ const char *str = buf;
+ size_t c;
- for (count = 0; count < len; count++)
- serial_logchar (serial_logfp, 'w', str[count] & 0xff, 0);
+ for (c = 0; c < count; c++)
+ serial_logchar (serial_logfp, 'w', str[c] & 0xff, 0);
/* Make sure that the log file is as up-to-date as possible,
in case we are getting ready to dump core or something. */
}
if (serial_debug_p (scb))
{
- int count;
+ const char *str = buf;
+ size_t c;
- for (count = 0; count < len; count++)
+ for (c = 0; c < count; c++)
{
fprintf_unfiltered (gdb_stdlog, "[");
serial_logchar (gdb_stdlog, 'w', str[count] & 0xff, 0);
gdb_flush (gdb_stdlog);
}
- return (scb->ops->write (scb, str, len));
+ return (scb->ops->write (scb, buf, count));
}
void
extern int serial_readchar (struct serial *scb, int timeout);
-/* Write LEN chars from STRING to the port SCB. Returns 0 for
+/* Write COUNT bytes from BUF to the port SCB. Returns 0 for
success, non-zero for failure. */
-extern int serial_write (struct serial *scb, const char *str, int len);
+extern int serial_write (struct serial *scb, const void *buf, size_t count);
/* Write a printf style string onto the serial port. */
void (*close) (struct serial *);
int (*fdopen) (struct serial *, int fd);
int (*readchar) (struct serial *, int timeout);
- int (*write) (struct serial *, const char *str, int len);
+ int (*write) (struct serial *, const void *buf, size_t count);
/* Discard pending output */
int (*flush_output) (struct serial *);
/* Discard pending input */