summaryrefslogtreecommitdiff
path: root/libdde_linux26/contrib/include/linux/semaphore.h
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-05-08 22:45:06 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-05-08 22:45:06 +0200
commit878c5456c5a2f9bff741a7b7bcdccd5c1694db22 (patch)
treebcf3d101215fa70b953aa7e9d0de805c5f8865b4 /libdde_linux26/contrib/include/linux/semaphore.h
parent9062642230b7bfb48e7b30f98cba8528172b2d36 (diff)
parentc8f311a7a32d4b0cb0c21672f63bca8efdf5d83a (diff)
Merge branch 'dde' into HEAD
Diffstat (limited to 'libdde_linux26/contrib/include/linux/semaphore.h')
-rw-r--r--libdde_linux26/contrib/include/linux/semaphore.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/libdde_linux26/contrib/include/linux/semaphore.h b/libdde_linux26/contrib/include/linux/semaphore.h
new file mode 100644
index 00000000..7415839a
--- /dev/null
+++ b/libdde_linux26/contrib/include/linux/semaphore.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2008 Intel Corporation
+ * Author: Matthew Wilcox <willy@linux.intel.com>
+ *
+ * Distributed under the terms of the GNU GPL, version 2
+ *
+ * Please see kernel/semaphore.c for documentation of these functions
+ */
+#ifndef __LINUX_SEMAPHORE_H
+#define __LINUX_SEMAPHORE_H
+
+#include <linux/list.h>
+#include <linux/spinlock.h>
+
+/* Please don't access any members of this structure directly */
+struct semaphore {
+ spinlock_t lock;
+ unsigned int count;
+ struct list_head wait_list;
+};
+
+#define __SEMAPHORE_INITIALIZER(name, n) \
+{ \
+ .lock = __SPIN_LOCK_UNLOCKED((name).lock), \
+ .count = n, \
+ .wait_list = LIST_HEAD_INIT((name).wait_list), \
+}
+
+#define DECLARE_MUTEX(name) \
+ struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
+
+static inline void sema_init(struct semaphore *sem, int val)
+{
+ static struct lock_class_key __key;
+ *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
+ lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
+}
+
+#define init_MUTEX(sem) sema_init(sem, 1)
+#define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
+
+extern void down(struct semaphore *sem);
+extern int __must_check down_interruptible(struct semaphore *sem);
+extern int __must_check down_killable(struct semaphore *sem);
+extern int __must_check down_trylock(struct semaphore *sem);
+extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
+extern void up(struct semaphore *sem);
+
+#endif /* __LINUX_SEMAPHORE_H */