PAPI 7.1.0.0
Loading...
Searching...
No Matches
sde_lib_lock.h
Go to the documentation of this file.
1#if !defined(PAPI_SDE_LIB_LOCK_H)
2#define PAPI_SDE_LIB_LOCK_H
3
4#include "atomic_ops.h"
5#if defined(AO_HAVE_test_and_set_acquire)
6#define USE_LIBAO_ATOMICS
7#endif
8
9/*************************************************************************/
10/* Locking functions similar to the PAPI locking function. */
11/*************************************************************************/
12#if defined(USE_LIBAO_ATOMICS)
13
15#define sde_lock() {while (AO_test_and_set_acquire(&_sde_hwd_lock_data) != AO_TS_CLEAR) { ; } }
16#define sde_unlock() { AO_CLEAR(&_sde_hwd_lock_data); }
17
18#else //defined(USE_LIBAO_ATOMICS)
19
20#include <pthread.h>
21
23
24#define sde_lock() \
25do{ \
26 pthread_mutex_lock(&_sde_hwd_lock_data); \
27} while(0)
28
29#define sde_unlock(lck) \
30do{ \
31 pthread_mutex_unlock(&_sde_hwd_lock_data); \
32} while(0)
33
34#endif //defined(USE_LIBAO_ATOMICS)
35
36
37
38#endif
#define AO_TS_t
Definition: gcc/hppa.h:39
pthread_mutex_t _sde_hwd_lock_data
Definition: sde_lib.c:43