diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-sparc64/semaphore.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-sparc64/semaphore.h')
-rw-r--r-- | include/asm-sparc64/semaphore.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/include/asm-sparc64/semaphore.h b/include/asm-sparc64/semaphore.h new file mode 100644 index 000000000000..7419dd88b49e --- /dev/null +++ b/include/asm-sparc64/semaphore.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #ifndef _SPARC64_SEMAPHORE_H | ||
2 | #define _SPARC64_SEMAPHORE_H | ||
3 | |||
4 | /* These are actually reasonable on the V9. | ||
5 | * | ||
6 | * See asm-ppc/semaphore.h for implementation commentary, | ||
7 | * only sparc64 specific issues are commented here. | ||
8 | */ | ||
9 | #ifdef __KERNEL__ | ||
10 | |||
11 | #include <asm/atomic.h> | ||
12 | #include <asm/system.h> | ||
13 | #include <linux/wait.h> | ||
14 | #include <linux/rwsem.h> | ||
15 | |||
16 | struct semaphore { | ||
17 | atomic_t count; | ||
18 | wait_queue_head_t wait; | ||
19 | }; | ||
20 | |||
21 | #define __SEMAPHORE_INITIALIZER(name, count) \ | ||
22 | { ATOMIC_INIT(count), \ | ||
23 | __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) } | ||
24 | |||
25 | #define __MUTEX_INITIALIZER(name) \ | ||
26 | __SEMAPHORE_INITIALIZER(name, 1) | ||
27 | |||
28 | #define __DECLARE_SEMAPHORE_GENERIC(name, count) \ | ||
29 | struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) | ||
30 | |||
31 | #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1) | ||
32 | #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name, 0) | ||
33 | |||
34 | static inline void sema_init (struct semaphore *sem, int val) | ||
35 | { | ||
36 | atomic_set(&sem->count, val); | ||
37 | init_waitqueue_head(&sem->wait); | ||
38 | } | ||
39 | |||
40 | static inline void init_MUTEX (struct semaphore *sem) | ||
41 | { | ||
42 | sema_init(sem, 1); | ||
43 | } | ||
44 | |||
45 | static inline void init_MUTEX_LOCKED (struct semaphore *sem) | ||
46 | { | ||
47 | sema_init(sem, 0); | ||
48 | } | ||
49 | |||
50 | extern void up(struct semaphore *sem); | ||
51 | extern void down(struct semaphore *sem); | ||
52 | extern int down_trylock(struct semaphore *sem); | ||
53 | extern int down_interruptible(struct semaphore *sem); | ||
54 | |||
55 | #endif /* __KERNEL__ */ | ||
56 | |||
57 | #endif /* !(_SPARC64_SEMAPHORE_H) */ | ||