summaryrefslogtreecommitdiff
path: root/v4l/compat.h
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2009-05-30 17:45:46 -0700
committerTrent Piepho <xyzzy@speakeasy.org>2009-05-30 17:45:46 -0700
commit9903c4e6973daa6579771ba67db415a7105d5e44 (patch)
tree370c0073f5c68835c5d3f5aa6fbe18703a7591c5 /v4l/compat.h
parente0dc20d13b71daf0612373420a45246e6566d61f (diff)
downloadmediapointer-dvb-s2-9903c4e6973daa6579771ba67db415a7105d5e44.tar.gz
mediapointer-dvb-s2-9903c4e6973daa6579771ba67db415a7105d5e44.tar.bz2
compat: handle __fls
From: Trent Piepho <xyzzy@speakeasy.org> __fls() was added for generic code in 2.6.29, existed for just 64-bit arches since 2.6.26 (v2.6.25-5228-g56a6b1e), and was x86-64 only before then. When __fls() doesn't exists we create an inline function that implements it via fls(), which has existed for longer. Priority: normal Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Diffstat (limited to 'v4l/compat.h')
-rw-r--r--v4l/compat.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/v4l/compat.h b/v4l/compat.h
index 6a40e2a33..ce28da615 100644
--- a/v4l/compat.h
+++ b/v4l/compat.h
@@ -454,4 +454,19 @@ static inline int snd_card_create(int idx, const char *id,
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
#endif
+/* __fls() was added for generic code in 2.6.29, existed for just 64-bit arches
+ * since 2.6.26 (v2.6.25-5228-g56a6b1e), and was x86-64 only before then. We
+ * only want this compat code when __fls doesn't exist, which 2.6.29 or later,
+ * non x86-64, and non 64-bit that's 2.6.26 or later. */
+#if !(LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) || \
+ defined(__x86_64__) || \
+ (BITS_PER_LONG == 64 && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)))
+/* This define will prevent breakage if __fls was already defined. */
+#define __fls v4l_compat_fls
+static inline unsigned long v4l_compat_fls(unsigned long x)
+{
+ return fls(x) - 1;
+}
+#endif
+
#endif /* _COMPAT_H */