Skip to content

Commit 9e6eba3

Browse files
authored
Adress problem reported in #1852 (#1860)
1 parent 926c7a2 commit 9e6eba3

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/hdf5_fun.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,9 @@ hid_t
957957
hid_t hdf5_id;
958958

959959
#if (H5_VERS_MAJOR>1)||((H5_VERS_MAJOR==1)&&(H5_VERS_MINOR>=10))
960-
e->AssureLongScalarKW(position, (DLong64&)hdf5_id);
960+
DLong64 temp=0;
961+
e->AssureLongScalarKW(position, temp);
962+
hdf5_id=temp;
961963
#else
962964
e->AssureLongScalarKW(position, hdf5_id);
963965
#endif
@@ -970,7 +972,9 @@ hid_t
970972
hid_t hdf5_id;
971973

972974
#if (H5_VERS_MAJOR>1)||((H5_VERS_MAJOR==1)&&(H5_VERS_MINOR>=10))
973-
e->AssureLongScalarPar(position, (DLong64&)hdf5_id);
975+
DLong64 temp=0;
976+
e->AssureLongScalarPar(position, temp);
977+
hdf5_id=temp;
974978
#else
975979
e->AssureLongScalarPar(position, hdf5_id);
976980
#endif

src/saverestore.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ bool_t xdr_set_gdl_pos(XDR *x, long int y){
434434
return xdr_get_gdl_pos(xdrs); //end of header
435435
}
436436

437+
union U
438+
{
439+
u_int32_t trentedeux[2];
440+
u_int64_t soixantequatre;
441+
};
442+
437443
inline u_int64_t updateNewRecordHeader(XDR *xdrs, u_int64_t cur) {
438444
u_int64_t next = xdr_get_gdl_pos(xdrs);
439445
//dirty trick for compression: write uncompressed, rewind, read what was just written, compress, write over, reset positions.
@@ -457,18 +463,18 @@ bool_t xdr_set_gdl_pos(XDR *x, long int y){
457463
}
458464
xdr_set_gdl_pos(xdrs, cur-12); //ptrs0
459465
//copy next (64 bit) as two 32 bits. Should be OK on 32 bit machines as next is u_int64.
460-
if (BigEndian()) { //first 32 bit is low, second high (XDRS is BigEndian)
461-
xdr_uint64_t(xdrs, &next);
462-
} else {
463-
u_int32_t first,second;
464-
first = ((u_int32_t *) &next)[0];
465-
second = ((u_int32_t *) &next)[1];
466-
xdr_uint32_t(xdrs, &first);
467-
xdr_uint32_t(xdrs, &second);
466+
if (!BigEndian()) { //first 32 bit is low, second high (XDRS is BigEndian)
467+
U u;
468+
u.soixantequatre=next;
469+
u_int32_t temp=u.trentedeux[0];
470+
u.trentedeux[0]=u.trentedeux[1];
471+
u.trentedeux[1]=temp;
472+
next=u.soixantequatre;
468473
}
474+
xdr_uint64_t(xdrs, &next);
469475
xdr_set_gdl_pos(xdrs, next);
470476
return next;
471-
}
477+
}
472478

473479
u_int64_t writeTimeUserHost(XDR *xdrs, char* FileDatestring, char* FileUser, char* FileHost) {
474480
u_int64_t cur=writeNewRecordHeader(xdrs, TIMESTAMP);

0 commit comments

Comments
 (0)