* Re: [PATCH] sim: constify sim_write source buffer
@ 2010-04-13 23:25 Sandra Loosemore
2010-04-14 0:39 ` Mike Frysinger
0 siblings, 1 reply; 5+ messages in thread
From: Sandra Loosemore @ 2010-04-13 23:25 UTC (permalink / raw)
To: Mike Frysinger; +Cc: gdb-patches
FYI, this patch:
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* remote-sim.h (sim_write): Add const to buf arg.
caused the ARM simulator to fail to build. See sim/arm/wrapper.c:158:
int
sim_write (sd, addr, buffer, size)
SIM_DESC sd ATTRIBUTE_UNUSED;
SIM_ADDR addr;
unsigned char * buffer;
int size;
The obvious patch makes it build, at least.
-Sandra
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sim: constify sim_write source buffer
2010-04-13 23:25 [PATCH] sim: constify sim_write source buffer Sandra Loosemore
@ 2010-04-14 0:39 ` Mike Frysinger
2010-04-14 6:03 ` Hans-Peter Nilsson
0 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2010-04-14 0:39 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: gdb-patches
[-- Attachment #1: Type: Text/Plain, Size: 9953 bytes --]
On Tuesday 13 April 2010 19:26:10 Sandra Loosemore wrote:
> FYI, this patch:
>
> 2010-04-13 Mike Frysinger <vapier@gentoo.org>
>
> * remote-sim.h (sim_write): Add const to buf arg.
>
> caused the ARM simulator to fail to build. See sim/arm/wrapper.c:158:
hmm, i didnt realize so many sim ports arent using the common/ code. the
targets ive been testing all do. this patch should build fine for the targets
that otherwise work (seems like some have been marked for removal apparently,
and moxie requires some random "dtc" program).
-mike
arm/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (sim_write): Add const to buffer arg.
RCS file: /cvs/src/src/sim/arm/wrapper.c,v
retrieving revision 1.38
diff -u -p -r1.38 wrapper.c
--- sim/arm/wrapper.c 1 Jan 2010 10:03:26 -0000 1.38
+++ sim/arm/wrapper.c 14 Apr 2010 00:20:26 -0000
@@ -158,7 +158,7 @@ int
sim_write (sd, addr, buffer, size)
SIM_DESC sd ATTRIBUTE_UNUSED;
SIM_ADDR addr;
- unsigned char * buffer;
+ const unsigned char * buffer;
int size;
{
int i;
avr/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* interp.c (sim_write): Add const to buffer arg.
RCS file: /cvs/src/src/sim/avr/interp.c,v
retrieving revision 1.6
diff -u -p -r1.6 interp.c
--- sim/avr/interp.c 1 Jan 2010 10:03:26 -0000 1.6
+++ sim/avr/interp.c 14 Apr 2010 00:20:26 -0000
@@ -1622,7 +1622,7 @@ sim_trace (SIM_DESC sd)
}
int
-sim_write (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
+sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size)
{
int osize = size;
cr16/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* interp.c (sim_write): Add const to buffer arg.
RCS file: /cvs/src/src/sim/cr16/interp.c,v
retrieving revision 1.5
diff -u -p -r1.5 interp.c
--- sim/cr16/interp.c 1 Jan 2010 10:03:27 -0000 1.5
+++ sim/cr16/interp.c 14 Apr 2010 00:20:26 -0000
@@ -883,7 +883,7 @@ int
sim_write (sd, addr, buffer, size)
SIM_DESC sd;
SIM_ADDR addr;
- unsigned char *buffer;
+ const unsigned char *buffer;
int size;
{
/* FIXME: this should be performing a virtual transfer */
d10v/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* interp.c (sim_write): Add const to buffer arg.
RCS file: /cvs/src/src/sim/d10v/interp.c,v
retrieving revision 1.18
diff -u -p -r1.18 interp.c
--- sim/d10v/interp.c 18 Apr 2006 09:15:29 -0000 1.18
+++ sim/d10v/interp.c 14 Apr 2010 00:20:26 -0000
@@ -761,7 +761,7 @@ int
sim_write (sd, addr, buffer, size)
SIM_DESC sd;
SIM_ADDR addr;
- unsigned char *buffer;
+ const unsigned char *buffer;
int size;
{
/* FIXME: this should be performing a virtual transfer */
erc32/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* interp.c (sim_write): Add const to buf arg.
RCS file: /cvs/src/src/sim/erc32/interf.c,v
retrieving revision 1.6
diff -u -p -r1.6 interf.c
--- sim/erc32/interf.c 28 Nov 2005 18:33:03 -0000 1.6
+++ sim/erc32/interf.c 14 Apr 2010 00:20:26 -0000
@@ -351,7 +351,7 @@ int
sim_write(sd, mem, buf, length)
SIM_DESC sd;
SIM_ADDR mem;
- unsigned char *buf;
+ const unsigned char *buf;
int length;
{
return (sis_memory_write(mem, buf, length));
h8300/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* compile.c (sim_write): Add const to buffer arg.
RCS file: /cvs/src/src/sim/h8300/compile.c,v
retrieving revision 1.46
diff -u -p -r1.46 compile.c
--- sim/h8300/compile.c 9 Dec 2009 05:32:16 -0000 1.46
+++ sim/h8300/compile.c 14 Apr 2010 00:20:26 -0000
@@ -4616,7 +4616,7 @@ sim_trace (SIM_DESC sd)
}
int
-sim_write (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
+sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size)
{
int i;
m32c/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* gdb-if.c (sim_write): Add const to buf arg.
* mem.h (mem_put_blk): Add const to bufptr arg.
* mem.c (mem_put_blk): Likewise, and add const to cast.
RCS file: /cvs/src/src/sim/m32c/gdb-if.c,v
retrieving revision 1.9
diff -u -p -r1.9 gdb-if.c
--- sim/m32c/gdb-if.c 1 Jan 2010 10:03:31 -0000 1.9
+++ sim/m32c/gdb-if.c 14 Apr 2010 00:20:26 -0000
@@ -167,7 +167,7 @@ sim_read (SIM_DESC sd, SIM_ADDR mem, uns
}
int
-sim_write (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
+sim_write (SIM_DESC sd, SIM_ADDR mem, const unsigned char *buf, int length)
{
check_desc (sd);
RCS file: /cvs/src/src/sim/m32c/mem.c,v
retrieving revision 1.11
diff -u -p -r1.11 mem.c
--- sim/m32c/mem.c 1 Jan 2010 10:03:31 -0000 1.11
+++ sim/m32c/mem.c 14 Apr 2010 00:34:30 -0000
@@ -365,13 +365,13 @@ mem_put_si (int address, unsigned long v
}
void
-mem_put_blk (int address, void *bufptr, int nbytes)
+mem_put_blk (int address, const void *bufptr, int nbytes)
{
S ("<=");
if (enable_counting)
mem_counters[1][1] += nbytes;
while (nbytes--)
- mem_put_byte (address++, *(unsigned char *) bufptr++);
+ mem_put_byte (address++, *(const unsigned char *) bufptr++);
E ();
}
RCS file: /cvs/src/src/sim/m32c/mem.h,v
retrieving revision 1.8
diff -u -p -r1.8 mem.h
--- sim/m32c/mem.h 1 Jan 2010 10:03:31 -0000 1.8
+++ sim/m32c/mem.h 14 Apr 2010 00:34:30 -0000
@@ -27,7 +27,7 @@ void mem_put_hi (int address, unsigned s
void mem_put_psi (int address, unsigned long value);
void mem_put_si (int address, unsigned long value);
-void mem_put_blk (int address, void *bufptr, int nbytes);
+void mem_put_blk (int address, const void *bufptr, int nbytes);
unsigned char mem_get_pc ();
mcore/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* interp.c (sim_write): Add const to buffer arg.
RCS file: /cvs/src/src/sim/mcore/interp.c,v
retrieving revision 1.12
diff -u -p -r1.12 interp.c
--- sim/mcore/interp.c 1 Jan 2010 10:03:32 -0000 1.12
+++ sim/mcore/interp.c 14 Apr 2010 00:20:26 -0000
@@ -1718,7 +1718,7 @@ int
sim_write (sd, addr, buffer, size)
SIM_DESC sd;
SIM_ADDR addr;
- unsigned char * buffer;
+ const unsigned char * buffer;
int size;
{
int i;
microblaze/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* interp.c (sim_write): Add const to buffer arg.
RCS file: /cvs/src/src/sim/microblaze/interp.c,v
retrieving revision 1.3
diff -u -p -r1.3 interp.c
--- sim/microblaze/interp.c 1 Jan 2010 10:03:32 -0000 1.3
+++ sim/microblaze/interp.c 14 Apr 2010 00:20:26 -0000
@@ -704,7 +704,7 @@ sim_resume (SIM_DESC sd, int step, int s
int
-sim_write (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
+sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size)
{
int i;
init_pointers ();
mips/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* interp.c (sim_write): Add const to buffer arg.
RCS file: /cvs/src/src/sim/mips/interp.c,v
retrieving revision 1.25
diff -u -p -r1.25 interp.c
--- sim/mips/interp.c 18 Jan 2010 03:30:28 -0000 1.25
+++ sim/mips/interp.c 14 Apr 2010 00:20:26 -0000
@@ -862,7 +862,7 @@ int
sim_write (sd,addr,buffer,size)
SIM_DESC sd;
SIM_ADDR addr;
- unsigned char *buffer;
+ const unsigned char *buffer;
int size;
{
int index;
moxie/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* interp.c (sim_write): Add const to buffer arg.
RCS file: /cvs/src/src/sim/moxie/interp.c,v
retrieving revision 1.10
diff -u -p -r1.10 interp.c
--- sim/moxie/interp.c 27 Feb 2010 01:24:37 -0000 1.10
+++ sim/moxie/interp.c 14 Apr 2010 00:20:26 -0000
@@ -1028,7 +1028,7 @@ int
sim_write (sd, addr, buffer, size)
SIM_DESC sd;
SIM_ADDR addr;
- unsigned char * buffer;
+ const unsigned char * buffer;
int size;
{
sim_cpu *scpu = STATE_CPU (sd, 0); /* FIXME */
ppc/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* sim_calls.c (sim_write): Add const to buf arg.
RCS file: /cvs/src/src/sim/ppc/sim_calls.c,v
retrieving revision 1.12
diff -u -p -r1.12 sim_calls.c
--- sim/ppc/sim_calls.c 28 Nov 2005 18:33:03 -0000 1.12
+++ sim/ppc/sim_calls.c 14 Apr 2010 00:20:26 -0000
@@ -144,7 +144,7 @@ sim_read (SIM_DESC sd, SIM_ADDR mem, uns
int
-sim_write (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
+sim_write (SIM_DESC sd, SIM_ADDR mem, const unsigned char *buf, int length)
{
int result = psim_write_memory(simulator, MAX_NR_PROCESSORS,
buf, mem, length,
rx/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* gdb-if.c (sim_write): Add const to buf arg.
RCS file: /cvs/src/src/sim/rx/gdb-if.c,v
retrieving revision 1.2
diff -u -p -r1.2 gdb-if.c
--- sim/rx/gdb-if.c 1 Jan 2010 10:03:33 -0000 1.2
+++ sim/rx/gdb-if.c 14 Apr 2010 00:20:26 -0000
@@ -245,7 +245,7 @@ sim_read (SIM_DESC sd, SIM_ADDR mem, uns
}
int
-sim_write (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
+sim_write (SIM_DESC sd, SIM_ADDR mem, const unsigned char *buf, int length)
{
int i;
sh/
2010-04-13 Mike Frysinger <vapier@gentoo.org>
* interp.c (sim_write): Add const to buffer arg.
RCS file: /cvs/src/src/sim/sh/interp.c,v
retrieving revision 1.21
diff -u -p -r1.21 interp.c
--- sim/sh/interp.c 14 Feb 2010 07:15:57 -0000 1.21
+++ sim/sh/interp.c 14 Apr 2010 00:20:26 -0000
@@ -81,7 +81,7 @@
extern unsigned short sh_jump_table[], sh_dsp_table[0x1000], ppi_table[];
-int sim_write (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size);
+int sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size);
#define O_RECOMPILE 85
#define DEFINE_TABLE
@@ -2141,7 +2141,7 @@ int
sim_write (sd, addr, buffer, size)
SIM_DESC sd;
SIM_ADDR addr;
- unsigned char *buffer;
+ const unsigned char *buffer;
int size;
{
int i;
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sim: constify sim_write source buffer
2010-04-14 0:39 ` Mike Frysinger
@ 2010-04-14 6:03 ` Hans-Peter Nilsson
0 siblings, 0 replies; 5+ messages in thread
From: Hans-Peter Nilsson @ 2010-04-14 6:03 UTC (permalink / raw)
To: Mike Frysinger; +Cc: Sandra Loosemore, gdb-patches
On Tue, 13 Apr 2010, Mike Frysinger wrote:
> hmm, i didnt realize so many sim ports arent using the common/ code. the
> targets ive been testing all do. this patch should build fine for the targets
> that otherwise work (seems like some have been marked for removal apparently,
> and moxie requires some random "dtc" program).
Approved. Obvious, actually.
brgds, H-P
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sim: constify sim_write source buffer
2010-04-10 21:58 Mike Frysinger
@ 2010-04-13 15:35 ` Joel Brobecker
0 siblings, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2010-04-13 15:35 UTC (permalink / raw)
To: Mike Frysinger; +Cc: gdb-patches
> include/gdb/:
> 2010-04-10 Mike Frysinger <vapier@gentoo.org>
>
> * remote-sim.h (sim_write): Add const to buf arg.
>
> sim/common/:
> 2010-04-10 Mike Frysinger <vapier@gentoo.org>
>
> * sim-hrw.c (sim_write): Add const to buf arg.
> * sim-utils.h (sim_write_fn): Likewise.
This is OK.
If you feel courageous, I noticed that the .h files in the include/gdb
subdirectory are still using the PARAMS macro. We stopped using them
a very long time ago... A patch removing them is pre-approved.
--
Joel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] sim: constify sim_write source buffer
@ 2010-04-10 21:58 Mike Frysinger
2010-04-13 15:35 ` Joel Brobecker
0 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2010-04-10 21:58 UTC (permalink / raw)
To: gdb-patches
Most the sim write functions declare their source buffer const because
they only ever read from it. The global sim_write() function does not
follow this convention though which causes some warnings when trying to
pass it const strings or buffers.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
include/gdb/:
2010-04-10 Mike Frysinger <vapier@gentoo.org>
* remote-sim.h (sim_write): Add const to buf arg.
sim/common/:
2010-04-10 Mike Frysinger <vapier@gentoo.org>
* sim-hrw.c (sim_write): Add const to buf arg.
* sim-utils.h (sim_write_fn): Likewise.
include/gdb/remote-sim.h | 2 +-
sim/common/sim-hrw.c | 2 +-
sim/common/sim-utils.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/gdb/remote-sim.h b/include/gdb/remote-sim.h
index cfb1c11..37f029a 100644
--- a/include/gdb/remote-sim.h
+++ b/include/gdb/remote-sim.h
@@ -175,7 +175,7 @@ int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
memory. Store bytes starting at virtual address MEM. Result is
number of bytes write, or zero if error. */
-int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
+int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, const unsigned char *buf, int length));
/* Fetch register REGNO storing its raw (target endian) value in the
diff --git a/sim/common/sim-hrw.c b/sim/common/sim-hrw.c
index e76a196..cedae87 100644
--- a/sim/common/sim-hrw.c
+++ b/sim/common/sim-hrw.c
@@ -32,7 +32,7 @@ sim_read (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
}
int
-sim_write (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
+sim_write (SIM_DESC sd, SIM_ADDR mem, const unsigned char *buf, int length)
{
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
return sim_core_write_buffer (sd, NULL, write_map,
diff --git a/sim/common/sim-utils.h b/sim/common/sim-utils.h
index 75d2fb4..e3ff63a 100644
--- a/sim/common/sim-utils.h
+++ b/sim/common/sim-utils.h
@@ -63,7 +63,7 @@ SIM_RC sim_analyze_program (SIM_DESC sd, char *prog_name,
This is still accommodated for backward compatibility reasons. */
typedef int sim_write_fn PARAMS ((SIM_DESC sd, SIM_ADDR mem,
- unsigned char *buf, int length));
+ const unsigned char *buf, int length));
struct bfd *sim_load_file (SIM_DESC sd, const char *myname,
host_callback *callback, char *prog,
struct bfd *prog_bfd, int verbose_p,
--
1.7.0.2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-04-14 6:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-13 23:25 [PATCH] sim: constify sim_write source buffer Sandra Loosemore
2010-04-14 0:39 ` Mike Frysinger
2010-04-14 6:03 ` Hans-Peter Nilsson
-- strict thread matches above, loose matches on Subject: below --
2010-04-10 21:58 Mike Frysinger
2010-04-13 15:35 ` Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox