| 1 |
#ifndef _I965_MUTEX_H_ |
| 2 |
#define _I965_MUTEX_H_ |
| 3 |
|
| 4 |
#include "intel_compiler.h" |
| 5 |
|
| 6 |
#if defined PTHREADS |
| 7 |
#include <pthread.h> |
| 8 |
|
| 9 |
typedef pthread_mutex_t _I965Mutex; |
| 10 |
|
| 11 |
static INLINE void _i965InitMutex(_I965Mutex *m) |
| 12 |
{ |
| 13 |
pthread_mutex_init(m, NULL); |
| 14 |
} |
| 15 |
|
| 16 |
static INLINE void |
| 17 |
_i965DestroyMutex(_I965Mutex *m) |
| 18 |
{ |
| 19 |
pthread_mutex_destroy(m); |
| 20 |
} |
| 21 |
|
| 22 |
static INLINE void |
| 23 |
_i965LockMutex(_I965Mutex *m) |
| 24 |
{ |
| 25 |
pthread_mutex_lock(m); |
| 26 |
} |
| 27 |
|
| 28 |
static INLINE void |
| 29 |
_i965UnlockMutex(_I965Mutex *m) |
| 30 |
{ |
| 31 |
pthread_mutex_unlock(m); |
| 32 |
} |
| 33 |
|
| 34 |
#define _I965_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER |
| 35 |
#define _I965_DECLARE_MUTEX(m) \ |
| 36 |
_I965Mutex m = _I965_MUTEX_INITIALIZER |
| 37 |
|
| 38 |
#else |
| 39 |
|
| 40 |
typedef int _I965Mutex; |
| 41 |
static INLINE void _i965InitMutex(_I965Mutex *m) |
| 42 |
{ |
| 43 |
(void) m; |
| 44 |
} |
| 45 |
static INLINE void _i965DestroyMutex(_I965Mutex *m) |
| 46 |
{ |
| 47 |
(void) m; |
| 48 |
} |
| 49 |
static INLINE void _i965LockMutex(_I965Mutex *m) |
| 50 |
{ |
| 51 |
(void) m; |
| 52 |
} |
| 53 |
static INLINE void _i965UnlockMutex(_I965Mutex *m) |
| 54 |
{ |
| 55 |
(void) m; |
| 56 |
} |
| 57 |
|
| 58 |
#define _I965_MUTEX_INITIALIZER 0 |
| 59 |
#define _I965_DECLARE_MUTEX(m) \ |
| 60 |
_I965Mutex m = _I965_MUTEX_INITIALIZER |
| 61 |
|
| 62 |
#endif |
| 63 |
|
| 64 |
#endif /* _I965_MUTEX_H_ */ |