Whamcloud - gitweb
- ptlrpc_ping_interpret is needless:
[fs/lustre-release.git] / lnet / libcfs / user-lock.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2004 Cluster File Systems, Inc.
5  * Author: Nikita Danilov <nikita@clusterfs.com>
6  *
7  * This file is part of Lustre, http://www.lustre.org.
8  *
9  * Lustre is free software; you can redistribute it and/or modify it under the
10  * terms of version 2 of the GNU General Public License as published by the
11  * Free Software Foundation.
12  *
13  * Lustre is distributed in the hope that it will be useful, but WITHOUT ANY
14  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with Lustre; if not, write to the Free Software Foundation, Inc., 675 Mass
20  * Ave, Cambridge, MA 02139, USA.
21  *
22  * Implementation of portable time API for user-level.
23  *
24  */
25
26 /* Implementations of portable synchronization APIs for liblustre */
27
28 /*
29  * liblustre is single-threaded, so most "synchronization" APIs are trivial.
30  */
31
32 #ifndef __KERNEL__
33
34 /*
35  * Optional debugging (magic stamping and checking ownership) can be added.
36  */
37
38 /*
39  * spin_lock
40  *
41  * - spin_lock_init(x)
42  * - spin_lock(x)
43  * - spin_unlock(x)
44  * - spin_trylock(x)
45  *
46  * - spin_lock_irqsave(x, f)
47  * - spin_unlock_irqrestore(x, f)
48  *
49  * No-op implementation.
50  */
51
52 void spin_lock_init(spinlock_t *lock)
53 {
54         LASSERT(lock != NULL);
55         (void)lock;
56 }
57
58 void spin_lock(spinlock_t *lock)
59 {
60         (void)lock;
61 }
62
63 void spin_unlock(spinlock_t *lock)
64 {
65         (void)lock;
66 }
67
68 int spin_trylock(spinlock_t *lock)
69 {
70         (void)lock;
71         return 1;
72 }
73
74 void spin_lock_bh_init(spinlock_t *lock)
75 {
76         LASSERT(lock != NULL);
77         (void)lock;
78 }
79
80 void spin_lock_bh(spinlock_t *lock)
81 {
82         LASSERT(lock != NULL);
83         (void)lock;
84 }
85
86 void spin_unlock_bh(spinlock_t *lock)
87 {
88         LASSERT(lock != NULL);
89         (void)lock;
90 }
91
92 void spin_lock_irqsave(spinlock_t *lock, unsigned long flags)
93 {
94         LASSERT(lock != NULL);
95         (void)lock;
96 }
97
98 void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
99 {
100         LASSERT(lock != NULL);
101         (void)lock;
102 }
103
104
105 /*
106  * Semaphore
107  *
108  * - sema_init(x, v)
109  * - __down(x)
110  * - __up(x)
111  */
112 struct semaphore {};
113
114 void sema_init(struct semaphore *s, int val)
115 {
116         LASSERT(s != NULL);
117         (void)s;
118         (void)val;
119 }
120
121 void __down(struct semaphore *s)
122 {
123         LASSERT(s != NULL);
124         (void)s;
125 }
126
127 void __up(struct semaphore *s)
128 {
129         LASSERT(s != NULL);
130         (void)s;
131 }
132
133 /*
134  * Mutex:
135  *
136  * - init_mutex(x)
137  * - init_mutex_locked(x)
138  * - mutex_up(x)
139  * - mutex_down(x)
140  */
141
142 #define mutex_up(s)                     __up(s)
143 #define mutex_down(s)                   __down(s)
144
145 #define init_mutex(x)                   sema_init(x, 1)
146 #define init_mutex_locked(x)            sema_init(x, 0)
147
148 /*
149  * Completion:
150  *
151  * - init_completion(c)
152  * - complete(c)
153  * - wait_for_completion(c)
154  */
155 struct completion {};
156
157 void init_completion(struct completion *c)
158 {
159         LASSERT(c != NULL);
160         (void)c;
161 }
162
163 void complete(struct completion *c)
164 {
165         LASSERT(c != NULL);
166         (void)c;
167 }
168
169 void wait_for_completion(struct completion *c)
170 {
171         LASSERT(c != NULL);
172         (void)c;
173 }
174
175 /*
176  * rw_semaphore:
177  *
178  * - DECLARE_RWSEM(x)
179  * - init_rwsem(x)
180  * - down_read(x)
181  * - up_read(x)
182  * - down_write(x)
183  * - up_write(x)
184  */
185 struct rw_semaphore {};
186
187 void init_rwsem(struct rw_semaphore *s)
188 {
189         LASSERT(s != NULL);
190         (void)s;
191 }
192
193 void down_read(struct rw_semaphore *s)
194 {
195         LASSERT(s != NULL);
196         (void)s;
197 }
198
199 int down_read_trylock(struct rw_semaphore *s)
200 {
201         LASSERT(s != NULL);
202         (void)s;
203         return 1;
204 }
205
206 void down_write(struct rw_semaphore *s)
207 {
208         LASSERT(s != NULL);
209         (void)s;
210 }
211
212 int down_write_trylock(struct rw_semaphore *s)
213 {
214         LASSERT(s != NULL);
215         (void)s;
216         return 1;
217 }
218
219 void up_read(struct rw_semaphore *s)
220 {
221         LASSERT(s != NULL);
222         (void)s;
223 }
224
225 void up_write(struct rw_semaphore *s)
226 {
227         LASSERT(s != NULL);
228         (void)s;
229 }
230
231 /* !__KERNEL__ */
232 #endif
233
234 /*
235  * Local variables:
236  * c-indentation-style: "K&R"
237  * c-basic-offset: 8
238  * tab-width: 8
239  * fill-column: 80
240  * scroll-step: 1
241  * End:
242  */