Skip to content

Commit

Permalink
Change type of offset arg in H5Pset_external to HDoff_t
Browse files Browse the repository at this point in the history
The `off_t` type is only 32-bit on Windows, which makes it impossible to link to higher offsets in large files.

The `H5O_efl_entry_t` struct defines its `offset` field already as `HDoff_t`, so no additional conversion is needed.
  • Loading branch information
phil-opp committed Sep 5, 2023
1 parent df8f7a9 commit 8e4e9e5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions bin/trace
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ $Source = "";
"H5M_iterate_t" => 'MI',
"H5FD_mem_t" => "Mt",
"off_t" => "o",
"HDoff_t" => "Ho",
"H5O_iterate1_t" => "Oi",
"H5O_iterate2_t" => "OI",
"H5O_mcdt_search_cb_t" => "Os",
Expand Down
4 changes: 2 additions & 2 deletions src/H5Pdcpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ H5Pget_chunk_opts(hid_t plist_id, unsigned *options /*out*/)
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size)
H5Pset_external(hid_t plist_id, const char *name, HDoff_t offset, hsize_t size)
{
size_t idx;
hsize_t total, tmp;
Expand All @@ -2608,7 +2608,7 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size)
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE4("e", "i*soh", plist_id, name, offset, size);
H5TRACE4("e", "i*sHoh", plist_id, name, offset, size);

/* Check arguments */
if (!name || !*name)
Expand Down
17 changes: 16 additions & 1 deletion src/H5Ppublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -5570,6 +5570,21 @@ H5_DLL herr_t H5Pget_mpi_params(hid_t fapl_id, MPI_Comm *comm, MPI_Info *info);
*/
H5_DLL herr_t H5Pset_mpi_params(hid_t fapl_id, MPI_Comm comm, MPI_Info info);
#endif /* H5_HAVE_PARALLEL */

#ifdef H5_HAVE_WIN32_API
/* off_t exists on Windows, but is always a 32-bit long, even on 64-bit Windows,
* so we define HDoff_t to be __int64, which is the type of the st_size field
* of the _stati64 struct.
*/
#define HDoff_t __int64
#endif /* H5_HAVE_WIN32_API */
#ifndef H5_HAVE_WIN32_API
/* These definitions differ in Windows and are defined in
* H5win32defs for that platform.
*/
#define HDoff_t off_t
#endif

/**
* \ingroup FAPL
*
Expand Down Expand Up @@ -6353,7 +6368,7 @@ H5_DLL herr_t H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize);
* \since 1.0.0
*
*/
H5_DLL herr_t H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size);
H5_DLL herr_t H5Pset_external(hid_t plist_id, const char *name, HDoff_t offset, hsize_t size);
/**
* \ingroup DCPL
*
Expand Down

0 comments on commit 8e4e9e5

Please sign in to comment.