Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / rx / SOLARIS / rx_kmutex.h
CommitLineData
805e021f
CE
1/*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
9
10/*
11 * rx_kmutex.h - mutex and condition variable macros for kernel environment.
12 *
13 * Solaris implementation.
14 */
15
16#ifndef _RX_KMUTEX_H_
17#define _RX_KMUTEX_H_
18
19#if defined(AFS_SUN5_ENV) && defined(KERNEL)
20
21#define RX_ENABLE_LOCKS 1
22
23#include <sys/tiuser.h>
24#include <sys/t_lock.h>
25#include <sys/mutex.h>
26
27typedef kmutex_t afs_kmutex_t;
28typedef kcondvar_t afs_kcondvar_t;
29
30#define MUTEX_DESTROY(a) mutex_destroy(a)
31#define MUTEX_INIT(a,b,c,d) mutex_init(a, b, c, d)
32#define MUTEX_ASSERT(a) osi_Assert(mutex_owned((afs_kmutex_t *)(a)))
33#define CV_INIT(a,b,c,d) cv_init(a, b, c, d)
34#define CV_DESTROY(a) cv_destroy(a)
35#define CV_SIGNAL(a) cv_signal(a)
36#define CV_BROADCAST(a) cv_broadcast(a)
37
38#ifdef RX_LOCKS_DB
39
40#define MUTEX_ENTER(a) \
41 do { \
42 mutex_enter(a); \
43 rxdb_grablock((a), osi_ThreadUnique(), rxdb_fileID, __LINE__); \
44 } while(0)
45
46#define MUTEX_TRYENTER(a) \
47 (mutex_tryenter(a) ? (rxdb_grablock((a), osi_ThreadUnique(), \
48 rxdb_fileID, __LINE__), 1) : 0)
49
50#define MUTEX_EXIT(a) \
51 do { \
52 rxdb_droplock((a), osi_ThreadUnique(), rxdb_fileID, __LINE__); \
53 mutex_exit(a); \
54 } while(0)
55
56#define CV_WAIT_SIG(cv, m) afs_cv_wait(cv, m, 1, rxdb_fileID, __LINE__)
57#define CV_WAIT(cv, m) afs_cv_wait(cv, m, 0, rxdb_fileID, __LINE__)
58
59#define CV_TIMEDWAIT(cv, m, t) \
60 afs_cv_timedwait(cv, lck, t, 0, rxdb_fileID, __LINE__)
61
62#else /* RX_LOCKS_DB */
63
64#define MUTEX_ENTER(a) mutex_enter(a)
65#define MUTEX_TRYENTER(a) mutex_tryenter(a)
66#define MUTEX_EXIT(a) mutex_exit(a)
67
68#define CV_WAIT_SIG(cv, m) afs_cv_wait(cv, m, 1)
69#define CV_WAIT(cv, m) afs_cv_wait(cv, m, 0)
70
71#define CV_TIMEDWAIT(cv, m, t) afs_cv_timedwait(cv, m, t, 0)
72
73#endif /* RX_LOCKS_DB */
74
75#endif /* SUN5 && KERNEL */
76
77#endif /* _RX_KMUTEX_H_ */