build: Add bsearch if not defined
Commit Message
From: Jasmin Jessich <jasmin@anw.at>
Compiling for Kernel 2.6.x failed in "rc-main.c" with
linux/bsearch.h: No such file or directory
Beside adding the missing function, also the include of "linux/bsearch.h"
has been removed by new patch "v2.6_rc_main_bsearch_h.patch".
Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
backports/backports.txt | 3 +++
backports/v2.6_rc_main_bsearch_h.patch | 10 ++++++++++
v4l/compat.h | 25 +++++++++++++++++++++++++
v4l/scripts/make_config_compat.pl | 1 +
4 files changed, 39 insertions(+)
create mode 100644 backports/v2.6_rc_main_bsearch_h.patch
Comments
Hi!
Even with this patch Kernel 2.6.x still can't be compiled due to
the next error "ida_simple_get" missing.
I will try to fix the "ida_simple_get" error tomorrow.
BR,
Jasmin
@@ -127,6 +127,9 @@ add no_atomic_include.patch
add v4l2-compat-timespec.patch
add v3.0_ida2bit.patch
+[2.6.39]
+add v2.6_rc_main_bsearch_h.patch
+
[2.6.38]
add v2.6.38_use_getkeycode_new_setkeycode_new.patch
add v2.6.38_config_of_for_of_node.patch
new file mode 100644
@@ -0,0 +1,10 @@
+--- a/drivers/media/rc/rc-main.c
++++ b/drivers/media/rc/rc-main.c
+@@ -16,7 +16,6 @@
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <media/rc-core.h>
+-#include <linux/bsearch.h>
+ #include <linux/spinlock.h>
+ #include <linux/delay.h>
+ #include <linux/input.h>
@@ -2170,4 +2170,29 @@ static inline unsigned long nsecs_to_jiffies_static(u64 n)
#define U32_MAX ((u32)~0U)
#endif
+#ifdef NEED_BSEARCH
+static inline void *bsearch(const void *key, const void *base, size_t num, size_t size,
+ int (*cmp)(const void *key, const void *elt))
+{
+ const char *pivot;
+ int result;
+
+ while (num > 0) {
+ pivot = base + (num >> 1) * size;
+ result = cmp(key, pivot);
+
+ if (result == 0)
+ return (void *)pivot;
+
+ if (result > 0) {
+ base = pivot + size;
+ num--;
+ }
+ num >>= 1;
+ }
+
+ return NULL;
+}
+#endif
+
#endif /* _COMPAT_H */
@@ -705,6 +705,7 @@ sub check_other_dependencies()
check_files_for_func("PCI_DEVICE_SUB", "NEED_PCI_DEVICE_SUB", "include/linux/pci.h");
check_files_for_func("annotate_reachable", "NEED_ANNOTATE_REACHABLE", "include/linux/compiler.h");
check_files_for_func("U32_MAX", "NEED_U32_MAX", "include/linux/kernel.h");
+ check_files_for_func("bsearch", "NEED_BSEARCH", "include/linux/bsearch.h");
# For tests for uapi-dependent logic
check_files_for_func_uapi("usb_endpoint_maxp", "NEED_USB_ENDPOINT_MAXP", "usb/ch9.h");