Project

General

Profile

Bug #55

Internal XDR functions are broken on some big endian systems.

Added by Jeppe Oland over 13 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
High
Assignee:
Erik Lindahl
Category:
mdrun
Target version:
Affected version - extra info:
Affected version:
Difficulty:
uncategorized
Close

Description

Big endian systems that have "long > int" breaks some xdr_put functions.

For example, from xdr_float:
case XDR_ENCODE:
if (sizeof(float) sizeof(long))
return (xdr_putlong(xdrs, (long *)fp));
else if (sizeof(float) sizeof(int)) {
long tmp = *(int *)fp;
return (xdr_putlong(xdrs, &tmp));
}
break;

"long tmp = *(int *)fp" will stuff the float into the bottom 4 bytes of the
8-byte long, and then the first 4 bytes will be written to disk :(

gmx_system_xdr.c (16.1 KB) gmx_system_xdr.c Proposed fixed version Erik Lindahl, 03/08/2006 03:20 PM
gmx_system_xdr.h (8.72 KB) gmx_system_xdr.h updated header Erik Lindahl, 03/08/2006 03:20 PM

History

#1 Updated by Erik Lindahl over 13 years ago

Created an attachment (id=25)
Proposed fixed version

#2 Updated by Erik Lindahl over 13 years ago

Created an attachment (id=26)
updated header

#3 Updated by Erik Lindahl over 13 years ago

This is an old bug that comes from the Sun public RPC code, which I bet was never updated for 64-bit
CPUs. All the xdr_long routines only support 32 bits.

The only reason we haven't discovered it before is that the internal XDR stuff is normally only used for 32-
bit MS Windows - on Unix systems we link with the vendor's XDR libraries.

Anyway, I think I've worked around it by using our own int32 routines. If you have a chance, please try the
attached updated version of gmx_system_xdr.c and the corresponding header (before I commit).

#4 Updated by Jeppe Oland over 13 years ago

Yep that seems to have fixed it - thanks.

#5 Updated by Erik Lindahl over 13 years ago

Commited to HEAD and release-3-3-patches branch.

Also available in: Atom PDF