* [RFC] sim/sh: Fix compile warnings for 64-bit build hosts
@ 2012-02-16 4:46 Kevin Buettner
2012-02-16 4:54 ` Mike Frysinger
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Buettner @ 2012-02-16 4:46 UTC (permalink / raw)
To: gdb-patches
Any comments on the following patch?
It fixes a bunch of warnings when building on a 64-bit host. Here
are a few of them:
./code.c:93: warning: cast from pointer to integer of different size
./code.c:215: warning: cast from pointer to integer of different size
./code.c:230: warning: cast from pointer to integer of different size
Kevin
* sh/interp.c (MA): Adjust cast to avoid warning on 64-bit hosts.
Index: interp.c
===================================================================
RCS file: /cvs/src/src/sim/sh/interp.c,v
retrieving revision 1.23
diff -u -p -r1.23 interp.c
--- interp.c 16 Apr 2011 18:16:36 -0000 1.23
+++ interp.c 16 Feb 2012 00:16:15 -0000
@@ -862,7 +862,7 @@ do { \
#else
#define MA(n) \
- do { memstalls += ((((int) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0)
+ do { memstalls += ((((long) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0)
#define L(x) thislock = x;
#define TL(x) if ((x) == prevlock) stalls++;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] sim/sh: Fix compile warnings for 64-bit build hosts
2012-02-16 4:46 [RFC] sim/sh: Fix compile warnings for 64-bit build hosts Kevin Buettner
@ 2012-02-16 4:54 ` Mike Frysinger
2012-02-16 23:36 ` Kevin Buettner
0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2012-02-16 4:54 UTC (permalink / raw)
To: gdb-patches; +Cc: Kevin Buettner
[-- Attachment #1: Type: Text/Plain, Size: 594 bytes --]
On Wednesday 15 February 2012 19:26:22 Kevin Buettner wrote:
> Any comments on the following patch?
uintptr_t i think would be better, but we don't seem to use that in sim/, so
this is OK
> It fixes a bunch of warnings when building on a 64-bit host. Here
> are a few of them:
>
> ./code.c:93: warning: cast from pointer to integer of different size
> ./code.c:215: warning: cast from pointer to integer of different size
> ./code.c:230: warning: cast from pointer to integer of different size
makes me think that this sim is incorrectly mixing target and host types
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] sim/sh: Fix compile warnings for 64-bit build hosts
2012-02-16 4:54 ` Mike Frysinger
@ 2012-02-16 23:36 ` Kevin Buettner
2012-02-17 1:21 ` Mike Frysinger
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Buettner @ 2012-02-16 23:36 UTC (permalink / raw)
To: gdb-patches
On Wed, 15 Feb 2012 23:50:34 -0500
Mike Frysinger <vapier@gentoo.org> wrote:
> On Wednesday 15 February 2012 19:26:22 Kevin Buettner wrote:
> > Any comments on the following patch?
>
> uintptr_t i think would be better, but we don't seem to use that in sim/, so
> this is OK
>
> > It fixes a bunch of warnings when building on a 64-bit host. Here
> > are a few of them:
> >
> > ./code.c:93: warning: cast from pointer to integer of different size
> > ./code.c:215: warning: cast from pointer to integer of different size
> > ./code.c:230: warning: cast from pointer to integer of different size
>
> makes me think that this sim is incorrectly mixing target and host types
My reading of the code shows that (the variable behind) PC is char *.
(PC is a macro defined to be insn_ptr.) The MA macro needs to convert
that pointer to an int type in order to apply the mask. So I agree
that uintptr_t would be the right thing to use.
I've committed my patch, but if you wish I can try it with uintptr_t.
This will require us to include stdint.h.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] sim/sh: Fix compile warnings for 64-bit build hosts
2012-02-16 23:36 ` Kevin Buettner
@ 2012-02-17 1:21 ` Mike Frysinger
0 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2012-02-17 1:21 UTC (permalink / raw)
To: gdb-patches; +Cc: Kevin Buettner
[-- Attachment #1: Type: Text/Plain, Size: 1491 bytes --]
On Thursday 16 February 2012 18:31:16 Kevin Buettner wrote:
> On Wed, 15 Feb 2012 23:50:34 -0500 Mike Frysinger wrote:
> > On Wednesday 15 February 2012 19:26:22 Kevin Buettner wrote:
> > > Any comments on the following patch?
> >
> > uintptr_t i think would be better, but we don't seem to use that in sim/,
> > so this is OK
> >
> > > It fixes a bunch of warnings when building on a 64-bit host. Here
> > > are a few of them:
> > >
> > > ./code.c:93: warning: cast from pointer to integer of different size
> > > ./code.c:215: warning: cast from pointer to integer of different size
> > > ./code.c:230: warning: cast from pointer to integer of different size
> >
> > makes me think that this sim is incorrectly mixing target and host types
>
> My reading of the code shows that (the variable behind) PC is char *.
> (PC is a macro defined to be insn_ptr.) The MA macro needs to convert
> that pointer to an int type in order to apply the mask. So I agree
> that uintptr_t would be the right thing to use.
>
> I've committed my patch, but if you wish I can try it with uintptr_t.
> This will require us to include stdint.h.
i don't think fixing this tiny issue would measurably improve the code, so
don't worry about it. to truly make the code better, the PC would need to not
be a pointer but rather uint32_t (for 32bit SuperH procs) and uin64_t (for
64bit SuperH procs). and i imagine that is way more work than you want to
take on ;).
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-16 23:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-16 4:46 [RFC] sim/sh: Fix compile warnings for 64-bit build hosts Kevin Buettner
2012-02-16 4:54 ` Mike Frysinger
2012-02-16 23:36 ` Kevin Buettner
2012-02-17 1:21 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox