Skip to content

Commit

Permalink
Merge remote-tracking branch 'canonical/develop' into off_t_2_haddr_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Dana Robinson committed Nov 8, 2024
2 parents 7603081 + faec68f commit 5e8f558
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 233 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,9 @@ jobs:
uses: ./.github/workflows/msys2-cmake.yml
with:
build_mode: "Release"

call-release-cmake-i386:
name: "CMake i386 Workflows"
uses: ./.github/workflows/i386-cmake.yml
with:
build_mode: "Release"
67 changes: 67 additions & 0 deletions .github/workflows/i386-cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: hdf5 dev CMake i386

# Triggers the workflow on a call from another workflow
on:
workflow_call:
inputs:
build_mode:
description: "release vs. debug build"
required: true
type: string

permissions:
contents: read

jobs:
i386_build_and_test:
name: "i386 ${{ inputs.build_mode }}"
runs-on: ubuntu-latest
steps:
- name: Get Sources
uses: actions/[email protected]

- name: setup alpine
uses: jirutka/setup-alpine@v1
with:
arch: x86
packages: >
build-base
libaec-dev
libgit2-dev
cmake
- name: CMake Configure
shell: alpine.sh --root {0}
run: |
mkdir build
cd build
cmake -C ../config/cmake/cacheinit.cmake -G "Unix Makefiles" \
--log-level=VERBOSE \
-DCMAKE_BUILD_TYPE=${{ inputs.build_mode }} \
-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF \
-DHDF5_BUILD_CPP_LIB:BOOL=OFF \
-DLIBAEC_USE_LOCALCONTENT:BOOL=OFF \
-DZLIB_USE_LOCALCONTENT:BOOL=OFF \
-DHDF5_BUILD_FORTRAN:BOOL=OFF \
-DHDF5_BUILD_JAVA:BOOL=OFF \
-DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=OFF \
..
- name: CMake Build
shell: alpine.sh --root {0}
run: |
cmake --build . --parallel 3 --config ${{ inputs.build_mode }}
working-directory: build

- name: CMake Run Tests
shell: alpine.sh --root {0}
run: |
ctest . -E H5_H5DUMP-h5ex_table_11 --parallel 2 -C ${{ inputs.build_mode }} -VV
working-directory: build

- name: CMake Run Expected To Fail Tests
shell: alpine.sh --root {0}
run: |
ctest . -R H5_H5DUMP-h5ex_table_11 --parallel 2 -C ${{ inputs.build_mode }} -V
working-directory: build
continue-on-error: true
52 changes: 52 additions & 0 deletions .github/workflows/main-cmake-spc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -559,3 +559,55 @@ jobs:
- name: CMake Build
run: cmake --build . --parallel 3 --config Release
working-directory: ${{ runner.workspace }}/build

test-cmake-minimum:
runs-on: ubuntu-latest
steps:
- name: Install Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install ninja-build doxygen graphviz
sudo apt install libssl3 libssl-dev libcurl4 libcurl4-openssl-dev
sudo apt install gcc-12 g++-12 gfortran-12
echo "CC=gcc-12" >> $GITHUB_ENV
echo "CXX=g++-12" >> $GITHUB_ENV
echo "FC=gfortran-12" >> $GITHUB_ENV
- uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.18

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Get Sources
uses: actions/[email protected]

# CMAKE CONFIGURE
- name: CMake Configure
run: |
mkdir "${{ runner.workspace }}/build"
cd "${{ runner.workspace }}/build"
cmake -C $GITHUB_WORKSPACE/config/cmake/cacheinit.cmake \
-G Ninja \
--log-level=VERBOSE \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_SHARED_LIBS=ON \
-DHDF5_ENABLE_ALL_WARNINGS=ON \
-DHDF5_ENABLE_WARNINGS_AS_ERRORS=ON \
-DHDF5_ENABLE_PARALLEL:BOOL=OFF \
-DHDF5_BUILD_CPP_LIB:BOOL=ON \
-DHDF5_BUILD_FORTRAN=OFF \
-DHDF5_BUILD_JAVA=ON \
-DHDF5_BUILD_DOC=OFF \
-DLIBAEC_USE_LOCALCONTENT=OFF \
-DZLIB_USE_LOCALCONTENT=OFF \
-DHDF5_ENABLE_MIRROR_VFD:BOOL=ON \
-DHDF5_ENABLE_DIRECT_VFD:BOOL=ON \
-DHDF5_ENABLE_ROS3_VFD:BOOL=ON \
$GITHUB_WORKSPACE
shell: bash

