KVM: arm/arm64: vgic-new: Implement kvm_vgic_vcpu_pending_irq
[linux/fpc-iii.git] / fs / xfs / mrlock.h
blobe3c92d19e54079e5ffc950adf8974c35eee0703e
1 /*
2 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
3 * All Rights Reserved.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef __XFS_SUPPORT_MRLOCK_H__
19 #define __XFS_SUPPORT_MRLOCK_H__
21 #include <linux/rwsem.h>
23 typedef struct {
24 struct rw_semaphore mr_lock;
25 #if defined(DEBUG) || defined(XFS_WARN)
26 int mr_writer;
27 #endif
28 } mrlock_t;
30 #if defined(DEBUG) || defined(XFS_WARN)
31 #define mrinit(mrp, name) \
32 do { (mrp)->mr_writer = 0; init_rwsem(&(mrp)->mr_lock); } while (0)
33 #else
34 #define mrinit(mrp, name) \
35 do { init_rwsem(&(mrp)->mr_lock); } while (0)
36 #endif
38 #define mrlock_init(mrp, t,n,s) mrinit(mrp, n)
39 #define mrfree(mrp) do { } while (0)
41 static inline void mraccess_nested(mrlock_t *mrp, int subclass)
43 down_read_nested(&mrp->mr_lock, subclass);
46 static inline void mrupdate_nested(mrlock_t *mrp, int subclass)
48 down_write_nested(&mrp->mr_lock, subclass);
49 #if defined(DEBUG) || defined(XFS_WARN)
50 mrp->mr_writer = 1;
51 #endif
54 static inline int mrtryaccess(mrlock_t *mrp)
56 return down_read_trylock(&mrp->mr_lock);
59 static inline int mrtryupdate(mrlock_t *mrp)
61 if (!down_write_trylock(&mrp->mr_lock))
62 return 0;
63 #if defined(DEBUG) || defined(XFS_WARN)
64 mrp->mr_writer = 1;
65 #endif
66 return 1;
69 static inline void mrunlock_excl(mrlock_t *mrp)
71 #if defined(DEBUG) || defined(XFS_WARN)
72 mrp->mr_writer = 0;
73 #endif
74 up_write(&mrp->mr_lock);
77 static inline void mrunlock_shared(mrlock_t *mrp)
79 up_read(&mrp->mr_lock);
82 static inline void mrdemote(mrlock_t *mrp)
84 #if defined(DEBUG) || defined(XFS_WARN)
85 mrp->mr_writer = 0;
86 #endif
87 downgrade_write(&mrp->mr_lock);
90 #endif /* __XFS_SUPPORT_MRLOCK_H__ */