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.
35 * Optional debugging (magic stamping and checking ownership) can be added.
46 * - spin_lock_irqsave(x, f)
47 * - spin_unlock_irqrestore(x, f)
49 * No-op implementation.
52 void spin_lock_init(spinlock_t *lock)
54 LASSERT(lock != NULL);
58 void spin_lock(spinlock_t *lock)
63 void spin_unlock(spinlock_t *lock)
68 int spin_trylock(spinlock_t *lock)
74 void spin_lock_bh_init(spinlock_t *lock)
76 LASSERT(lock != NULL);
80 void spin_lock_bh(spinlock_t *lock)
82 LASSERT(lock != NULL);
86 void spin_unlock_bh(spinlock_t *lock)
88 LASSERT(lock != NULL);
92 void spin_lock_irqsave(spinlock_t *lock, unsigned long flags)
94 LASSERT(lock != NULL);
98 void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
100 LASSERT(lock != NULL);
114 void sema_init(struct semaphore *s, int val)
121 void __down(struct semaphore *s)
127 void __up(struct semaphore *s)
137 * - init_mutex_locked(x)
142 #define mutex_up(s) __up(s)
143 #define mutex_down(s) __down(s)
145 #define init_mutex(x) sema_init(x, 1)
146 #define init_mutex_locked(x) sema_init(x, 0)
151 * - init_completion(c)
153 * - wait_for_completion(c)
155 struct completion {};
157 void init_completion(struct completion *c)
163 void complete(struct completion *c)
169 void wait_for_completion(struct completion *c)
185 struct rw_semaphore {};
187 void init_rwsem(struct rw_semaphore *s)
193 void down_read(struct rw_semaphore *s)
199 int down_read_trylock(struct rw_semaphore *s)
206 void down_write(struct rw_semaphore *s)
212 int down_write_trylock(struct rw_semaphore *s)
219 void up_read(struct rw_semaphore *s)
225 void up_write(struct rw_semaphore *s)
236 * c-indentation-style: "K&R"