Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch HDoff_t to haddr_t in the public API #5082

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from
Draft
4 changes: 2 additions & 2 deletions HDF5Examples/FORTRAN/H5D/h5ex_d_extern.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ PROGRAM main
INTEGER :: i, j
! This change was introduced in the 1.8.12 release
#if H5_VERSION_GE(1,8,12)
INTEGER(OFF_T) :: offset = 0 ! Offset, in bytes, from the beginning of the file to the
! location in the file where the data starts.
INTEGER(HADDR_T) :: offset = 0 ! Offset, in bytes, from the beginning of the file to the
! location in the file where the data starts.
#else
INTEGER :: offset = 0
#endif
Expand Down
4 changes: 2 additions & 2 deletions c++/src/C2Cppfunction_map.htm
Original file line number Diff line number Diff line change
Expand Up @@ -16851,7 +16851,7 @@
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'>void DSetCreatPropList::setExternal(const char* name, HDoff_t offset,
normal'>void DSetCreatPropList::setExternal(const char* name, haddr_t offset,
hsize_t size)</p>
</td>
<td width=35 valign=top style='width:26.05pt;border-top:none;border-left:
Expand Down Expand Up @@ -16925,7 +16925,7 @@
mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'>void DSetCreatPropList::getExternal(unsigned idx, size_t name_size,
char* name, HDoff_t&amp; offset, hsize_t&amp; size)</p>
char* name, haddr_t&amp; offset, hsize_t&amp; size)</p>
</td>
<td width=35 valign=top style='width:26.05pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
Expand Down
8 changes: 4 additions & 4 deletions c++/src/H5DcreatProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,10 @@ DSetCreatPropList::setFletcher32() const
/// which is a 32-bit signed long value on Windows, which limited
/// the valid offset that can be set to 2 GiB.
///
///\version 2.0.0 \p offset parameter type changed to HDoff_t from off_t.
///\version 2.0.0 \p offset parameter type changed to haddr_t from off_t.
//--------------------------------------------------------------------------
void
DSetCreatPropList::setExternal(const char *name, HDoff_t offset, hsize_t size) const
DSetCreatPropList::setExternal(const char *name, haddr_t offset, hsize_t size) const
{
herr_t ret_value = H5Pset_external(id, name, offset, size);
if (ret_value < 0) {
Expand Down Expand Up @@ -702,10 +702,10 @@ DSetCreatPropList::getExternalCount() const
/// which is a 32-bit signed long value on Windows, which limited
/// the valid offset that can be returned to 2 GiB.
///
///\version 2.0.0 \p offset parameter type changed to HDoff_t from off_t.
///\version 2.0.0 \p offset parameter type changed to haddr_t from off_t.
//--------------------------------------------------------------------------
void
DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char *name, HDoff_t &offset,
DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char *name, haddr_t &offset,
hsize_t &size) const
{
herr_t ret_value = H5Pget_external(id, idx, name_size, name, &offset, &size);
Expand Down
4 changes: 2 additions & 2 deletions c++/src/H5DcreatProp.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList {
void setChunk(int ndims, const hsize_t *dim) const;

// Returns information about an external file.
void getExternal(unsigned idx, size_t name_size, char *name, HDoff_t &offset, hsize_t &size) const;
void getExternal(unsigned idx, size_t name_size, char *name, haddr_t &offset, hsize_t &size) const;

// Returns the number of external files for a dataset.
int getExternalCount() const;
Expand Down Expand Up @@ -101,7 +101,7 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList {
void setDeflate(int level) const;

// Adds an external file to the list of external files.
void setExternal(const char *name, HDoff_t offset, hsize_t size) const;
void setExternal(const char *name, haddr_t offset, hsize_t size) const;

// Adds a filter to the filter pipeline.
void setFilter(H5Z_filter_t filter, unsigned int flags = 0, size_t cd_nelmts = 0,
Expand Down
12 changes: 6 additions & 6 deletions fortran/src/H5Pf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ h5pget_filter_c(hid_t_f *prp_id, int_f *filter_number, int_f *flags, size_t_f *c
* SOURCE
*/
int_f
h5pset_external_c(hid_t_f *prp_id, _fcd name, int_f *namelen, off_t_f *offset, hsize_t_f *bytes)
h5pset_external_c(hid_t_f *prp_id, _fcd name, int_f *namelen, haddr_t_f *offset, hsize_t_f *bytes)
/******/
{
int ret_value = -1;
Expand All @@ -1525,9 +1525,9 @@ h5pset_external_c(hid_t_f *prp_id, _fcd name, int_f *namelen, off_t_f *offset, h
hsize_t c_bytes;
char *c_name;
size_t c_namelen = (size_t)*namelen;
off_t c_offset;
haddr_t c_offset;
c_bytes = (hsize_t)*bytes;
c_offset = (off_t)*offset;
c_offset = (haddr_t)*offset;

c_name = (char *)HD5f2cstring(name, c_namelen);
if (c_name == NULL)
Expand Down Expand Up @@ -1600,7 +1600,7 @@ h5pget_external_count_c(hid_t_f *prp_id, int_f *count)
* SOURCE
*/
int_f
h5pget_external_c(hid_t_f *prp_id, int_f *idx, size_t_f *name_size, _fcd name, off_t_f *offset,
h5pget_external_c(hid_t_f *prp_id, int_f *idx, size_t_f *name_size, _fcd name, haddr_t_f *offset,
hsize_t_f *bytes)
/******/
{
Expand All @@ -1610,7 +1610,7 @@ h5pget_external_c(hid_t_f *prp_id, int_f *idx, size_t_f *name_size, _fcd name, o
herr_t status;
size_t c_namelen;
char *c_name = NULL;
HDoff_t c_offset;
haddr_t c_offset;
hsize_t size;

c_namelen = (size_t)*name_size;
Expand All @@ -1632,7 +1632,7 @@ h5pget_external_c(hid_t_f *prp_id, int_f *idx, size_t_f *name_size, _fcd name, o
if (status < 0)
goto DONE;

*offset = (off_t_f)c_offset;
*offset = (haddr_t_f)c_offset;
*bytes = (hsize_t_f)size;
/* Note: if the size of the fortran buffer is larger then the returned string
* from the function then we need to give HD5packFstring the fortran buffer size so
Expand Down
18 changes: 6 additions & 12 deletions fortran/src/H5Pff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1623,16 +1623,13 @@ END SUBROUTINE h5pget_filter_f
!! \param bytes Size of the external file data.
!! \param hdferr \fortran_error
!!
!! \note On Windows, off_t is typically a 32-bit signed long value, which
!! limits the valid offset that can be set to 2 GiB.
!!
!! See C API: @ref H5Pset_external()
!!
SUBROUTINE h5pset_external_f(prp_id, name, offset, bytes, hdferr)
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: prp_id
CHARACTER(LEN=*), INTENT(IN) :: name
INTEGER(OFF_T), INTENT(IN) :: offset
INTEGER(HADDR_T), INTENT(IN) :: offset
INTEGER(HSIZE_T), INTENT(IN) :: bytes
INTEGER, INTENT(OUT) :: hdferr
INTEGER :: namelen
Expand All @@ -1641,12 +1638,12 @@ SUBROUTINE h5pset_external_f(prp_id, name, offset, bytes, hdferr)
INTEGER FUNCTION h5pset_external_c(prp_id, name,namelen, offset, bytes) &
BIND(C,NAME='h5pset_external_c')
IMPORT :: C_CHAR
IMPORT :: HID_T, OFF_T, HSIZE_T
IMPORT :: HID_T, HADDR_T, HSIZE_T
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: prp_id
CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name
INTEGER :: namelen
INTEGER(OFF_T), INTENT(IN) :: offset
INTEGER(HADDR_T), INTENT(IN) :: offset
INTEGER(HSIZE_T), INTENT(IN) :: bytes
END FUNCTION h5pset_external_c
END INTERFACE
Expand Down Expand Up @@ -1697,9 +1694,6 @@ END SUBROUTINE h5pget_external_count_f
!! \param bytes Size of the external file data.
!! \param hdferr \fortran_error
!!
!! \note On Windows, off_t is typically a 32-bit signed long value, which
!! limits the valid offset that can be returned to 2 GiB.
!!
!! See C API: @ref H5Pget_external()
!!
SUBROUTINE h5pget_external_f(prp_id, idx, name_size, name, offset, bytes, hdferr)
Expand All @@ -1708,20 +1702,20 @@ SUBROUTINE h5pget_external_f(prp_id, idx, name_size, name, offset, bytes, hdferr
INTEGER, INTENT(IN) :: idx
INTEGER(SIZE_T), INTENT(IN) :: name_size
CHARACTER(LEN=*), INTENT(OUT) :: name
INTEGER(OFF_T), INTENT(OUT) :: offset
INTEGER(HADDR_T), INTENT(OUT) :: offset
INTEGER(HSIZE_T), INTENT(OUT) :: bytes
INTEGER, INTENT(OUT) :: hdferr
INTERFACE
INTEGER FUNCTION h5pget_external_c(prp_id, idx, name_size, name, offset, bytes) &
BIND(C,NAME='h5pget_external_c')
IMPORT :: C_CHAR
IMPORT :: HID_T, SIZE_T, HSIZE_T, OFF_T
IMPORT :: HID_T, SIZE_T, HSIZE_T, HADDR_T
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: prp_id
INTEGER, INTENT(IN) :: idx
INTEGER(SIZE_T), INTENT(IN) :: name_size
CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: name
INTEGER(OFF_T), INTENT(OUT) :: offset
INTEGER(HADDR_T), INTENT(OUT) :: offset
INTEGER(HSIZE_T), INTENT(OUT) :: bytes
END FUNCTION h5pget_external_c
END INTERFACE
Expand Down
6 changes: 3 additions & 3 deletions fortran/src/H5f90proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,11 @@ H5_FCDLL int_f h5pget_filter_c(hid_t_f *prp_id, int_f *filter_number, int_f *fla
int_f *cd_values, size_t_f *namelen, _fcd name, int_f *filter_id);
H5_FCDLL int_f h5pget_filter_by_id_c(hid_t_f *prp_id, int_f *filter_id, int_f *flags, size_t_f *cd_nelmts,
int_f *cd_values, size_t_f *namelen, _fcd name);
H5_FCDLL int_f h5pset_external_c(hid_t_f *prp_id, _fcd name, int_f *namelen, off_t_f *offset,
H5_FCDLL int_f h5pset_external_c(hid_t_f *prp_id, _fcd name, int_f *namelen, haddr_t_f *offset,
hsize_t_f *bytes);
H5_FCDLL int_f h5pget_external_count_c(hid_t_f *prp_id, int_f *count);
H5_FCDLL int_f h5pget_external_c(hid_t_f *prp_id, int_f *idx, size_t_f *name_size, _fcd name, off_t_f *offset,
hsize_t_f *bytes);
H5_FCDLL int_f h5pget_external_c(hid_t_f *prp_id, int_f *idx, size_t_f *name_size, _fcd name,
haddr_t_f *offset, hsize_t_f *bytes);
H5_FCDLL int_f h5pget_btree_ratios_c(hid_t_f *prp_id, real_f *left, real_f *middle, real_f *right);
H5_FCDLL int_f h5pset_btree_ratios_c(hid_t_f *prp_id, real_f *left, real_f *middle, real_f *right);
H5_FCDLL int_f h5pset_fclose_degree_c(hid_t_f *fapl, int_f *degree);
Expand Down
11 changes: 0 additions & 11 deletions fortran/src/H5match_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,6 @@ main(void)
return -1;
}

/* off_t */
for (i = 0; i < FORTRAN_NUM_INTEGER_KINDS; i++) {
if (IntKinds_SizeOf[i] == H5_SIZEOF_OFF_T) {
writeToFiles("int", "OFF_T", "off_t_f", IntKinds[i]);
break;
}
if (i == (FORTRAN_NUM_INTEGER_KINDS - 1))
/* Error: couldn't find a size for off_t */
return -1;
}

/* size_t */
for (i = 0; i < FORTRAN_NUM_INTEGER_KINDS; i++) {
if (IntKinds_SizeOf[i] == H5_SIZEOF_SIZE_T) {
Expand Down
4 changes: 2 additions & 2 deletions fortran/test/tH5P.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SUBROUTINE external_test(cleanup, total_error)
INTEGER(HSIZE_T), DIMENSION(1) :: cur_size !data space current size
INTEGER(HSIZE_T), DIMENSION(1) :: max_size !data space maximum size
CHARACTER(LEN=256) :: name !external file name
INTEGER(OFF_T) :: file_offset !external file offset
INTEGER(HADDR_T) :: file_offset !external file offset
INTEGER(HSIZE_T) :: file_size !sizeof external file segment
INTEGER :: error !error code
INTEGER(SIZE_T) :: int_size !size of integer
Expand Down Expand Up @@ -134,7 +134,7 @@ SUBROUTINE external_test(cleanup, total_error)
CALL h5tget_size_f(H5T_NATIVE_INTEGER, int_size, error)
CALL check("h5tget_size_f",error,total_error)
file_size = int_size * max_size(1)
CALL h5pset_external_f(plist_id, "ext1.data", INT(0,off_t), file_size, error)
CALL h5pset_external_f(plist_id, "ext1.data", INT(0,haddr_t), file_size, error)
CALL check("h5pset_external_f",error,total_error)
CALL h5screate_simple_f(RANK, cur_size, space_id, error, max_size)
CALL check("h5screate_simple_f", error, total_error)
Expand Down
8 changes: 4 additions & 4 deletions fortran/test/tH5P_F03.F90
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,13 @@ SUBROUTINE external_test_offset(cleanup,total_error)

CALL h5pcreate_f(H5P_DATASET_CREATE_F, dcpl, error)
CALL check("h5pcreate_f", error, total_error)
CALL h5pset_external_f(dcpl, "extern_1a.raw", INT(0,off_t), sizeof_part, error)
CALL h5pset_external_f(dcpl, "extern_1a.raw", INT(0,haddr_t), sizeof_part, error)
CALL check("h5pset_external_f",error,total_error)
CALL h5pset_external_f(dcpl, "extern_2a.raw", INT(10,off_t), sizeof_part, error)
CALL h5pset_external_f(dcpl, "extern_2a.raw", INT(10,haddr_t), sizeof_part, error)
CALL check("h5pset_external_f",error,total_error)
CALL h5pset_external_f(dcpl, "extern_3a.raw", INT(20,off_t), sizeof_part, error)
CALL h5pset_external_f(dcpl, "extern_3a.raw", INT(20,haddr_t), sizeof_part, error)
CALL check("h5pset_external_f",error,total_error)
CALL h5pset_external_f(dcpl, "extern_4a.raw", INT(30,off_t), sizeof_part, error)
CALL h5pset_external_f(dcpl, "extern_4a.raw", INT(30,haddr_t), sizeof_part, error)
CALL check("h5pset_external_f",error,total_error)

cur_size(1) = 100
Expand Down
6 changes: 3 additions & 3 deletions java/src/jni/h5pDCPLImp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1external(JNIEnv *env, jclass clss, jlong plist, jstr

PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Pset_external: file name not pinned");

if ((status = H5Pset_external((hid_t)plist, fileName, (HDoff_t)offset, (hsize_t)size)) < 0)
if ((status = H5Pset_external((hid_t)plist, fileName, (haddr_t)offset, (hsize_t)size)) < 0)
H5_LIBRARY_ERROR(ENVONLY);

done:
Expand All @@ -1083,7 +1083,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1external(JNIEnv *env, jclass clss, jlong plist, jint
jboolean isCopy;
jstring str;
hsize_t s;
HDoff_t o;
haddr_t o;
jsize arrLen;
jlong *theArray = NULL;
char *file = NULL;
Expand Down Expand Up @@ -1112,7 +1112,7 @@ Java_hdf_hdf5lib_H5_H5Pget_1external(JNIEnv *env, jclass clss, jlong plist, jint
if (NULL != size) {
PIN_LONG_ARRAY(ENVONLY, size, theArray, &isCopy, "H5Pget_external: size array not pinned");

theArray[0] = o;
theArray[0] = (jlong)o;
theArray[1] = (jlong)s;
}

Expand Down
16 changes: 6 additions & 10 deletions release_docs/RELEASE.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to the Fortran Section:

The offset parameter was changed for H5P(set|get)_external_f() from an INTEGER of KIND OFF_T to HADDR_T, and the OFF_T parameter is no longer a defined INTEGER KIND.

Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,13 @@ New Features
developers who wish to provide an ID for their driver should create
a routine specific to their individual implementation.

- H5Pset_external() now uses HDoff_t, which is always a 64-bit type
- H5P(set|get)_external() now take a haddr_t offset parameter, which is
always a 64-bit type

The H5Pset_external() call took an off_t parameter in HDF5 1.14.x and
earlier. On POSIX systems, off_t is specified as a 64-bit type via
POSIX large-file support (LFS). On Windows, however, off_t is defined
as a 32-bit type, even on 64-bit Windows.

HDoff_t has been added to H5public.h and is defined to be int64_t on
Windows and the library has been updated to use HDoff_t in place of
off_t throughout. The H5Pset_external() offset parameter has also been
updated to be HDoff_t.
These calls took an off_t parameter in HDF5 1.14.x and earlier. On POSIX
systems, off_t is specified as a 64-bit type via POSIX large-file support
(LFS). On Windows, however, off_t is defined as a 32-bit type, even on
64-bit Windows, which limited external files to 2 GiB.

There is no API compatibility wrapper for this change.

Expand Down
4 changes: 2 additions & 2 deletions src/H5Defl.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size
HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name");
if ((fd = HDopen(full_name, O_RDONLY)) < 0)
HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file");
if (HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0)
if (HDlseek(fd, (HDoff_t)(efl->slot[u].offset + skip), SEEK_SET) < 0)
HGOTO_ERROR(H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file");
#ifndef NDEBUG
tempto_read = MIN((size_t)(efl->slot[u].size - skip), (hsize_t)size);
Expand Down Expand Up @@ -434,7 +434,7 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz
else
HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file");
} /* end if */
if (HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0)
if (HDlseek(fd, (HDoff_t)(efl->slot[u].offset + skip), SEEK_SET) < 0)
HGOTO_ERROR(H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file");
#ifndef NDEBUG
tempto_write = MIN(efl->slot[u].size - skip, (hsize_t)size);
Expand Down
Loading
Loading