PERFORCE change 103978 for review
John Birrell
jb at FreeBSD.org
Tue Aug 15 05:03:22 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=103978
Change 103978 by jb at jb_freebsd2 on 2006/08/15 05:02:20
Change the generated code to use memcpy rather than a structure
assignment to avoid possible alignment problems on sun4v.
Affected files ...
.. //depot/projects/dtrace/src/lib/libelf/libelf_convert.m4#4 edit
Differences ...
==== //depot/projects/dtrace/src/lib/libelf/libelf_convert.m4#4 (text+ko) ====
@@ -251,19 +251,20 @@
static void
libelf_cvt_$1$3_tof(char *dst, char *src, int count, int byteswap)
{
- Elf64_$2 t, *s = (Elf64_$2 *) src;
+ Elf64_$2 t;
int c;
if (dst == src && !byteswap)
return;
if (!byteswap) {
- (void) memcpy(dst, src, count * sizeof(*s));
+ (void) memcpy(dst, src, count * sizeof(t));
return;
}
for (c = 0; c < count; c++) {
- t = *s++;
+ memcpy(&t, src, sizeof(t));
+ src += sizeof(t);
SWAP_$1$3(t);
WRITE_$1$3(dst,t);
}
@@ -274,21 +275,22 @@
static void
libelf_cvt_$1$3_tom(char *dst, char *src, int count, int byteswap)
{
- Elf64_$2 t, *d = (Elf64_$2 *) dst;
+ Elf64_$2 t;
int c;
if (dst == src && !byteswap)
return;
if (!byteswap) {
- (void) memcpy(dst, src, count * sizeof(*d));
+ (void) memcpy(dst, src, count * sizeof(t));
return;
}
for (c = 0; c < count; c++) {
READ_$1$3(src,t);
SWAP_$1$3(t);
- *d++ = t;
+ memcpy(dst, &t, sizeof(t));
+ dst += sizeof(t);
}
}
')
@@ -364,12 +366,12 @@
static void
libelf_cvt$3_$1_tof(char *dst, char *src, int count, int byteswap)
{
- Elf$3_$2 t, *s;
+ Elf$3_$2 t;
int c;
- s = (Elf$3_$2 *) src;
for (c = 0; c < count; c++) {
- t = *s++;
+ memcpy(&t, src, sizeof(t));
+ src += sizeof(t);
if (byteswap) {
SWAP_STRUCT($2,$3)
}
@@ -383,21 +385,22 @@
static void
libelf_cvt$3_$1_tom(char *dst, char *src, int count, int byteswap)
{
- Elf$3_$2 t, *d;
- unsigned char *s,*s0;
+ Elf$3_$2 t;
+ unsigned char *s;
+ int i;
size_t fsz;
fsz = elf$3_fsize(ELF_T_$1, 1, EV_CURRENT);
- d = ((Elf$3_$2 *) dst) + (count - 1);
- s0 = (unsigned char *) src + (count - 1) * fsz;
- while (count--) {
- s = s0;
+ for (i = 0; i < count; i++) {
+ s = (unsigned char *) src;
READ_STRUCT($2,$3)
if (byteswap) {
SWAP_STRUCT($2,$3)
}
- *d-- = t; s0 -= fsz;
+ memcpy(dst, &t, sizeof(t));
+ dst += sizeof(t);
+ src += fsz;
}
}
')')
More information about the p4-projects
mailing list