1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2004 Cluster File Systems, Inc.
5 * Author: Nikita Danilov <nikita@clusterfs.com>
7 * This file is part of Lustre, http://www.lustre.org.
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.
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
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.
22 * Implementation of portable time API for user-level.
26 /* Implementations of portable synchronization APIs for liblustre */
29 * liblustre is single-threaded, so most "synchronization" APIs are trivial.
31 * XXX Liang: There are several branches share lnet with b_hd_newconfig,
32 * if we define lock APIs at here, there will be conflict with liblustre
39 #include <libcfs/libcfs.h>
41 * Optional debugging (magic stamping and checking ownership) can be added.
53 * - spin_lock_irqsave(x, f)
54 * - spin_unlock_irqrestore(x, f)
56 * No-op implementation.
59 void spin_lock_init(spinlock_t *lock)
61 LASSERT(lock != NULL);
65 void spin_lock(spinlock_t *lock)
70 void spin_unlock(spinlock_t *lock)
75 int spin_trylock(spinlock_t *lock)
81 void spin_lock_bh_init(spinlock_t *lock)
83 LASSERT(lock != NULL);
87 void spin_lock_bh(spinlock_t *lock)
89 LASSERT(lock != NULL);
93 void spin_unlock_bh(spinlock_t *lock)
95 LASSERT(lock != NULL);
108 void sema_init(struct semaphore *s, int val)
115 void __down(struct semaphore *s)
121 void __up(struct semaphore *s)
131 * - init_mutex_locked(x)
136 #define mutex_up(s) __up(s)
137 #define mutex_down(s) __down(s)
139 #define init_mutex(x) sema_init(x, 1)
140 #define init_mutex_locked(x) sema_init(x, 0)
145 * - init_completion(c)
147 * - wait_for_completion(c)
149 struct completion {};
151 void init_completion(struct completion *c)
157 void complete(struct completion *c)
163 void wait_for_completion(struct completion *c)
179 struct rw_semaphore {};
181 void init_rwsem(struct rw_semaphore *s)
187 void down_read(struct rw_semaphore *s)
193 int down_read_trylock(struct rw_semaphore *s)
200 void down_write(struct rw_semaphore *s)
206 int down_write_trylock(struct rw_semaphore *s)
213 void up_read(struct rw_semaphore *s)
219 void up_write(struct rw_semaphore *s)
231 * c-indentation-style: "K&R"