From 46ef18a501eb99899026ef30f38e60f800c0591b Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 4 Nov 2024 15:40:22 -0800 Subject: [PATCH 01/11] Switch HDoff_t to haddr_t in H5P(s|g)et_extent() Note that this switches the parameter from signed to unsigned, which generates downstream warnings that will have to be addressed. --- src/H5Pdcpl.c | 6 ++---- src/H5Ppublic.h | 8 ++++---- test/external.c | 16 ++++++++-------- test/external_env.c | 2 +- test/set_extent.c | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 3186e11c041..cc40c070051 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -2586,7 +2586,7 @@ H5Pget_chunk_opts(hid_t plist_id, unsigned *options /*out*/) *------------------------------------------------------------------------- */ herr_t -H5Pset_external(hid_t plist_id, const char *name, HDoff_t offset, hsize_t size) +H5Pset_external(hid_t plist_id, const char *name, haddr_t offset, hsize_t size) { size_t idx; hsize_t total, tmp; @@ -2599,8 +2599,6 @@ H5Pset_external(hid_t plist_id, const char *name, HDoff_t offset, hsize_t size) /* Check arguments */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given"); - if (offset < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "negative external file offset"); /* Get the plist structure */ if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) @@ -2701,7 +2699,7 @@ H5Pget_external_count(hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name /*out*/, HDoff_t *offset /*out*/, +H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name /*out*/, haddr_t *offset /*out*/, hsize_t *size /*out*/) { H5O_efl_t efl; diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index bdb172bf8dc..a9889a78fd6 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -6044,13 +6044,13 @@ H5_DLL herr_t H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize); * 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. * \version 1.6.4 \p idx parameter type changed to unsigned. * \since 1.0.0 * */ H5_DLL herr_t H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name /*out*/, - HDoff_t *offset /*out*/, hsize_t *size /*out*/); + haddr_t *offset /*out*/, hsize_t *size /*out*/); /** * \ingroup DCPL * @@ -6541,11 +6541,11 @@ H5_DLL herr_t H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize); * 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. * \since 1.0.0 * */ -H5_DLL herr_t H5Pset_external(hid_t plist_id, const char *name, HDoff_t offset, hsize_t size); +H5_DLL herr_t H5Pset_external(hid_t plist_id, const char *name, haddr_t offset, hsize_t size); /** * \ingroup DCPL * diff --git a/test/external.c b/test/external.c index c7354f9afa4..58953b8d84d 100644 --- a/test/external.c +++ b/test/external.c @@ -97,7 +97,7 @@ test_non_extendible(hid_t file) hsize_t cur_size[1] = {100}; /* data space current size */ hsize_t max_size[1] = {100}; /* data space maximum size */ int n = 0; /* number of external files */ - HDoff_t file_offset = 0; /* external file offset */ + haddr_t file_offset = 0; /* external file offset */ hsize_t file_size = 0; /* sizeof external file segment */ haddr_t dset_addr = HADDR_UNDEF; /* address of dataset */ @@ -363,7 +363,7 @@ test_unlimited(hid_t file) hsize_t cur_size[1] = {100}; /* data space current size */ hsize_t max_size[1] = {H5S_UNLIMITED}; /* data space maximum size */ int n; /* number of external files */ - HDoff_t file_offset; /* external file offset */ + haddr_t file_offset; /* external file offset */ hsize_t file_size; /* sizeof external file segment */ TESTING("unlimited dataspace, unlimited external storage"); @@ -446,7 +446,7 @@ test_unlimited(hid_t file) *------------------------------------------------------------------------- */ static int -add_external_files(hid_t dcpl_id, unsigned int n_external_files, HDoff_t offset, hsize_t max_ext_size) +add_external_files(hid_t dcpl_id, unsigned int n_external_files, haddr_t offset, hsize_t max_ext_size) { char exname[AEF_EXNAME_MAX_LEN + 1]; unsigned int i = 0; @@ -704,7 +704,7 @@ test_read_file_set(hid_t fapl) FAIL_STACK_ERROR; for (i = 0; i < N_EXT_FILES; i++) { snprintf(filename, sizeof(filename), "extern_%dr.raw", (int)i + 1); - if (H5Pset_external(dcpl, filename, (HDoff_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + if (H5Pset_external(dcpl, filename, (haddr_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR; } @@ -823,7 +823,7 @@ test_write_file_set(hid_t fapl) else size = H5F_UNLIMITED; - if (H5Pset_external(dcpl, filename, (HDoff_t)(i * GARBAGE_PER_FILE), size) < 0) + if (H5Pset_external(dcpl, filename, (haddr_t)(i * GARBAGE_PER_FILE), size) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -946,7 +946,7 @@ test_path_absolute(hid_t fapl) if (i == 1) snprintf(filename, sizeof(filename), "%s%sextern_%zur.raw", cwdpath + 2, H5_DIR_SEPS, i + 1); #endif - if (H5Pset_external(dcpl, filename, (HDoff_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + if (H5Pset_external(dcpl, filename, (haddr_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR; } @@ -1036,7 +1036,7 @@ test_path_relative(hid_t fapl) FAIL_STACK_ERROR; for (i = 0; i < N_EXT_FILES; i++) { snprintf(filename, sizeof(filename), "extern_%dr.raw", (int)i + 1); - if (H5Pset_external(dcpl, filename, (HDoff_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + if (H5Pset_external(dcpl, filename, (haddr_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR; } @@ -1130,7 +1130,7 @@ test_path_relative_cwd(hid_t fapl) FAIL_STACK_ERROR; for (i = 0; i < N_EXT_FILES; i++) { snprintf(filename, sizeof(filename), "..%sextern_%dr.raw", H5_DIR_SEPS, (int)i + 1); - if (H5Pset_external(dcpl, filename, (HDoff_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + if (H5Pset_external(dcpl, filename, (haddr_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR; } diff --git a/test/external_env.c b/test/external_env.c index 9e0305394e3..f6956bd5264 100644 --- a/test/external_env.c +++ b/test/external_env.c @@ -68,7 +68,7 @@ test_path_env(hid_t fapl) FAIL_STACK_ERROR; for (i = 0; i < N_EXT_FILES; i++) { snprintf(filename, sizeof(filename), "..%sextern_env_%dr.raw", H5_DIR_SEPS, (int)i + 1); - if (H5Pset_external(dcpl, filename, (HDoff_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + if (H5Pset_external(dcpl, filename, (haddr_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR; } /* end for */ diff --git a/test/set_extent.c b/test/set_extent.c index 0127e870174..a4e7e275b07 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -1839,7 +1839,7 @@ test_external(hid_t fapl, bool use_select_io) { char name[256]; /*external file name */ - HDoff_t file_offset; /*external file offset */ + haddr_t file_offset; /*external file offset */ hsize_t file_size; /*sizeof external file segment */ if (H5Pget_external(dcpl, 0, sizeof(name), name, &file_offset, &file_size) < 0) From 3367a6bbe27155a1c9ce822089528499d750a051 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 5 Nov 2024 08:10:17 -0800 Subject: [PATCH 02/11] Fix cast warnings from HDoff_t --> haddr_t change --- src/H5Oefl.c | 6 +++--- src/H5Oprivate.h | 2 +- src/H5Pdcpl.c | 2 +- tools/lib/h5tools_dump.c | 4 ++-- tools/src/h5ls/h5ls.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/H5Oefl.c b/src/H5Oefl.c index ea3c8b2754d..2f913179c2d 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -145,7 +145,7 @@ H5O__efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED for (size_t u = 0; u < mesg->nused; u++) { - hsize_t offset = 0; + haddr_t offset = 0; /* Name */ if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_size(f), p_end)) @@ -163,8 +163,8 @@ H5O__efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED /* File offset */ if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_size(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5F_DECODE_LENGTH(f, p, offset); /* Decode into an hsize_t to avoid sign warnings */ - mesg->slot[u].offset = (HDoff_t)offset; + H5F_DECODE_LENGTH(f, p, offset); + mesg->slot[u].offset = offset; /* Size */ if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_size(f), p_end)) diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index b50f7c315be..0c3e1470553 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -379,7 +379,7 @@ typedef struct H5O_link_t { typedef struct H5O_efl_entry_t { size_t name_offset; /*offset of name within heap */ char *name; /*malloc'd name */ - HDoff_t offset; /*offset of data within file */ + haddr_t offset; /*offset of data within file */ hsize_t size; /*size allocated within file */ } H5O_efl_entry_t; diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index cc40c070051..78fa4605f50 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1549,7 +1549,7 @@ H5P__dcrt_ext_file_list_dec(const void **_pp, void *_value) enc_size = *(*pp)++; assert(enc_size < 256); UINT64DECODE_VAR(*pp, enc_value, enc_size); - efl->slot[u].offset = (HDoff_t)enc_value; + efl->slot[u].offset = enc_value; /* Decode size */ enc_size = *(*pp)++; diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 6c9a1cfd0ef..1acf6b9dfcf 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -3190,7 +3190,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_context_t * H5D_layout_t stl = H5D_LAYOUT_ERROR; size_t ncols = 80; /* available output width */ size_t cd_nelmts; /* filter client number of values */ - HDoff_t offset; /* offset of external file */ + haddr_t offset; /* offset of external file */ char f_name[256]; /* filter name */ char name[256]; /* external or virtual file name */ hsize_t chsize[64]; /* chunk size in elements */ @@ -3346,7 +3346,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_context_t * * way to print off_t values. There's no real standard for off_t other * than it must be signed, according to POSIX. */ - h5tools_str_append(&buffer, " OFFSET %lld", (long long)offset); + h5tools_str_append(&buffer, " OFFSET %"PRIuHADDR"", offset); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); } diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index 992d412f368..0402c0117d6 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -1911,7 +1911,7 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) size_t cd_num; /* filter client data counter */ char f_name[256]; /* filter/file name */ char s[64]; /* temporary string buffer */ - HDoff_t f_offset; /* offset in external file */ + haddr_t f_offset; /* offset in external file */ hsize_t f_size; /* bytes used in external file */ hsize_t total, used; /* total size or offset */ int ndims; /* dimensionality */ From a2dcafeff130f42a0c98dc7d2f287e4bde225c94 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 5 Nov 2024 09:16:22 -0800 Subject: [PATCH 03/11] Moved HDoff_t back to H5private.h --- release_docs/RELEASE.txt | 7 +------ src/H5FDstdio.c | 40 +++++++++++++++++++++++++--------------- src/H5private.h | 10 ++++++++++ src/H5public.h | 16 ---------------- 4 files changed, 36 insertions(+), 37 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 83d72f69c5c..2e104db83de 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -353,18 +353,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 uses haddr_t, 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. - There is no API compatibility wrapper for this change. Fixes GitHub issue #3506 diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 611ae554ba4..25d5ea5728f 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -121,26 +121,36 @@ typedef struct H5FD_stdio_t { /* Platform-independent names for some file-oriented functions */ +/* off_t exists on Windows, but is always a 32-bit long, even on 64-bit Windows, + * so on Windows we define my_off_t to be int64_t, which is equivalent to __int64, + * the type of the st_size field of the _stati64 struct. + */ +#ifdef H5_HAVE_WIN32_API +typedef int64_t my_off_t; +#else +typedef off_t my_off_t; +#endif + #ifdef H5_HAVE_WIN32_API /* Windows and MinGW */ -#define file_ftell _ftelli64 +#define my_ftell _ftelli64 #else /* Everyone else */ -#define file_ftell ftello +#define my_ftell ftello #endif #if defined(H5_HAVE_WIN32_API) && !defined(H5_HAVE_MINGW) /* Windows (but NOT MinGW) */ -#define file_fseek _fseeki64 -#define file_ftruncate _chsize_s +#define my_fseek _fseeki64 +#define my_ftruncate _chsize_s #else /* Everyone else */ -#define file_fseek fseeko -#define file_ftruncate ftruncate +#define my_fseek fseeko +#define my_ftruncate ftruncate #endif /* These macros check for overflow of various quantities. These macros - * assume that HDoff_t is signed and haddr_t and size_t are unsigned. + * assume that my_off_t is signed and haddr_t and size_t are unsigned. * * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' * is too large to be represented by the second argument @@ -153,11 +163,11 @@ typedef struct H5FD_stdio_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(my_off_t) - 1)) - 1) #define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) #define REGION_OVERFLOW(A, Z) \ - (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (my_off_t)((A) + (Z)) < (my_off_t)(A)) /* Prototypes */ static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); @@ -309,7 +319,7 @@ H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr #endif /* H5_HAVE_WIN32_API */ /* Sanity check on file offsets */ - assert(sizeof(HDoff_t) >= sizeof(size_t)); + assert(sizeof(my_off_t) >= sizeof(size_t)); /* Quiet compiler */ (void)fapl_id; @@ -374,11 +384,11 @@ H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr file->op = H5FD_STDIO_OP_SEEK; file->pos = HADDR_UNDEF; file->write_access = write_access; /* Note the write_access for later */ - if (file_fseek(file->fp, 0, SEEK_END) < 0) { + if (my_fseek(file->fp, 0, SEEK_END) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; } else { - HDoff_t x = file_ftell(file->fp); + my_off_t x = my_ftell(file->fp); assert(x >= 0); file->eof = (haddr_t)x; } @@ -764,7 +774,7 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl /* Seek to the correct file position. */ if (!(file->op == H5FD_STDIO_OP_READ || file->op == H5FD_STDIO_OP_SEEK) || file->pos != addr) { - if (file_fseek(file->fp, (HDoff_t)addr, SEEK_SET) < 0) { + if (my_fseek(file->fp, (my_off_t)addr, SEEK_SET) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(__func__, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); @@ -855,7 +865,7 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp /* Seek to the correct file position. */ if ((file->op != H5FD_STDIO_OP_WRITE && file->op != H5FD_STDIO_OP_SEEK) || file->pos != addr) { - if (file_fseek(file->fp, (HDoff_t)addr, SEEK_SET) < 0) { + if (my_fseek(file->fp, (my_off_t)addr, SEEK_SET) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(__func__, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); @@ -1011,7 +1021,7 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, bool /*UNUSED*/ clo rewind(file->fp); /* Truncate file to proper length */ - if (-1 == file_ftruncate(file->fd, (HDoff_t)file->eoa)) + if (-1 == my_ftruncate(file->fd, (my_off_t)file->eoa)) H5Epush_ret(__func__, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to truncate/extend file properly", -1); #endif /* H5_HAVE_WIN32_API */ diff --git a/src/H5private.h b/src/H5private.h index cff6b37390c..55853fc771a 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -591,6 +591,16 @@ typedef double _Complex H5_double_complex; typedef long double _Complex H5_ldouble_complex; #endif +/* off_t exists on Windows, but is always a 32-bit long, even on 64-bit Windows, + * so on Windows we define HDoff_t to be int64_t, which is equivalent to __int64, + * the type of the st_size field of the _stati64 struct. + */ +#ifdef H5_HAVE_WIN32_API +typedef int64_t HDoff_t; +#else +typedef off_t HDoff_t; +#endif + /* __int64 is the correct type for the st_size field of the _stati64 * struct on Windows (MSDN isn't very clear about this). POSIX systems use * off_t. Both of these are typedef'd to HDoff_t in H5public.h. diff --git a/src/H5public.h b/src/H5public.h index 62e0db9764b..8e5d946fec3 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -300,22 +300,6 @@ typedef long long ssize_t; */ typedef uint64_t hsize_t; -/* off_t exists on Windows, but is always a 32-bit long, even on 64-bit Windows, - * so on Windows we define HDoff_t to be int64_t, which is equivalent to __int64, - * the type of the st_size field of the _stati64 struct. - */ -#ifdef H5_HAVE_WIN32_API -/** - * Platform-independent offset - */ -typedef int64_t HDoff_t; -#else -/** - * Platform-independent offset - */ -typedef off_t HDoff_t; -#endif - #ifdef H5_HAVE_PARALLEL #define HSIZE_AS_MPI_TYPE MPI_UINT64_T #endif From d9707835af48515a274fde97202d47663362f4e3 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 5 Nov 2024 11:13:31 -0800 Subject: [PATCH 04/11] Fix additional warnings --- src/H5Defl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/H5Defl.c b/src/H5Defl.c index 7f25e69d92c..f9c98d2c118 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -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); @@ -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); From c842d0c6d2e670bf8e3b6175db2d51952173e340 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 22:50:13 +0000 Subject: [PATCH 05/11] Committing clang-format changes --- src/H5FDstdio.c | 3 ++- tools/lib/h5tools_dump.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 25d5ea5728f..185d969d78d 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -167,7 +167,8 @@ typedef off_t my_off_t; #define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) #define REGION_OVERFLOW(A, Z) \ - (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (my_off_t)((A) + (Z)) < (my_off_t)(A)) + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || \ + (my_off_t)((A) + (Z)) < (my_off_t)(A)) /* Prototypes */ static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 1acf6b9dfcf..58ad5fdae81 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -3346,7 +3346,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_context_t * * way to print off_t values. There's no real standard for off_t other * than it must be signed, according to POSIX. */ - h5tools_str_append(&buffer, " OFFSET %"PRIuHADDR"", offset); + h5tools_str_append(&buffer, " OFFSET %" PRIuHADDR "", offset); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); } From 9d821697cbdb341dc9fce9b7abdfa342d8230fd1 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 7 Nov 2024 14:53:12 -0800 Subject: [PATCH 06/11] Improve entry in RELEASE.txt --- release_docs/RELEASE.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 2689d30172e..073118b0a83 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -360,12 +360,12 @@ New Features developers who wish to provide an ID for their driver should create a routine specific to their individual implementation. - - H5P(set|get)_external() now uses haddr_t, which is always a 64-bit type + - H5P(set|get)_external() now use haddr_t, 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. + 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. From 70ee459b96db34da29c7b33819a6711d6eb945dc Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 7 Nov 2024 23:42:34 -0800 Subject: [PATCH 07/11] Update wrappers with HDoff_t --> haddr_t changes --- c++/src/C2Cppfunction_map.htm | 4 ++-- c++/src/H5DcreatProp.cpp | 8 ++++---- c++/src/H5DcreatProp.h | 4 ++-- fortran/src/H5Pf.c | 12 ++++++------ fortran/src/H5Pff.F90 | 18 ++++++------------ fortran/src/H5f90proto.h | 4 ++-- fortran/src/H5match_types.c | 11 ----------- fortran/test/tH5P.F90 | 4 ++-- fortran/test/tH5P_F03.F90 | 8 ++++---- java/src/jni/h5pDCPLImp.c | 6 +++--- tools/lib/h5tools_dump.c | 4 ---- tools/src/misc/h5repart.c | 2 +- 12 files changed, 32 insertions(+), 53 deletions(-) diff --git a/c++/src/C2Cppfunction_map.htm b/c++/src/C2Cppfunction_map.htm index 4ea67544efe..deb0d157a0a 100644 --- a/c++/src/C2Cppfunction_map.htm +++ b/c++/src/C2Cppfunction_map.htm @@ -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'>