# BUILD
- name: CMake Build
run: cmake --build . --parallel 3 --config Release
working-directory: ${{ runner.workspace }}/build

35 changes: 18 additions & 17 deletions src/H5FDcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,22 @@ typedef struct H5FD_core_fapl_t {
/* These macros check for overflow of various quantities. These macros
* assume that file_offset_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
* of the file seek function.
* CORE_ADDR_OVERFLOW: Checks whether a file address of type `haddr_t'
* is too large to be represented by the second argument
* of the file seek function.
*
* SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
* large to be represented by the `size_t' type.
* CORE_SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
* large to be represented by the `size_t' type.
*
* REGION_OVERFLOW: Checks whether an address and size pair describe data
* which can be addressed entirely in memory.
* CORE_REGION_OVERFLOW: Checks whether an address and size pair describe data
* which can be addressed entirely in memory.
*/
#define MAXADDR ((haddr_t)((~(size_t)0) - 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) || (size_t)((A) + (Z)) < (size_t)(A))
#define CORE_MAXADDR ((haddr_t)((~(size_t)0) - 1))
#define CORE_ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || (A) > (haddr_t)CORE_MAXADDR)
#define CORE_SIZE_OVERFLOW(Z) ((Z) > (hsize_t)CORE_MAXADDR)
#define CORE_REGION_OVERFLOW(A, Z) \
(CORE_ADDR_OVERFLOW(A) || CORE_SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || \
(size_t)((A) + (Z)) < (size_t)(A))

/* Prototypes */
static herr_t H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end);
Expand Down Expand Up @@ -147,7 +148,7 @@ static const H5FD_class_t H5FD_core_g = {
H5FD_CLASS_VERSION, /* struct version */
H5FD_CORE_VALUE, /* value */
"core", /* name */
MAXADDR, /* maxaddr */
CORE_MAXADDR, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
NULL, /* terminate */
NULL, /* sb_size */
Expand Down Expand Up @@ -707,7 +708,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
if (0 == maxaddr || HADDR_UNDEF == maxaddr)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if (ADDR_OVERFLOW(maxaddr))
if (CORE_ADDR_OVERFLOW(maxaddr))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow");
assert(H5P_DEFAULT != fapl_id);
if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
Expand Down Expand Up @@ -1155,7 +1156,7 @@ H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr)

FUNC_ENTER_PACKAGE

if (ADDR_OVERFLOW(addr))
if (CORE_ADDR_OVERFLOW(addr))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow");

file->eoa = addr;
Expand Down Expand Up @@ -1271,7 +1272,7 @@ H5FD__core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
/* Check for overflow conditions */
if (HADDR_UNDEF == addr)
HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
if (REGION_OVERFLOW(addr, size))
if (CORE_REGION_OVERFLOW(addr, size))
HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");

/* Read the part which is before the EOF marker */
Expand Down Expand Up @@ -1325,7 +1326,7 @@ H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN
assert(buf);

/* Check for overflow conditions */
if (REGION_OVERFLOW(addr, size))
if (CORE_REGION_OVERFLOW(addr, size))
HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");

