diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2006-06-18 18:41:30 -0400 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2006-06-18 18:41:30 -0400 |
commit | 0d8fee3270f8a5e4bf95fbed3e81e21b57f8a5a0 (patch) | |
tree | e965874962259a2f16980f19a4e5c03ef635a86f /fs/xfs/linux-2.6/sema.h | |
parent | a805bad5daae8d4f92ce46f467484d4867e996d4 (diff) |
[XFS] Kill direct access to ->count in valusema(); all we ever use it for
is check if semaphore is actually locked, which can be trivially done in
portable way. Code gets more reabable, while we are at it...
SGI-PV: 953915
SGI-Modid: xfs-linux-melb:xfs-kern:26274a
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/sema.h')
-rw-r--r-- | fs/xfs/linux-2.6/sema.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/xfs/linux-2.6/sema.h b/fs/xfs/linux-2.6/sema.h index 194a84490bd1..b25090094cca 100644 --- a/fs/xfs/linux-2.6/sema.h +++ b/fs/xfs/linux-2.6/sema.h | |||
@@ -34,20 +34,21 @@ typedef struct semaphore sema_t; | |||
34 | #define initnsema(sp, val, name) sema_init(sp, val) | 34 | #define initnsema(sp, val, name) sema_init(sp, val) |
35 | #define psema(sp, b) down(sp) | 35 | #define psema(sp, b) down(sp) |
36 | #define vsema(sp) up(sp) | 36 | #define vsema(sp) up(sp) |
37 | #define valusema(sp) (atomic_read(&(sp)->count)) | 37 | #define freesema(sema) do { } while (0) |
38 | #define freesema(sema) | 38 | |
39 | static inline int issemalocked(sema_t *sp) | ||
40 | { | ||
41 | return down_trylock(sp) || (up(sp), 0); | ||
42 | } | ||
39 | 43 | ||
40 | /* | 44 | /* |
41 | * Map cpsema (try to get the sema) to down_trylock. We need to switch | 45 | * Map cpsema (try to get the sema) to down_trylock. We need to switch |
42 | * the return values since cpsema returns 1 (acquired) 0 (failed) and | 46 | * the return values since cpsema returns 1 (acquired) 0 (failed) and |
43 | * down_trylock returns the reverse 0 (acquired) 1 (failed). | 47 | * down_trylock returns the reverse 0 (acquired) 1 (failed). |
44 | */ | 48 | */ |
45 | 49 | static inline int cpsema(sema_t *sp) | |
46 | #define cpsema(sp) (down_trylock(sp) ? 0 : 1) | 50 | { |
47 | 51 | return down_trylock(sp) ? 0 : 1; | |
48 | /* | 52 | } |
49 | * Didn't do cvsema(sp). Not sure how to map this to up/down/... | ||
50 | * It does a vsema if the values is < 0 other wise nothing. | ||
51 | */ | ||
52 | 53 | ||
53 | #endif /* __XFS_SUPPORT_SEMA_H__ */ | 54 | #endif /* __XFS_SUPPORT_SEMA_H__ */ |