aboutsummaryrefslogtreecommitdiffstats
path: root/unmodified_drivers/linux-2.6/compat-include
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@xensource.com>2006-10-25 13:58:30 +0100
committerIan Campbell <ian.campbell@xensource.com>2006-10-25 13:58:30 +0100
commit212cd2b3a01cedec944d143b8bb0024628a2f382 (patch)
treee634a6f94b5552f9c75ef2a67964e75fb842fdfe /unmodified_drivers/linux-2.6/compat-include
parent3dd858632a6cfd1b55e38395f6fd143f7ae96f6c (diff)
downloadxen-212cd2b3a01cedec944d143b8bb0024628a2f382.tar.gz
xen-212cd2b3a01cedec944d143b8bb0024628a2f382.tar.bz2
xen-212cd2b3a01cedec944d143b8bb0024628a2f382.zip
PV-on-HVM: Add a compatibility linux/mutex.h for kernels before
2.6.16. This implements the new mutex type in terms of the old semaphore type. Signed-off-by: Ian Campbell <ian.campbell@xensource.com> Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com> Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
Diffstat (limited to 'unmodified_drivers/linux-2.6/compat-include')
-rw-r--r--unmodified_drivers/linux-2.6/compat-include/linux/mutex.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/unmodified_drivers/linux-2.6/compat-include/linux/mutex.h b/unmodified_drivers/linux-2.6/compat-include/linux/mutex.h
new file mode 100644
index 0000000000..fcb4a899c7
--- /dev/null
+++ b/unmodified_drivers/linux-2.6/compat-include/linux/mutex.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2006 Cisco Systems. All rights reserved.
+ *
+ * This file is released under the GPLv2.
+ */
+
+/* mutex compatibility for pre-2.6.16 kernels */
+
+#ifndef __LINUX_MUTEX_H
+#define __LINUX_MUTEX_H
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#error "This version of Linux should not need compat mutex.h"
+#endif
+
+#include <linux/version.h>
+#include <asm/semaphore.h>
+
+#define mutex semaphore
+#define DEFINE_MUTEX(foo) DECLARE_MUTEX(foo)
+#define mutex_init(foo) init_MUTEX(foo)
+#define mutex_lock(foo) down(foo)
+#define mutex_lock_interruptible(foo) down_interruptible(foo)
+/* this function follows the spin_trylock() convention, so *
+ * it is negated to the down_trylock() return values! Be careful */
+#define mutex_trylock(foo) !down_trylock(foo)
+#define mutex_unlock(foo) up(foo)
+
+#endif /* __LINUX_MUTEX_H */