From 7bbe45e71d74b342aadd086ac9174414542b2063 Mon Sep 17 00:00:00 2001 From: vchoi Date: Mon, 6 Jun 2022 22:27:40 -0500 Subject: Fixes for: (1) H5O_refresh_metadata(): address failure when make check-passthrough-vol: use H5VL_object_data() to retrieve the vol object. (2) H5FD__vfd_swmr_open(): use HADDR_UNDEF as maxaddr when opening the underlying hdf5 file; otherwise it will casue problem when the hdf5 file is opened with the core driver. (3) src/H5Fvfd_swmr.c and vfd swmr tests: --Use long long for constant define in H5Fvfd_swmr.c and when snprintf the updater file's sequence number --Modify test/vfd_swmr.c to accommodate endianness of machine and also long long for sequence number --Modify vfd_swmr_bigset_writer.c, vfd_swmr_common.c, vfd_swmr_gfail_writer.c, vfd_swmr_gperf_writer.c to use long long for constant define --- src/H5FDvfd_swmr.c | 2 +- src/H5Fvfd_swmr.c | 6 +-- src/H5Oflush.c | 6 ++- test/vfd_swmr.c | 104 +++++++++++++++++++++++++++++++++--------- test/vfd_swmr_bigset_writer.c | 4 +- test/vfd_swmr_common.c | 12 ++--- test/vfd_swmr_gfail_writer.c | 2 +- test/vfd_swmr_gperf_writer.c | 2 +- 8 files changed, 100 insertions(+), 38 deletions(-) diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c index a8f588d..9846330 100644 --- a/src/H5FDvfd_swmr.c +++ b/src/H5FDvfd_swmr.c @@ -688,7 +688,7 @@ H5FD__vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t max /* Hard-wired to open the underlying HDF5 file with SEC2 */ /* H5FD_SEC2 is the default driver for H5P_FILE_ACCESS_DEFAULT except when the environment variable HDF5_DRIVER is set to otherwise */ - if ((file->hdf5_file_lf = H5FD_open(name, flags, H5P_FILE_ACCESS_DEFAULT, maxaddr)) == NULL) + if ((file->hdf5_file_lf = H5FD_open(name, flags, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF)) == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "can't set driver info"); /* set pb_configured to FALSE. This field should not exist, but diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index 702c362..5608f5a 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -50,8 +50,8 @@ /****************/ #define VFD_SWMR_MD_FILE_SUFFIX ".md" -#define NANOSECS_PER_SECOND 1000000000 /* nanoseconds per second */ -#define NANOSECS_PER_TENTH_SEC 100000000 /* nanoseconds per 0.1 second */ +#define NANOSECS_PER_SECOND 1000000000LL /* nanoseconds per second */ +#define NANOSECS_PER_TENTH_SEC 100000000LL /* nanoseconds per 0.1 second */ /* Declare an array of string to identify the VFD SMWR Log tags. * Note this array is used to generate the entry tag by the log reporting macro @@ -2405,7 +2405,7 @@ H5F__generate_updater_file(H5F_t *f, uint32_t num_entries, uint16_t flags, uint8 /* Close the updater file and rename the file */ if (H5FD_close(ud_file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close updater file") - sz = HDsnprintf(newname, H5F__MAX_VFD_SWMR_FILE_NAME_LEN, "%s.%lu", + sz = HDsnprintf(newname, H5F__MAX_VFD_SWMR_FILE_NAME_LEN, "%s.%llu", shared->vfd_swmr_config.updater_file_path, shared->updater_seq_num); if (sz < 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "error processing snprintf format string") diff --git a/src/H5Oflush.c b/src/H5Oflush.c index 870da13..0153534 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -207,8 +207,9 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid) H5O_loc_t obj_oloc; H5G_name_t obj_path; H5O_refresh_state_t state; - H5D_t * ds; + const H5D_t * ds; const H5VL_object_t *vol_obj; + const void *object; H5VL_t * connector = NULL; /* Create empty object location */ @@ -237,7 +238,8 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to save datatype state"); break; case H5I_DATASET: - ds = (H5D_t *)vol_obj->data; + object = H5VL_object_data(vol_obj); + ds = (const H5D_t *)object; state.dapl_id = ds->shared->dapl_id; if (H5I_inc_ref(state.dapl_id, FALSE) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not increase refcnt"); diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c index e3149f2..16efaed 100644 --- a/test/vfd_swmr.c +++ b/test/vfd_swmr.c @@ -95,6 +95,18 @@ static const char *namebases[] = {FILENAME, FILENAME2, FILENAME3, FNAME, NULL}; /* Size of "flags" field in the updater file header */ #define UD_SIZE_2 2 +#define Swap2Bytes(val) \ + ( (((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00) ) + +#define Swap8Bytes(val) \ + ( (((val) >> 56) & 0x00000000000000FF) | (((val) >> 40) & 0x000000000000FF00) | \ + (((val) >> 24) & 0x0000000000FF0000) | (((val) >> 8) & 0x00000000FF000000) | \ + (((val) << 8) & 0x000000FF00000000) | (((val) << 24) & 0x0000FF0000000000) | \ + (((val) << 40) & 0x00FF000000000000) | (((val) << 56) & 0xFF00000000000000) ) +#define Swap4Bytes(val) \ + ( (((val) >> 24) & 0x000000FF) | (((val) >> 8) & 0x0000FF00) | \ + (((val) << 8) & 0x00FF0000) | (((val) << 24) & 0xFF000000) ) + /* test routines for VFD SWMR */ static unsigned test_fapl(hid_t orig_fapl); static unsigned test_file_fapl(hid_t orig_fapl); @@ -131,10 +143,36 @@ static void clean_chk_ud_files(char *md_file_path, char *updater_file_path); static herr_t verify_ud_chk(char *md_file_path, char *ud_file_path); static herr_t md_ck_cb(char *md_file_path, uint64_t tick_num); +void check_endian(hbool_t *little_endian); +static int vfd_swmr_fapl_augment(hid_t fapl, bool use_latest_format, bool only_meta_pages, + size_t page_buf_size, H5F_vfd_swmr_config_t *config); + +/*------------------------------------------------------------------------- + * + * Function check_endian() + * Helper routine to check the endianness of a machine + * + * ------------------------------------------------------------------------- + */ +void +check_endian(hbool_t *little_endian) +{ + short int word = 0x0001; + char * byte = (char *)&word; + + if (byte[0] == 1) + /* little endian */ + *little_endian = TRUE; + else + /* big endian */ + *little_endian = FALSE; + +} /* check_endian() */ + /*------------------------------------------------------------------------- * * Function vfd_swmr_fapl_augment() - * A Helper routine to set up fapl for VFD SWMR + * Helper routine to set up fapl for VFD SWMR * *------------------------------------------------------------------------- */ @@ -985,7 +1023,7 @@ test_writer_create_open_flush(hid_t orig_fapl) /* config, tick_len, max_lag, presume_posix_semantics, writer, * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, * md_file_path, md_file_name, updater_file_path */ - init_vfd_swmr_config(my_config, 1, 3, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, MD_FILENAME, NULL); + init_vfd_swmr_config(my_config, 5, 10, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, MD_FILENAME, NULL); if ((fapl = H5Pcopy(orig_fapl)) < 0) FAIL_STACK_ERROR; @@ -4201,6 +4239,10 @@ verify_updater_flags(char *ud_name, uint16_t expected_flags) { FILE * ud_fp = NULL; /* Updater file pointer */ uint16_t flags = 0; /* The "flags" field in the updater file */ + uint16_t swapped_flags = 0; /* The "flags" field in the updater file */ + hbool_t little_endian = FALSE; /* Endianness of a machine */ + + check_endian(&little_endian); /* Open the updater file */ if ((ud_fp = HDfopen(ud_name, "r")) == NULL) @@ -4214,7 +4256,9 @@ verify_updater_flags(char *ud_name, uint16_t expected_flags) if (HDfread(&flags, UD_SIZE_2, 1, ud_fp) != (size_t)1) FAIL_STACK_ERROR; - if (flags != expected_flags) + swapped_flags = little_endian?flags:Swap2Bytes(flags); + + if (swapped_flags != expected_flags) TEST_ERROR; if (HDfclose(ud_fp) < 0) @@ -4310,7 +4354,7 @@ test_updater_flags(hid_t orig_fapl) TEST_ERROR; /* Verify the first updater file: "flags" field and file size */ - HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num); + HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num); /* Verify "flags" of the first updater file */ if (verify_updater_flags(namebuf, CREATE_METADATA_FILE_ONLY_FLAG) < 0) @@ -4326,11 +4370,11 @@ test_updater_flags(hid_t orig_fapl) /* Look for the last updater file */ for (seq_num = 0;; seq_num++) { - HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num); + HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num); if (HDaccess(namebuf, F_OK) != 0) break; } - HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num - 1); + HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num - 1); /* Verify "flags" of the last updater file */ if (verify_updater_flags(namebuf, FINAL_UPDATE_FLAG) < 0) @@ -4345,7 +4389,7 @@ test_updater_flags(hid_t orig_fapl) /* Remove updater files */ for (i = 0; i < seq_num; i++) { - HDsprintf(namebuf, "%s.%lu", UD_FILENAME, i); + HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, i); HDremove(namebuf); } @@ -4466,11 +4510,11 @@ test_updater_flags_same_file_opens(hid_t orig_fapl) /* Look for the last updater file */ for (seq_num = 0;; seq_num++) { - HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num); + HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num); if (HDaccess(namebuf, F_OK) != 0) break; } - HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num - 1); + HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num - 1); /* Verify "flags" of the last updater file is 0 */ if (verify_updater_flags(namebuf, 0) < 0) @@ -4482,11 +4526,11 @@ test_updater_flags_same_file_opens(hid_t orig_fapl) /* Look for the last updater file */ for (seq_num = 0;; seq_num++) { - HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num); + HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num); if (HDaccess(namebuf, F_OK) != 0) break; } - HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num - 1); + HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num - 1); /* Verify "flags" of the last updater file after closing file */ if (verify_updater_flags(namebuf, FINAL_UPDATE_FLAG) < 0) @@ -4494,7 +4538,7 @@ test_updater_flags_same_file_opens(hid_t orig_fapl) /* Clean up updater files */ for (i = 0; i < seq_num; i++) { - HDsprintf(namebuf, "%s.%lu", UD_FILENAME, i); + HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, i); HDremove(namebuf); } @@ -4553,7 +4597,7 @@ clean_chk_ud_files(char *md_file_path, char *updater_file_path) /* Remove all the updater files if exist: . */ for (i = 0;; i++) { - HDsprintf(ud_name, "%s.%lu", updater_file_path, i); + HDsprintf(ud_name, "%s.%" PRIu64 "", updater_file_path, i); if (HDaccess(ud_name, F_OK) != 0) break; HDremove(ud_name); @@ -4590,13 +4634,23 @@ verify_ud_chk(char *md_file_path, char *ud_file_path) char ud_name[FILE_NAME_LEN]; /* Updater file name */ FILE * chk_fp = NULL; /* Checksum file pointer */ FILE * ud_fp = NULL; /* Updater file pointer */ - uint64_t ud_seq_num = 0; /* Sequence number in the updater file */ - uint64_t chk_ud_seq_num = 0; /* Updater sequence number in the checksum file */ uint64_t i; /* Local index variable */ long size = 0; /* Size of the file */ - size_t change_list_len = 0; /* change_list_len in the updater file header */ + + uint64_t chk_ud_seq_num = 0; /* Updater sequence number in the checksum file */ + + uint64_t ud_seq_num = 0; /* Sequence number in the updater file */ + uint64_t change_list_len = 0; /* change_list_len in the updater file header */ uint32_t num_change_list_entries = 0; /* num_change_list_entries in the updater change list header */ + uint64_t swapped_ud_seq_num = 0; + uint64_t swapped_change_list_len = 0; + uint32_t swapped_num_change_list_entries = 0; + + hbool_t little_endian = FALSE; + + check_endian(&little_endian); + /* Open the checksum file */ HDsprintf(chk_name, "%s.chk", md_file_path); if ((chk_fp = HDfopen(chk_name, "r")) == NULL) @@ -4604,7 +4658,7 @@ verify_ud_chk(char *md_file_path, char *ud_file_path) for (i = 0;; i++) { /* Generate updater file name: . */ - HDsprintf(ud_name, "%s.%lu", ud_file_path, i); + HDsprintf(ud_name, "%s.%" PRIu64 "", ud_file_path, i); /* Open the updater file */ if ((ud_fp = HDfopen(ud_name, "r")) == NULL) @@ -4618,8 +4672,10 @@ verify_ud_chk(char *md_file_path, char *ud_file_path) if (HDfread(&ud_seq_num, UD_SIZE_8, 1, ud_fp) != 1) FAIL_STACK_ERROR; + swapped_ud_seq_num = little_endian?ud_seq_num:Swap8Bytes(ud_seq_num); + /* Compare the sequence number with i */ - if (ud_seq_num != i) + if (swapped_ud_seq_num != i) TEST_ERROR; /* Read change_list_len from updater file's header */ @@ -4629,6 +4685,8 @@ verify_ud_chk(char *md_file_path, char *ud_file_path) if (HDfread(&change_list_len, UD_SIZE_8, 1, ud_fp) != 1) FAIL_STACK_ERROR; + swapped_change_list_len = little_endian?change_list_len:Swap8Bytes(change_list_len); + if (i != 0) { /* Read num_change_list_entries from updater file's change list */ @@ -4638,12 +4696,14 @@ verify_ud_chk(char *md_file_path, char *ud_file_path) if (HDfread(&num_change_list_entries, UD_SIZE_4, 1, ud_fp) != 1) FAIL_STACK_ERROR; - if (num_change_list_entries == 0) { - if (change_list_len != H5F_UD_CL_SIZE(0)) + swapped_num_change_list_entries = little_endian?num_change_list_entries:Swap4Bytes(num_change_list_entries); + + if (swapped_num_change_list_entries == 0) { + if (swapped_change_list_len != H5F_UD_CL_SIZE(0)) TEST_ERROR; } else { - if (change_list_len != H5F_UD_CL_SIZE(num_change_list_entries)) + if (swapped_change_list_len != H5F_UD_CL_SIZE(swapped_num_change_list_entries)) TEST_ERROR; } } @@ -4657,7 +4717,7 @@ verify_ud_chk(char *md_file_path, char *ud_file_path) FAIL_STACK_ERROR; /* Compare sequence number in updater file with sequence number in checksum file */ - if (ud_seq_num != chk_ud_seq_num) + if (swapped_ud_seq_num != chk_ud_seq_num) TEST_ERROR; /* Advance checksum file to the next sequence number */ diff --git a/test/vfd_swmr_bigset_writer.c b/test/vfd_swmr_bigset_writer.c index 6ff5d03..7d4c9d8 100644 --- a/test/vfd_swmr_bigset_writer.c +++ b/test/vfd_swmr_bigset_writer.c @@ -95,7 +95,7 @@ #define DEPTH 1 #define RANK2 2 #define RANK3 3 -#define NUM_ATTEMPTS 100 +#define NUM_ATTEMPTS 500 #define SKIP_CHUNK 0 /* Calculate the time passed in seconds. @@ -103,7 +103,7 @@ * Expects X, Y to be struct timespec from the function call HDclock_gettime. */ #define TIME_PASSED(X, Y) \ - ((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0 + ((double)(((uint64_t)Y.tv_sec - (uint64_t)X.tv_sec) * 1000000000LL + ((uint64_t)Y.tv_nsec - (uint64_t)X.tv_nsec))) / 1000000000.0 typedef struct _base { hsize_t depth, row, col; diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c index 1652ee5..0d4ae0c 100644 --- a/test/vfd_swmr_common.c +++ b/test/vfd_swmr_common.c @@ -46,8 +46,8 @@ below_speed_limit(struct timespec *last, const struct timespec *ival) struct timespec now; hbool_t result; - HDassert(0 <= last->tv_nsec && last->tv_nsec < 1000000000L); - HDassert(0 <= ival->tv_nsec && ival->tv_nsec < 1000000000L); + HDassert(0 <= last->tv_nsec && last->tv_nsec < 1000000000LL); + HDassert(0 <= ival->tv_nsec && ival->tv_nsec < 1000000000LL); /* NOTE: timespec_get() is C11. This may need further tweaks. */ #ifdef H5_HAVE_WIN32_API @@ -59,12 +59,12 @@ below_speed_limit(struct timespec *last, const struct timespec *ival) HDexit(EXIT_FAILURE); } - if (now.tv_sec - last->tv_sec > ival->tv_sec) + if ((uint64_t)now.tv_sec - (uint64_t)last->tv_sec > (uint64_t)ival->tv_sec) result = true; - else if (now.tv_sec - last->tv_sec < ival->tv_sec) + else if ((uint64_t)now.tv_sec - (uint64_t)last->tv_sec < (uint64_t)ival->tv_sec) result = false; else - result = (now.tv_nsec - last->tv_nsec >= ival->tv_nsec); + result = ((uint64_t)now.tv_nsec - (uint64_t)last->tv_nsec >= (uint64_t)ival->tv_nsec); if (result) *last = now; @@ -245,7 +245,7 @@ timer_function(void *arg) void await_signal(hid_t fid) { - struct timespec tick = {.tv_sec = 0, .tv_nsec = 1000000000 / 100}; + struct timespec tick = {.tv_sec = 0, .tv_nsec = 1000000000LL / 100}; sigset_t sleepset; if (HDsigfillset(&sleepset) == -1) { diff --git a/test/vfd_swmr_gfail_writer.c b/test/vfd_swmr_gfail_writer.c index 10370cc..8b8f00e 100644 --- a/test/vfd_swmr_gfail_writer.c +++ b/test/vfd_swmr_gfail_writer.c @@ -116,7 +116,7 @@ #ifndef H5_HAVE_WIN32_API #define TIME_PASSED(X, Y) \ - ((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0 + ((double)((Y.tv_sec - X.tv_sec) * 1000000000LL + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0 typedef struct { hid_t file, filetype, one_by_one_sid; diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index c376b51..88e8b6f 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -64,7 +64,7 @@ #define VS_ATTR_NAME_LEN 21 #define TIME_PASSED(X, Y) \ - ((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0 + ((double)((Y.tv_sec - X.tv_sec) * 1000000000LL + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0 typedef struct { hid_t file, filetype, one_by_one_sid; -- cgit v0.12 From a284ec5eceda9c39d94974e4636503e9c1ca740b Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 7 Jun 2022 03:31:55 +0000 Subject: Committing clang-format changes --- src/H5Oflush.c | 4 +-- test/vfd_swmr.c | 64 +++++++++++++++++++++---------------------- test/vfd_swmr_bigset_writer.c | 4 ++- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/H5Oflush.c b/src/H5Oflush.c index 0153534..f153fa2 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -209,7 +209,7 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid) H5O_refresh_state_t state; const H5D_t * ds; const H5VL_object_t *vol_obj; - const void *object; + const void * object; H5VL_t * connector = NULL; /* Create empty object location */ @@ -238,7 +238,7 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to save datatype state"); break; case H5I_DATASET: - object = H5VL_object_data(vol_obj); + object = H5VL_object_data(vol_obj); ds = (const H5D_t *)object; state.dapl_id = ds->shared->dapl_id; if (H5I_inc_ref(state.dapl_id, FALSE) < 0) diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c index 16efaed..a5b3e25 100644 --- a/test/vfd_swmr.c +++ b/test/vfd_swmr.c @@ -95,17 +95,16 @@ static const char *namebases[] = {FILENAME, FILENAME2, FILENAME3, FNAME, NULL}; /* Size of "flags" field in the updater file header */ #define UD_SIZE_2 2 -#define Swap2Bytes(val) \ - ( (((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00) ) - -#define Swap8Bytes(val) \ - ( (((val) >> 56) & 0x00000000000000FF) | (((val) >> 40) & 0x000000000000FF00) | \ - (((val) >> 24) & 0x0000000000FF0000) | (((val) >> 8) & 0x00000000FF000000) | \ - (((val) << 8) & 0x000000FF00000000) | (((val) << 24) & 0x0000FF0000000000) | \ - (((val) << 40) & 0x00FF000000000000) | (((val) << 56) & 0xFF00000000000000) ) -#define Swap4Bytes(val) \ - ( (((val) >> 24) & 0x000000FF) | (((val) >> 8) & 0x0000FF00) | \ - (((val) << 8) & 0x00FF0000) | (((val) << 24) & 0xFF000000) ) +#define Swap2Bytes(val) ((((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00)) + +#define Swap8Bytes(val) \ + ((((val) >> 56) & 0x00000000000000FF) | (((val) >> 40) & 0x000000000000FF00) | \ + (((val) >> 24) & 0x0000000000FF0000) | (((val) >> 8) & 0x00000000FF000000) | \ + (((val) << 8) & 0x000000FF00000000) | (((val) << 24) & 0x0000FF0000000000) | \ + (((val) << 40) & 0x00FF000000000000) | (((val) << 56) & 0xFF00000000000000)) +#define Swap4Bytes(val) \ + ((((val) >> 24) & 0x000000FF) | (((val) >> 8) & 0x0000FF00) | (((val) << 8) & 0x00FF0000) | \ + (((val) << 24) & 0xFF000000)) /* test routines for VFD SWMR */ static unsigned test_fapl(hid_t orig_fapl); @@ -143,9 +142,9 @@ static void clean_chk_ud_files(char *md_file_path, char *updater_file_path); static herr_t verify_ud_chk(char *md_file_path, char *ud_file_path); static herr_t md_ck_cb(char *md_file_path, uint64_t tick_num); -void check_endian(hbool_t *little_endian); +void check_endian(hbool_t *little_endian); static int vfd_swmr_fapl_augment(hid_t fapl, bool use_latest_format, bool only_meta_pages, - size_t page_buf_size, H5F_vfd_swmr_config_t *config); + size_t page_buf_size, H5F_vfd_swmr_config_t *config); /*------------------------------------------------------------------------- * @@ -4237,11 +4236,11 @@ error: static herr_t verify_updater_flags(char *ud_name, uint16_t expected_flags) { - FILE * ud_fp = NULL; /* Updater file pointer */ - uint16_t flags = 0; /* The "flags" field in the updater file */ - uint16_t swapped_flags = 0; /* The "flags" field in the updater file */ - hbool_t little_endian = FALSE; /* Endianness of a machine */ - + FILE * ud_fp = NULL; /* Updater file pointer */ + uint16_t flags = 0; /* The "flags" field in the updater file */ + uint16_t swapped_flags = 0; /* The "flags" field in the updater file */ + hbool_t little_endian = FALSE; /* Endianness of a machine */ + check_endian(&little_endian); /* Open the updater file */ @@ -4256,7 +4255,7 @@ verify_updater_flags(char *ud_name, uint16_t expected_flags) if (HDfread(&flags, UD_SIZE_2, 1, ud_fp) != (size_t)1) FAIL_STACK_ERROR; - swapped_flags = little_endian?flags:Swap2Bytes(flags); + swapped_flags = little_endian ? flags : Swap2Bytes(flags); if (swapped_flags != expected_flags) TEST_ERROR; @@ -4630,21 +4629,21 @@ clean_chk_ud_files(char *md_file_path, char *updater_file_path) static herr_t verify_ud_chk(char *md_file_path, char *ud_file_path) { - char chk_name[FILE_NAME_LEN]; /* Checksum file name */ - char ud_name[FILE_NAME_LEN]; /* Updater file name */ - FILE * chk_fp = NULL; /* Checksum file pointer */ - FILE * ud_fp = NULL; /* Updater file pointer */ - uint64_t i; /* Local index variable */ - long size = 0; /* Size of the file */ + char chk_name[FILE_NAME_LEN]; /* Checksum file name */ + char ud_name[FILE_NAME_LEN]; /* Updater file name */ + FILE * chk_fp = NULL; /* Checksum file pointer */ + FILE * ud_fp = NULL; /* Updater file pointer */ + uint64_t i; /* Local index variable */ + long size = 0; /* Size of the file */ - uint64_t chk_ud_seq_num = 0; /* Updater sequence number in the checksum file */ + uint64_t chk_ud_seq_num = 0; /* Updater sequence number in the checksum file */ - uint64_t ud_seq_num = 0; /* Sequence number in the updater file */ + uint64_t ud_seq_num = 0; /* Sequence number in the updater file */ uint64_t change_list_len = 0; /* change_list_len in the updater file header */ uint32_t num_change_list_entries = 0; /* num_change_list_entries in the updater change list header */ - uint64_t swapped_ud_seq_num = 0; - uint64_t swapped_change_list_len = 0; + uint64_t swapped_ud_seq_num = 0; + uint64_t swapped_change_list_len = 0; uint32_t swapped_num_change_list_entries = 0; hbool_t little_endian = FALSE; @@ -4672,7 +4671,7 @@ verify_ud_chk(char *md_file_path, char *ud_file_path) if (HDfread(&ud_seq_num, UD_SIZE_8, 1, ud_fp) != 1) FAIL_STACK_ERROR; - swapped_ud_seq_num = little_endian?ud_seq_num:Swap8Bytes(ud_seq_num); + swapped_ud_seq_num = little_endian ? ud_seq_num : Swap8Bytes(ud_seq_num); /* Compare the sequence number with i */ if (swapped_ud_seq_num != i) @@ -4685,7 +4684,7 @@ verify_ud_chk(char *md_file_path, char *ud_file_path) if (HDfread(&change_list_len, UD_SIZE_8, 1, ud_fp) != 1) FAIL_STACK_ERROR; - swapped_change_list_len = little_endian?change_list_len:Swap8Bytes(change_list_len); + swapped_change_list_len = little_endian ? change_list_len : Swap8Bytes(change_list_len); if (i != 0) { @@ -4696,7 +4695,8 @@ verify_ud_chk(char *md_file_path, char *ud_file_path) if (HDfread(&num_change_list_entries, UD_SIZE_4, 1, ud_fp) != 1) FAIL_STACK_ERROR; - swapped_num_change_list_entries = little_endian?num_change_list_entries:Swap4Bytes(num_change_list_entries); + swapped_num_change_list_entries = + little_endian ? num_change_list_entries : Swap4Bytes(num_change_list_entries); if (swapped_num_change_list_entries == 0) { if (swapped_change_list_len != H5F_UD_CL_SIZE(0)) diff --git a/test/vfd_swmr_bigset_writer.c b/test/vfd_swmr_bigset_writer.c index 7d4c9d8..4de9b70 100644 --- a/test/vfd_swmr_bigset_writer.c +++ b/test/vfd_swmr_bigset_writer.c @@ -103,7 +103,9 @@ * Expects X, Y to be struct timespec from the function call HDclock_gettime. */ #define TIME_PASSED(X, Y) \ - ((double)(((uint64_t)Y.tv_sec - (uint64_t)X.tv_sec) * 1000000000LL + ((uint64_t)Y.tv_nsec - (uint64_t)X.tv_nsec))) / 1000000000.0 + ((double)(((uint64_t)Y.tv_sec - (uint64_t)X.tv_sec) * 1000000000LL + \ + ((uint64_t)Y.tv_nsec - (uint64_t)X.tv_nsec))) / \ + 1000000000.0 typedef struct _base { hsize_t depth, row, col; -- cgit v0.12