Skip to content

Commit

Permalink
Adress problem reported in #1852 (#1860)
Browse files Browse the repository at this point in the history
  • Loading branch information
GillesDuvert authored Jul 16, 2024
1 parent 926c7a2 commit 9e6eba3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/hdf5_fun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,9 @@ hid_t
hid_t hdf5_id;

#if (H5_VERS_MAJOR>1)||((H5_VERS_MAJOR==1)&&(H5_VERS_MINOR>=10))
e->AssureLongScalarKW(position, (DLong64&)hdf5_id);
DLong64 temp=0;
e->AssureLongScalarKW(position, temp);
hdf5_id=temp;
#else
e->AssureLongScalarKW(position, hdf5_id);
#endif
Expand All @@ -970,7 +972,9 @@ hid_t
hid_t hdf5_id;

#if (H5_VERS_MAJOR>1)||((H5_VERS_MAJOR==1)&&(H5_VERS_MINOR>=10))
e->AssureLongScalarPar(position, (DLong64&)hdf5_id);
DLong64 temp=0;
e->AssureLongScalarPar(position, temp);
hdf5_id=temp;
#else
e->AssureLongScalarPar(position, hdf5_id);
#endif
Expand Down
24 changes: 15 additions & 9 deletions src/saverestore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ bool_t xdr_set_gdl_pos(XDR *x, long int y){
return xdr_get_gdl_pos(xdrs); //end of header
}

union U
{
u_int32_t trentedeux[2];
u_int64_t soixantequatre;
};

inline u_int64_t updateNewRecordHeader(XDR *xdrs, u_int64_t cur) {
u_int64_t next = xdr_get_gdl_pos(xdrs);
//dirty trick for compression: write uncompressed, rewind, read what was just written, compress, write over, reset positions.
Expand All @@ -457,18 +463,18 @@ bool_t xdr_set_gdl_pos(XDR *x, long int y){
}
xdr_set_gdl_pos(xdrs, cur-12); //ptrs0
//copy next (64 bit) as two 32 bits. Should be OK on 32 bit machines as next is u_int64.
if (BigEndian()) { //first 32 bit is low, second high (XDRS is BigEndian)
xdr_uint64_t(xdrs, &next);
} else {
u_int32_t first,second;
first = ((u_int32_t *) &next)[0];
second = ((u_int32_t *) &next)[1];
xdr_uint32_t(xdrs, &first);
xdr_uint32_t(xdrs, &second);
if (!BigEndian()) { //first 32 bit is low, second high (XDRS is BigEndian)
U u;
u.soixantequatre=next;
u_int32_t temp=u.trentedeux[0];
u.trentedeux[0]=u.trentedeux[1];
u.trentedeux[1]=temp;
next=u.soixantequatre;
}
xdr_uint64_t(xdrs, &next);
xdr_set_gdl_pos(xdrs, next);
return next;
}
}

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

0 comments on commit 9e6eba3

Please sign in to comment.