Rather than having to bang out chunks of data one byte at a time over
the socket interface, add a write variant that accepts an arbitrarily
long buffer. This speeds things up considerably when we have many
chars to send out at once.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+2010-11-16 Mike Frysinger <vapier@gentoo.org>
+
+ * dv-sockser.c (dv_sockser_write_buffer): New function.
+ (dv_sockser_write): Rewrite to use dv_sockser_write_buffer.
+ * dv-sockser.h (dv_sockser_write_buffer): New prototype.
+
2010-10-07 Hans-Peter Nilsson <hp@axis.com>
* callback.c (os_lseek): Call wrap on lseek result.
}
int
-dv_sockser_write (SIM_DESC sd, unsigned char c)
+dv_sockser_write_buffer (SIM_DESC sd, const unsigned char *buffer,
+ unsigned nr_bytes)
{
int n;
if (! connected_p (sd))
return -1;
- n = write (sockser_fd, &c, 1);
+ n = write (sockser_fd, buffer, nr_bytes);
if (n == -1)
{
if (errno == EPIPE)
}
return -1;
}
- if (n != 1)
+ if (n != nr_bytes)
return -1;
- return 1;
+ return nr_bytes;
+}
+
+int
+dv_sockser_write (SIM_DESC sd, unsigned char c)
+{
+ return dv_sockser_write_buffer (sd, &c, 1);
}
int
/* FIXME: later add a device ptr arg */
extern int dv_sockser_status (SIM_DESC);
int dv_sockser_write (SIM_DESC, unsigned char);
+int dv_sockser_write_buffer (SIM_DESC, const unsigned char *, unsigned);
int dv_sockser_read (SIM_DESC);
#endif /* DV_SOCKSER_H */