summaryrefslogtreecommitdiffstats
path: root/test/ttsafe_error.c
diff options
context:
space:
mode:
authorMike McGreevy <mamcgree@hdfgroup.org>2010-09-10 16:15:34 (GMT)
committerMike McGreevy <mamcgree@hdfgroup.org>2010-09-10 16:15:34 (GMT)
commitb7c2d18029df6d724e44b74c8f49bb7aa1e2f02b (patch)
treec3dd326b9b8ed4746b57165165713ae9b046c62b /test/ttsafe_error.c
parent47c792faa033c4c149b2c5d4dd0e70e4f2b0e3d2 (diff)
downloadhdf5-b7c2d18029df6d724e44b74c8f49bb7aa1e2f02b.zip
hdf5-b7c2d18029df6d724e44b74c8f49bb7aa1e2f02b.tar.gz
hdf5-b7c2d18029df6d724e44b74c8f49bb7aa1e2f02b.tar.bz2
[svn-r19367] Purpose:
Add windows threads support to HDF5. Description: Added calls to the windows threads library to the H5TS layer, and wrapped most calls to either pthreads or windows threads library with portable H5TS-style defines. Modified tests to use portable function definitions as well. This can be configured via CMake with the HDF5_ENABLE_THREADSAFE option, and should work on windows vista and later operating systems. Tested: h5committest, plus threadsafe with pthreads on jam and amani, and tested on a Windows Vista VM with threadsafe using windows threads.
Diffstat (limited to 'test/ttsafe_error.c')
-rw-r--r--test/ttsafe_error.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c
index b3d056f..f55afdc 100644
--- a/test/ttsafe_error.c
+++ b/test/ttsafe_error.c
@@ -71,12 +71,12 @@ err_num_t expected[8];
int error_flag = 0;
int error_count = 0;
-pthread_mutex_t error_mutex;
+H5TS_mutex_simple_t error_mutex;
void tts_error(void)
{
- pthread_t threads[NUM_THREAD];
- pthread_attr_t attribute;
+ H5TS_thread_t threads[NUM_THREAD];
+ H5TS_attr_t attribute;
hid_t dataset;
int value, i;
int ret;
@@ -104,16 +104,15 @@ void tts_error(void)
expected[6].min_num = H5E_EXISTS;
/* set up mutex for global count of errors */
- ret=pthread_mutex_init(&error_mutex, NULL);
- assert(ret==0);
+ H5TS_mutex_init(&error_mutex);
/* make thread scheduling global */
- ret=pthread_attr_init(&attribute);
- assert(ret==0);
+ H5TS_attr_init(&attribute);
+
+ /* set thread scope to system */
#ifdef H5_HAVE_SYSTEM_SCOPE_THREADS
- ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
- assert(ret==0);
+ H5TS_attr_setscope(&attribute, H5TS_SCOPE_SYSTEM);
#endif /* H5_HAVE_SYSTEM_SCOPE_THREADS */
/*
@@ -124,13 +123,11 @@ void tts_error(void)
assert(error_file>=0);
for (i = 0; i < NUM_THREAD; i++){
- ret=pthread_create(&threads[i], &attribute, tts_error_thread, NULL);
- assert(ret==0);
+ threads[i] = H5TS_create_thread(tts_error_thread, &attribute, NULL);
}
for (i = 0; i < NUM_THREAD; i++){
- ret=pthread_join(threads[i],NULL);
- assert(ret==0);
+ H5TS_wait_for_thread(threads[i]);
}
if (error_flag)
@@ -153,9 +150,7 @@ void tts_error(void)
ret=H5Fclose(error_file);
assert(ret>=0);
- /* Destroy the thread attribute */
- ret=pthread_attr_destroy(&attribute);
- assert(ret==0);
+ H5TS_attr_destroy(&attribute);
}
static
@@ -208,11 +203,9 @@ herr_t error_callback(hid_t estack_id, void *client_data)
{
int ret;
- ret=pthread_mutex_lock(&error_mutex);
- assert(ret==0);
+ H5TS_mutex_lock_simple(&error_mutex);
error_count++;
- ret=pthread_mutex_unlock(&error_mutex);
- assert(ret==0);
+ H5TS_mutex_unlock_simple(&error_mutex);
return H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, client_data);
}