Fix 64bit alignment issue in totempg

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1889 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Fabio M. Di Nitto 2009-03-22 18:35:06 +00:00
parent 1a70ca7ae2
commit aaf6948ae7

View File

@ -343,13 +343,30 @@ static inline void group_endian_convert (
{
unsigned short *group_len;
int i;
struct iovec iovec_aligned = { NULL, 0 };
struct iovec *iovec_swab;
group_len = (unsigned short *)iovec->iov_base;
/*
* Align data structure for sparc and ia64
*/
if ((size_t)iovec->iov_base % 4 != 0) {
iovec_aligned.iov_base = alloca(iovec->iov_len);
memcpy(iovec_aligned.iov_base, iovec->iov_base, iovec->iov_len);
iovec_aligned.iov_len = iovec->iov_len;
iovec_swab = &iovec_aligned;
} else {
iovec_swab = iovec;
}
group_len = (unsigned short *)iovec_swab->iov_base;
group_len[0] = swab16(group_len[0]);
for (i = 1; i < group_len[0] + 1; i++) {
group_len[i] = swab16(group_len[i]);
}
if (iovec_swab == &iovec_aligned) {
memcpy(iovec->iov_base, iovec_aligned.iov_base, iovec->iov_len);
}
}
static inline int group_matches (
@ -372,7 +389,8 @@ static inline int group_matches (
*/
if ((size_t)iovec->iov_base % 4 != 0) {
iovec_aligned.iov_base = alloca(iovec->iov_len);
memcpy(iovec_aligned.iov_base, iovec->iov_base, iovec->iov_len); iovec_aligned.iov_len = iovec->iov_len;
memcpy(iovec_aligned.iov_base, iovec->iov_base, iovec->iov_len);
iovec_aligned.iov_len = iovec->iov_len;
iovec = &iovec_aligned;
}