2004-01-11 01:22:50 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-14 10:06:57 +03:00
|
|
|
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "threads/mutex.h"
|
2004-01-11 01:22:50 +03:00
|
|
|
|
2004-01-14 10:06:57 +03:00
|
|
|
/*
|
|
|
|
* Default to a safe value
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
bool ompi_uses_threads = (bool) OMPI_HAVE_THREADS;
|
2004-01-11 01:22:50 +03:00
|
|
|
|
2004-08-19 04:34:00 +04:00
|
|
|
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
static void ompi_mutex_construct(ompi_mutex_t *m)
|
|
|
|
{
|
|
|
|
InterlockedExchange(&m->m_lock, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ompi_mutex_destruct(ompi_mutex_t *m)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static void ompi_mutex_construct(ompi_mutex_t *m)
|
|
|
|
{
|
|
|
|
#if OMPI_HAVE_POSIX_THREADS
|
2004-08-19 23:29:01 +04:00
|
|
|
pthread_mutex_init(&m->m_lock_pthread, 0);
|
2004-08-19 04:34:00 +04:00
|
|
|
#endif
|
2004-08-20 03:34:46 +04:00
|
|
|
#if OMPI_HAVE_ATOMIC
|
2004-08-19 23:29:01 +04:00
|
|
|
ompi_atomic_unlock(&m->m_lock_atomic);
|
2004-08-19 04:34:00 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ompi_mutex_destruct(ompi_mutex_t *m)
|
|
|
|
{
|
|
|
|
#if OMPI_HAVE_POSIX_THREADS
|
2004-08-19 23:29:01 +04:00
|
|
|
pthread_mutex_destroy(&m->m_lock_pthread);
|
2004-08-19 04:34:00 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(ompi_mutex_t,
|
|
|
|
ompi_object_t,
|
|
|
|
ompi_mutex_construct,
|
|
|
|
ompi_mutex_destruct);
|