void DSetCreatPropList::setExternal(const char* name, HDoff_t offset, + normal'>void DSetCreatPropList::setExternal(const char* name, haddr_t offset, hsize_t size)

void DSetCreatPropList::getExternal(unsigned idx, size_t name_size, - char* name, HDoff_t& offset, hsize_t& size)

+ char* name, haddr_t& offset, hsize_t& size)

Date: Fri, 8 Nov 2024 07:44:47 +0000 Subject: [PATCH 08/11] Committing clang-format changes --- fortran/src/H5f90proto.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h index 8631b2b5af6..51e4c42ac99 100644 --- a/fortran/src/H5f90proto.h +++ b/fortran/src/H5f90proto.h @@ -430,8 +430,8 @@ H5_FCDLL int_f h5pget_filter_by_id_c(hid_t_f *prp_id, int_f *filter_id, int_f *f 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, haddr_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); From 0103a602d678c22b6c11c56fdf12d9a0c42cde07 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 7 Nov 2024 23:49:53 -0800 Subject: [PATCH 09/11] Update RELEASE.txt note --- release_docs/RELEASE.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 073118b0a83..6610ac5300b 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -360,7 +360,8 @@ New Features developers who wish to provide an ID for their driver should create a routine specific to their individual implementation. - - H5P(set|get)_external() now use haddr_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 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 From 76030811a8045ae9cf80d5424b887f5a9e9688e2 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 7 Nov 2024 23:55:40 -0800 Subject: [PATCH 10/11] Missed an OFF_T in the examples --- HDF5Examples/FORTRAN/H5D/h5ex_d_extern.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HDF5Examples/FORTRAN/H5D/h5ex_d_extern.F90 b/HDF5Examples/FORTRAN/H5D/h5ex_d_extern.F90 index e44fdf0c2a9..d8e90103f7f 100644 --- a/HDF5Examples/FORTRAN/H5D/h5ex_d_extern.F90 +++ b/HDF5Examples/FORTRAN/H5D/h5ex_d_extern.F90 @@ -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 From e477946563cc53addf2614f583c893fe05070d35 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 8 Nov 2024 07:43:03 -0800 Subject: [PATCH 11/11] Fix comment in H5private.h --- src/H5private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5private.h b/src/H5private.h index 55853fc771a..43ea4f6b696 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -603,7 +603,7 @@ typedef off_t HDoff_t; /* __int64 is the correct type for the st_size field of the _stati64 * struct on Windows (MSDN isn't very clear about this). POSIX systems use - * off_t. Both of these are typedef'd to HDoff_t in H5public.h. + * off_t. Both of these are typedef'd to HDoff_t (above). */ typedef HDoff_t h5_stat_size_t;