summaryrefslogtreecommitdiffstats
path: root/test/ttsafe_acreate.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/ttsafe_acreate.c')
-rw-r--r--test/ttsafe_acreate.c72
1 files changed, 35 insertions, 37 deletions
diff --git a/test/ttsafe_acreate.c b/test/ttsafe_acreate.c
index 5c08d09..58e8d9d 100644
--- a/test/ttsafe_acreate.c
+++ b/test/ttsafe_acreate.c
@@ -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*/
-