/*
Expand Down
29 changes: 4 additions & 25 deletions src/H5FDdirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,6 @@ typedef struct H5FD_direct_t {

} H5FD_direct_t;

/*
* These macros check for overflow of various quantities. These macros
* assume that HDoff_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
* of the file seek function.
*
* SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
* large to be represented by the `size_t' type.
*
* REGION_OVERFLOW: Checks whether an address and size pair describe data
* 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 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))

/* Prototypes */
static herr_t H5FD__direct_populate_config(size_t boundary, size_t block_size, size_t cbuf_size,
H5FD_direct_fapl_t *fa_out);
Expand All @@ -137,7 +116,7 @@ static const H5FD_class_t H5FD_direct_g = {
H5FD_CLASS_VERSION, /* struct version */
H5FD_DIRECT_VALUE, /* value */
"direct", /* name */
MAXADDR, /* maxaddr */
H5FD_MAXADDR, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
NULL, /* terminate */
NULL, /* sb_size */
Expand Down Expand Up @@ -436,7 +415,7 @@ H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
if (0 == maxaddr || HADDR_UNDEF == maxaddr)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if (ADDR_OVERFLOW(maxaddr))
if (H5FD_ADDR_OVERFLOW(maxaddr))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr");

/* Build the open flags */
Expand Down Expand Up @@ -818,7 +797,7 @@ H5FD__direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U
/* Check for overflow conditions */
if (HADDR_UNDEF == addr)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
if (REGION_OVERFLOW(addr, size))
if (H5FD_REGION_OVERFLOW(addr, size))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");

/* If the system doesn't require data to be aligned, read the data in
Expand Down Expand Up @@ -998,7 +977,7 @@ H5FD__direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_
/* Check for overflow conditions */
if (HADDR_UNDEF == addr)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
if (REGION_OVERFLOW(addr, size))
if (H5FD_REGION_OVERFLOW(addr, size))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");

/* If the system doesn't require data to be aligned, read the data in
Expand Down
17 changes: 2 additions & 15 deletions src/H5FDhdfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,6 @@ typedef struct H5FD_hdfs_t {
#endif
} H5FD_hdfs_t;

/*
* These macros check for overflow of various quantities. These macros
* assume that HDoff_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
* of the file seek function.
* Only included if HDFS code should compile.
*
*/
#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1)
#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR))

/* Prototypes */
static void *H5FD__hdfs_fapl_get(H5FD_t *_file);
static void *H5FD__hdfs_fapl_copy(const void *_old_fa);
Expand All @@ -267,7 +254,7 @@ static const H5FD_class_t H5FD_hdfs_g = {
H5FD_CLASS_VERSION, /* struct version */
H5FD_HDFS_VALUE, /* value */
"hdfs", /* name */
MAXADDR, /* maxaddr */
H5FD_MAXADDR, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
NULL, /* terminate */
NULL, /* sb_size */
Expand Down Expand Up @@ -840,7 +827,7 @@ H5FD__hdfs_open(const char *path, unsigned flags, hid_t fapl_id, haddr_t maxaddr
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
if (0 == maxaddr || HADDR_UNDEF == maxaddr)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if (ADDR_OVERFLOW(maxaddr))
if (H5FD_ADDR_OVERFLOW(maxaddr))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr");
if (flags != H5F_ACC_RDONLY)
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, "only Read-Only access allowed");
Expand Down
29 changes: 4 additions & 25 deletions src/H5FDlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,27 +129,6 @@ typedef struct H5FD_log_t {
H5FD_log_fapl_t fa; /* Driver-specific file access properties */
} H5FD_log_t;

/*
* These macros check for overflow of various quantities. These macros
* assume that HDoff_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
* of the file seek function.
*
* SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too
* large to be represented by the `size_t' type.
*
* REGION_OVERFLOW: Checks whether an address and size pair describe data
* 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 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))

/* Prototypes */
static void *H5FD__log_fapl_get(H5FD_t *file);
static void *H5FD__log_fapl_copy(const void *_old_fa);
Expand Down Expand Up @@ -177,7 +156,7 @@ static const H5FD_class_t H5FD_log_g = {
H5FD_CLASS_VERSION, /* struct version */
H5FD_LOG_VALUE, /* value */
"log", /* name */
MAXADDR, /* maxaddr */
H5FD_MAXADDR, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
NULL, /* terminate */
NULL, /* sb_size */
Expand Down Expand Up @@ -450,7 +429,7 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
if (0 == maxaddr || HADDR_UNDEF == maxaddr)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if (ADDR_OVERFLOW(maxaddr))
if (H5FD_ADDR_OVERFLOW(maxaddr))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr");

/* Initialize timers */
Expand Down Expand Up @@ -1120,7 +1099,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had
/* Check for overflow conditions */
if (!H5_addr_defined(addr))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr);
if (REGION_OVERFLOW(addr, size))
if (H5FD_REGION_OVERFLOW(addr, size))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr);

/* Log the I/O information about the read */
Expand Down Expand Up @@ -1344,7 +1323,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha
/* Check for overflow conditions */
if (!H5_addr_defined(addr))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr);
if (REGION_OVERFLOW(addr, size))
if (H5FD_REGION_OVERFLOW(addr, size))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu",
(unsigned long long)addr, (unsigned long long)size);

Expand Down
Loading

0 comments on commit 5e8f558

Please sign in to comment.