aboutsummaryrefslogtreecommitdiff
path: root/sim/avr
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2022-10-26 21:53:30 +0545
committerMike Frysinger <vapier@gentoo.org>2022-10-31 21:24:39 +0545
commit5b94c3808140206d3b5204a3780f294d590cc458 (patch)
tree4b5bea9bdc30a6ab503bd3d1c289b5e6f20af836 /sim/avr
parentf2462532e24ebfc137598d73ee6541948121f040 (diff)
downloadgdb-5b94c3808140206d3b5204a3780f294d590cc458.zip
gdb-5b94c3808140206d3b5204a3780f294d590cc458.tar.gz
gdb-5b94c3808140206d3b5204a3780f294d590cc458.tar.bz2
sim: common: change sim_read & sim_write to use void* buffers
When reading/writing arbitrary data to the system's memory, the unsigned char pointer type doesn't make that much sense. Switch it to void so we align a bit with standard C library read/write functions, and to avoid having to sprinkle casts everywhere.
Diffstat (limited to 'sim/avr')
-rw-r--r--sim/avr/interp.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sim/avr/interp.c b/sim/avr/interp.c
index 8efdffa..1b147c4 100644
--- a/sim/avr/interp.c
+++ b/sim/avr/interp.c
@@ -1526,25 +1526,26 @@ sim_engine_run (SIM_DESC sd,
}
int
-sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size)
+sim_write (SIM_DESC sd, SIM_ADDR addr, const void *buffer, int size)
{
int osize = size;
if (addr >= 0 && addr < SRAM_VADDR)
{
+ const unsigned char *data = buffer;
while (size > 0 && addr < (MAX_AVR_FLASH << 1))
{
word val = flash[addr >> 1].op;
if (addr & 1)
- val = (val & 0xff) | (buffer[0] << 8);
+ val = (val & 0xff) | (data[0] << 8);
else
- val = (val & 0xff00) | buffer[0];
+ val = (val & 0xff00) | data[0];
flash[addr >> 1].op = val;
flash[addr >> 1].code = OP_unknown;
addr++;
- buffer++;
+ data++;
size--;
}
return osize - size;
@@ -1562,12 +1563,13 @@ sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size)
}
int
-sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
+sim_read (SIM_DESC sd, SIM_ADDR addr, void *buffer, int size)
{
int osize = size;
if (addr >= 0 && addr < SRAM_VADDR)
{
+ unsigned char *data = buffer;
while (size > 0 && addr < (MAX_AVR_FLASH << 1))
{
word val = flash[addr >> 1].op;
@@ -1575,7 +1577,7 @@ sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
if (addr & 1)
val >>= 8;
- *buffer++ = val;
+ *data++ = val;
addr++;
size--;
}