no-copy-libafs-builds-20021015
[openafs.git] / src / rx / LINUX / rx_kmutex.h
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  * Linux implementation.
14  * This are noops until such time as the kernel no longer has a global lock.
15  */
16 #ifndef RX_KMUTEX_H_
17 #define RX_KMUTEX_H_
18
19 #include "rx/rx_kernel.h"       /* for osi_Panic() */
20
21 /* AFS_GLOBAL_RXLOCK_KERNEL is defined so that the busy tq code paths are
22  * used. The thread can sleep when sending packets.
23  */
24 #define AFS_GLOBAL_RXLOCK_KERNEL 1
25
26
27 #ifdef CONFIG_SMP
28 #define RX_ENABLE_LOCKS 1
29
30 #ifndef _LINUX_CODA_FS_I
31 #define _LINUX_CODA_FS_I
32 struct coda_inode_info {};
33 #endif
34 #include "linux/wait.h"
35 #include "linux/sched.h"
36
37 typedef struct afs_kmutex {
38     struct semaphore sem;
39     int owner;
40 } afs_kmutex_t;
41
42 #ifndef set_current_state
43 #define set_current_state(X) current->state=X
44 #endif
45
46 #if defined(AFS_LINUX24_ENV)
47 typedef wait_queue_head_t afs_kcondvar_t;
48 #else
49 typedef struct wait_queue *afs_kcondvar_t;
50 #endif
51
52 static inline int MUTEX_ISMINE(afs_kmutex_t *l)
53 {
54     return l->owner == current->pid;
55 }
56
57 #define MUTEX_INIT(a,b,c,d)     afs_mutex_init(a)
58 #define MUTEX_DESTROY(a)
59 #define MUTEX_ENTER             afs_mutex_enter
60 #define MUTEX_TRYENTER          afs_mutex_tryenter
61 #define MUTEX_EXIT              afs_mutex_exit
62
63 #if defined(AFS_LINUX24_ENV)
64 #define CV_INIT(cv,b,c,d)       init_waitqueue_head((wait_queue_head_t *)(cv))
65 #else
66 #define CV_INIT(cv,b,c,d)       init_waitqueue((struct wait_queue**)(cv))
67 #endif
68 #define CV_DESTROY(cv)
69 #define CV_WAIT_SIG(cv, m)      afs_cv_wait(cv, m, 1)
70 #define CV_WAIT(cv, m)          afs_cv_wait(cv, m, 0)
71 #define CV_TIMEDWAIT            afs_cv_timedwait
72
73 #if defined(AFS_LINUX24_ENV)
74 #define CV_SIGNAL(cv)           wake_up((wait_queue_head_t *)cv)
75 #define CV_BROADCAST(cv)        wake_up((wait_queue_head_t *)cv)
76 #else
77 #define CV_SIGNAL(cv)           wake_up((struct wait_queue**)cv)
78 #define CV_BROADCAST(cv)        wake_up((struct wait_queue**)cv)
79 #endif
80
81 #else
82
83 #define MUTEX_ISMINE(a)
84 #define osirx_AssertMine(addr, msg)
85
86 #define MUTEX_DESTROY(a)
87 #define MUTEX_ENTER(a)
88 #define MUTEX_TRYENTER(a) 1
89 #define MUTEX_EXIT(a)  
90 #define MUTEX_INIT(a,b,c,d) 
91 #define CV_INIT(a,b,c,d)
92 #define CV_DESTROY(a)
93 #endif
94
95 /* Since we're using the RX listener daemon, we don't need to hold off
96  * interrupts.
97  */
98 #define SPLVAR
99 #define NETPRI
100 #define USERPRI
101
102 #endif /* RX_KMUTEX_H_ */