
os/atomic.h --> include/sys/atomic.h WARNING: There are almost certainly some bugs introduced here, but I believe that using this system will get us to a stable and portable library faster in the long run. Other changes: threads/mutex Reorganized to use pthreads or asm atomic operations as available. Untested Windows implementation added using InterlockedExchange() funcion. threads/thread Added an untested Windows implementation other places Updates to include the "right" header files or to use ompi_atomic_add_int() rather that fetchNadd() etc. This commit was SVN r2221.
41 строка
637 B
C
41 строка
637 B
C
/*
|
|
* $HEADER$
|
|
*/
|
|
|
|
#ifndef _OMPI_MUTEX_PTHREAD_
|
|
#define _OMPI_MUTEX_PTHREAD_
|
|
|
|
#include <pthread.h>
|
|
#include "class/ompi_object.h"
|
|
#include "include/sys/atomic.h"
|
|
|
|
|
|
struct ompi_mutex_t {
|
|
ompi_object_t super;
|
|
pthread_mutex_t m_lock;
|
|
};
|
|
typedef struct ompi_mutex_t ompi_mutex_t;
|
|
|
|
OBJ_CLASS_DECLARATION(ompi_mutex_t);
|
|
|
|
|
|
|
|
static inline void ompi_mutex_lock(ompi_mutex_t* m)
|
|
{
|
|
pthread_mutex_lock(&m->m_lock);
|
|
}
|
|
|
|
|
|
static inline int ompi_mutex_trylock(ompi_mutex_t* m)
|
|
{
|
|
return pthread_mutex_trylock(&m->m_lock);
|
|
}
|
|
|
|
|
|
static inline void ompi_mutex_unlock(ompi_mutex_t* m)
|
|
{
|
|
pthread_mutex_unlock(&m->m_lock);
|
|
}
|
|
|
|
#endif
|