diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2021-10-29 22:10:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 22:10:31 (GMT) |
commit | 111c7ae9ac2efc29e8b399e6951253af9110b81a (patch) | |
tree | f69fa03253bdab97d7cf3615baff02cd936323f9 /test/ttsafe_acreate.c | |
parent | db30c2da68ece4a155e9e50c28ec16d6057509b2 (diff) | |
download | hdf5-111c7ae9ac2efc29e8b399e6951253af9110b81a.zip hdf5-111c7ae9ac2efc29e8b399e6951253af9110b81a.tar.gz hdf5-111c7ae9ac2efc29e8b399e6951253af9110b81a.tar.bz2 |
Merge hdf5 1 10 8 (#1154)hdf5-1_10_8
Merge HDF5 1.10.8 release files to 1.10/master
Diffstat (limited to 'test/ttsafe_acreate.c')
-rw-r--r-- | test/ttsafe_acreate.c | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/test/ttsafe_acreate.c b/test/ttsafe_acreate.c index 5c08d09..c2c34a0 100644 --- a/test/ttsafe_acreate.c +++ b/test/ttsafe_acreate.c @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -35,17 +35,17 @@ #ifdef H5_HAVE_THREADSAFE -#define FILENAME "ttsafe_acreate.h5" -#define DATASETNAME "IntData" -#define NUM_THREADS 16 +#define FILENAME "ttsafe_acreate.h5" +#define DATASETNAME "IntData" +#define NUM_THREADS 16 void *tts_acreate_thread(void *); typedef struct acreate_data_struct { - hid_t dataset; - hid_t datatype; - hid_t dataspace; - int current_index; + hid_t dataset; + hid_t datatype; + hid_t dataspace; + int current_index; } ttsafe_name_data_t; void @@ -55,17 +55,17 @@ tts_acreate(void) H5TS_thread_t threads[NUM_THREADS]; /* HDF5 data declarations */ - hid_t file = H5I_INVALID_HID; - hid_t dataset = H5I_INVALID_HID; - hid_t dataspace = H5I_INVALID_HID; - hid_t datatype = H5I_INVALID_HID; - hid_t attribute = H5I_INVALID_HID; - hsize_t dimsf[1]; /* dataset dimensions */ + hid_t file = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t dataspace = H5I_INVALID_HID; + hid_t datatype = H5I_INVALID_HID; + hid_t attribute = H5I_INVALID_HID; + hsize_t dimsf[1]; /* dataset dimensions */ /* data declarations */ - int data; /* data to write */ - int buffer, i; - herr_t status; + int data; /* data to write */ + int buffer, i; + herr_t status; ttsafe_name_data_t *attrib_data; @@ -77,7 +77,7 @@ tts_acreate(void) CHECK(file, H5I_INVALID_HID, "H5Fcreate"); /* create a simple dataspace for the dataset */ - dimsf[0] = 1; + dimsf[0] = 1; dataspace = H5Screate_simple(1, dimsf, NULL); CHECK(dataspace, H5I_INVALID_HID, "H5Screate_simple"); @@ -92,7 +92,7 @@ tts_acreate(void) CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); /* initialize data for dataset and write value to dataset */ - data = NUM_THREADS; + data = NUM_THREADS; status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data); CHECK(status, FAIL, "H5Dwrite"); @@ -100,24 +100,24 @@ tts_acreate(void) * Simultaneously create a large number of attributes to be associated * with the dataset */ - for(i = 0; i < NUM_THREADS; i++) { - attrib_data = (ttsafe_name_data_t *)HDmalloc(sizeof(ttsafe_name_data_t)); - attrib_data->dataset = dataset; - attrib_data->datatype = datatype; - attrib_data->dataspace = dataspace; + for (i = 0; i < NUM_THREADS; i++) { + attrib_data = (ttsafe_name_data_t *)HDmalloc(sizeof(ttsafe_name_data_t)); + attrib_data->dataset = dataset; + attrib_data->datatype = datatype; + attrib_data->dataspace = dataspace; attrib_data->current_index = i; - threads[i] = H5TS_create_thread(tts_acreate_thread, NULL, attrib_data); + threads[i] = H5TS_create_thread(tts_acreate_thread, NULL, attrib_data); } - for(i = 0; i < NUM_THREADS; i++) + for (i = 0; i < NUM_THREADS; i++) H5TS_wait_for_thread(threads[i]); /* verify the correctness of the test */ - for(i = 0; i < NUM_THREADS; i++) { + for (i = 0; i < NUM_THREADS; i++) { attribute = H5Aopen(dataset, gen_name(i), H5P_DEFAULT); CHECK(attribute, H5I_INVALID_HID, "H5Aopen"); - if(attribute < 0) + if (attribute < 0) TestErrPrintf("unable to open appropriate attribute. Test failed!\n"); else { status = H5Aread(attribute, H5T_NATIVE_INT, &buffer); @@ -143,10 +143,10 @@ tts_acreate(void) void * tts_acreate_thread(void *client_data) { - hid_t attribute = H5I_INVALID_HID; - char *attribute_name; - int *attribute_data; /* data for attributes */ - herr_t status; + hid_t attribute = H5I_INVALID_HID; + char * attribute_name; + int * attribute_data; /* data for attributes */ + herr_t status; ttsafe_name_data_t *attrib_data; @@ -154,15 +154,14 @@ tts_acreate_thread(void *client_data) /* Create attribute */ attribute_name = gen_name(attrib_data->current_index); - attribute = H5Acreate2(attrib_data->dataset, attribute_name, - attrib_data->datatype, attrib_data->dataspace, - H5P_DEFAULT, H5P_DEFAULT); + attribute = H5Acreate2(attrib_data->dataset, attribute_name, attrib_data->datatype, + attrib_data->dataspace, H5P_DEFAULT, H5P_DEFAULT); CHECK(attribute, H5I_INVALID_HID, "H5Acreate2"); /* Write data to the attribute */ - attribute_data = (int *)HDmalloc(sizeof(int)); + attribute_data = (int *)HDmalloc(sizeof(int)); *attribute_data = attrib_data->current_index; - status = H5Awrite(attribute, H5T_NATIVE_INT, attribute_data); + status = H5Awrite(attribute, H5T_NATIVE_INT, attribute_data); CHECK(status, FAIL, "H5Awrite"); status = H5Aclose(attribute); CHECK(status, FAIL, "H5Aclose"); @@ -176,4 +175,3 @@ cleanup_acreate(void) } #endif /*H5_HAVE_THREADSAFE*/ - |