lkml.org 
[lkml]   [2009]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE, semaphore_init, semaphore_init_locked
The full cleanup of init_MUTEX[_LOCKED] and DECLARE_MUTEX has not been
done. Some of the users are real semaphores and we should name them as
such instead of confusing everyone with "MUTEX".

Provide the infrastructure to get finally rid of init_MUTEX[_LOCKED]
and DECLARE_MUTEX.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/semaphore.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

Index: linux-2.6-tip/include/linux/semaphore.h
===================================================================
--- linux-2.6-tip.orig/include/linux/semaphore.h
+++ linux-2.6-tip/include/linux/semaphore.h
@@ -26,6 +26,9 @@ struct semaphore {
.wait_list = LIST_HEAD_INIT((name).wait_list), \
}

+#define DEFINE_SEMAPHORE(name) \
+ struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
+
#define DECLARE_MUTEX(name) \
struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)

@@ -36,6 +39,20 @@ static inline void sema_init(struct sema
lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
}

+static inline void semaphore_init(struct semanphore *sem)
+{
+ sema_init(sem, 1);
+}
+
+/*
+ * semaphore_init_locked() is mostly a sign for a mutex which is
+ * abused as completion.
+ */
+static inline void __deprecated semaphore_init_locked(struct semanphore *sem)
+{
+ sema_init(sem, 0);
+}
+
#define init_MUTEX(sem) sema_init(sem, 1)
#define init_MUTEX_LOCKED(sem) sema_init(sem, 0)




\
 
 \ /
  Last update: 2009-07-26 10:21    [W:0.238 / U:3.168 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site