Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #37178] [PATCH] Quiet a few alignment warnings

0 views
Skip to first unread message

Andy Dougherty

unread,
Sep 15, 2005, 2:14:18 PM9/15/05
to bugs-bi...@rt.perl.org
# New Ticket Created by Andy Dougherty
# Please include the string: [perl #37178]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37178 >


Currently, on SPARC/Solaris with gcc, compilation of parrot produces
7,208 warnings of the form:

warning: cast increases required alignment of target type

This patch gets rid of four of them. The code in these cases actually
did preserve the appropriate alignment, so this patch only serves to
quiet the warnings. However, in the past, some of those warnings have
been pointing to real problems, so avoiding the warnings where feasible
is probably a good idea. Basically, whenever sensible, we should allow
the compiler to operate on pointers in their native type.

diff -r -u parrot-orig/src/pmc_freeze.c parrot-andy/src/pmc_freeze.c
--- parrot-orig/src/pmc_freeze.c Mon Sep 5 12:56:58 2005
+++ parrot-andy/src/pmc_freeze.c Thu Sep 15 14:00:43 2005
@@ -621,7 +621,7 @@
PMC_next_for_GC(p) = NULL;
}
#endif
- p = (PMC *)((char *)p + sizeof(PMC));
+ p++;
}
}
}
diff -r -u parrot-orig/src/packfile.c parrot-andy/src/packfile.c
--- parrot-orig/src/packfile.c Mon Sep 5 12:56:57 2005
+++ parrot-andy/src/packfile.c Thu Sep 15 09:13:24 2005
@@ -89,11 +89,7 @@

#define ROUND_16(val) ( ((val) & 0xf) ? 16 - ((val) & 0xf) : 0 )
#define ALIGN_16(st, cursor) \
- do { \
- (cursor) = (opcode_t *) \
- ((char *)(cursor) \
- + ROUND_16((char *)(cursor) - (char *)(st))); \
- } while (0)
+ (cursor) += ROUND_16( (char *)(cursor) - (char *)(st) )/sizeof(opcode_t)

/*

@@ -546,7 +542,7 @@
* Map the header on top of the buffer later when we are sure
* we have alignment done right.
*/
- cursor = (opcode_t*)((char*)packed + PACKFILE_HEADER_BYTES);
+ cursor = packed + PACKFILE_HEADER_BYTES/sizeof(opcode_t);
memcpy(header, packed, PACKFILE_HEADER_BYTES);

if (header->wordsize != 4 && header->wordsize != 8) {

--
Andy Dougherty doug...@lafayette.edu

0 new messages