new compatibility header from Ian Abbott <abbotti@mev.co.uk>:
authorFrank Mori Hess <fmhess@speakeasy.net>
Thu, 17 Feb 2005 22:58:33 +0000 (22:58 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Thu, 17 Feb 2005 22:58:33 +0000 (22:58 +0000)
Here's an asm/semaphore.h compatibility header to help build Comedi
drivers for kernel versions prior to 2.2.18.  It defines the following
missing macros:

init_MUTEX(x)
init_MUTEX_LOCKED(x)
DECLARE_MUTEX(name)
DECLARE_MUTEX_LOCKED(name)

I didn't define sema_init(sem, val) as I the implementation is
arch-dependent.

include/asm/semaphore.h [new file with mode: 0644]

diff --git a/include/asm/semaphore.h b/include/asm/semaphore.h
new file mode 100644 (file)
index 0000000..791c2e1
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * asm/semaphore.h compatibility header
+ */
+
+#ifndef __COMPAT_ASM_SEMAPHORE_H_
+#define __COMPAT_ASM_SEMAPHORE_H_
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)
+#define init_MUTEX(x)                          *(x)=MUTEX
+#define init_MUTEX_LOCKED(x)                   *(x)=MUTEX_LOCKED
+#define DECLARE_MUTEX(name)                    struct semaphore name=MUTEX
+#define DECLARE_MUTEX_LOCKED(name)             struct semaphore name=MUTEX_LOCKED
+/* N.B. Cannot define missing sema_init() portably, so best not use it! */
+#endif
+
+#include_next <asm/semaphore.h>
+
+#endif // __COMPAT_ASM_SEMAPHORE_H_
+