* PATCH, rs6000: silence warnings
@ 2009-04-21 1:48 Ben Elliston
[not found] ` <303e1d290904201953v55125bcco64f8433d9a5bcaa7@mail.gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Ben Elliston @ 2009-04-21 1:48 UTC (permalink / raw)
To: gcc-patches; +Cc: dje.gcc
When building libgcc on powerpc64-linux, I see:
/home/bje/source/gcc-trunk/libgcc/../gcc/config/rs6000/linux-unwind.h:98: warning: cast discards qualifiers from pointer target type
/home/bje/source/gcc-trunk/libgcc/../gcc/config/rs6000/linux-unwind.h:99: warning: cast discards qualifiers from pointer target type
/home/bje/source/gcc-trunk/libgcc/../gcc/config/rs6000/linux-unwind.h:101: warning: cast discards qualifiers from pointer target type
/home/bje/source/gcc-trunk/libgcc/../gcc/config/rs6000/linux-unwind.h:110: warning: cast discards qualifiers from pointer target type
/home/bje/source/gcc-trunk/libgcc/../gcc/config/rs6000/linux-unwind.h:120: warning: cast discards qualifiers from pointer target type
This patch cleans up these casts by eliminating them altogether. With
this change, the code becomes more typesafe and easier to read. OK for
mainline? (Regression test and bootstrap underway on power64-linux).
Thanks,
Ben
2009-04-21 Ben Elliston <bje@au.ibm.com>
* config/rs6000/linux-unwind.h (get_regs): Remove type
puns. Change the type of `pc' to an array of unsigned ints and
update all users. Constify frame24.
Index: /home/bje/source/gcc-trunk/gcc/config/rs6000/linux-unwind.h
===================================================================
--- /home/bje/source/gcc-trunk/gcc/config/rs6000/linux-unwind.h (revision 146466)
+++ /home/bje/source/gcc-trunk/gcc/config/rs6000/linux-unwind.h (working copy)
@@ -91,14 +91,13 @@
static struct gcc_regs *
get_regs (struct _Unwind_Context *context)
{
- const unsigned char *pc = context->ra;
+ const unsigned int *pc = context->ra;
/* addi r1, r1, 128; li r0, 0x0077; sc (sigreturn) */
/* addi r1, r1, 128; li r0, 0x00AC; sc (rt_sigreturn) */
- if (*(unsigned int *) (pc + 0) != 0x38210000 + SIGNAL_FRAMESIZE
- || *(unsigned int *) (pc + 8) != 0x44000002)
+ if (pc[0] != 0x38210000 + SIGNAL_FRAMESIZE || pc[2] != 0x44000002)
return NULL;
- if (*(unsigned int *) (pc + 4) == 0x38000077)
+ if (pc[1] == 0x38000077)
{
struct sigframe {
char gap[SIGNAL_FRAMESIZE];
@@ -107,17 +106,17 @@
} *frame = (struct sigframe *) context->cfa;
return frame->regs;
}
- else if (*(unsigned int *) (pc + 4) == 0x380000AC)
+ else if (pc[1] == 0x380000AC)
{
/* This works for 2.4 kernels, but not for 2.6 kernels with vdso
because pc isn't pointing into the stack. Can be removed when
no one is running 2.4.19 or 2.4.20, the first two ppc64
kernels released. */
- struct rt_sigframe_24 {
+ const struct rt_sigframe_24 {
int tramp[6];
void *pinfo;
struct gcc_ucontext *puc;
- } *frame24 = (struct rt_sigframe_24 *) pc;
+ } *frame24 = (const struct rt_sigframe_24 *) context->ra;
/* Test for magic value in *puc of vdso. */
if ((long) frame24->puc != -21 * 8)
@@ -146,16 +145,15 @@
static struct gcc_regs *
get_regs (struct _Unwind_Context *context)
{
- const unsigned char *pc = context->ra;
+ const unsigned int *pc = context->ra;
/* li r0, 0x7777; sc (sigreturn old) */
/* li r0, 0x0077; sc (sigreturn new) */
/* li r0, 0x6666; sc (rt_sigreturn old) */
/* li r0, 0x00AC; sc (rt_sigreturn new) */
- if (*(const unsigned int *) (pc + 4) != 0x44000002)
+ if (pc[1] != 0x44000002)
return NULL;
- if (*(const unsigned int *) (pc + 0) == 0x38007777
- || *(const unsigned int *) (pc + 0) == 0x38000077)
+ if (pc[0] == 0x38007777 || pc[0] == 0x38000077)
{
struct sigframe {
char gap[SIGNAL_FRAMESIZE];
@@ -164,8 +162,7 @@
} *frame = (struct sigframe *) context->cfa;
return frame->regs;
}
- else if (*(const unsigned int *) (pc + 0) == 0x38006666
- || *(const unsigned int *) (pc + 0) == 0x380000AC)
+ else if (pc[0] == 0x38006666 || pc[0] == 0x380000AC)
{
struct rt_sigframe {
char gap[SIGNAL_FRAMESIZE + 16];
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH, rs6000: silence warnings
[not found] ` <1240357691.18770.0.camel@helios>
@ 2009-04-22 14:30 ` David Edelsohn
0 siblings, 0 replies; 2+ messages in thread
From: David Edelsohn @ 2009-04-22 14:30 UTC (permalink / raw)
To: Ben Elliston; +Cc: gcc-patches
On Tue, Apr 21, 2009 at 7:48 PM, Ben Elliston <bje@au1.ibm.com> wrote:
> On Mon, 2009-04-20 at 22:53 -0400, David Edelsohn wrote:
>
>> > This patch cleans up these casts by eliminating them altogether. With
>> > this change, the code becomes more typesafe and easier to read. OK for
>> > mainline? (Regression test and bootstrap underway on power64-linux).
>>
>> Why was it initially written as char * ? Normal, valid PowerPC code
>> should be word-aligned, but is it possible to be called with an
>> unaligned pointer? Will this change cause problems on embedded
>> processors with strict alignment requirements?
>
> My reading was that the char * was only the type for a buffer where
> several addresses were stashed. That does not dictate anything about
> the alignment of the addresses stored therein.
Not the alignment of the addresses, but the alignment of the buffer
itself. It looks like it always will be suitably aligned.
The patch is okay.
Thanks, David
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-04-22 14:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-21 1:48 PATCH, rs6000: silence warnings Ben Elliston
[not found] ` <303e1d290904201953v55125bcco64f8433d9a5bcaa7@mail.gmail.com>
[not found] ` <1240357691.18770.0.camel@helios>
2009-04-22 14:30 ` David Edelsohn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).