|
1 | | -From fd882f9e77b13cbc6a669e6836c3943393b44152 Mon Sep 17 00:00:00 2001 |
2 | | -From: Michal Rostecki <vadorovsky@gmail.com> |
3 | | -Date: Fri, 6 Sep 2024 14:46:31 +0200 |
4 | | -Subject: libv4l2: Guard the v4l2_ioctl function with HAVE_POSIX_IOCTL |
| 1 | +Ensure that LIBV4L_HAVE_POSIX_IOCTL define is used when linking with other packages. |
5 | 2 |
|
6 | | -Lack of this check leads to issues on musl-based system. Even though |
7 | | -compilation of libv4l2 itself with musl doesn't cause any errors, |
8 | | -using the library inside gst-plugins-v4l2 causes a compiler error |
9 | | -due to mismatch of the ioctl signature. |
10 | | - |
11 | | -A similar check is already performed in v4l2convert.c, so the change |
12 | | -doesn't bring any inconsistency. |
13 | | - |
14 | | -Link: https://bugs.gentoo.org/896418 |
15 | | -Signed-off-by: Michal Rostecki <vadorovsky@gmail.com> |
16 | | -Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> |
17 | | ---- |
18 | | - lib/include/libv4l2.h | 4 ++++ |
19 | | - lib/libv4l2/libv4l2.c | 4 ++++ |
20 | | - 2 files changed, 8 insertions(+) |
21 | | - |
22 | | -diff --git a/lib/include/libv4l2.h b/lib/include/libv4l2.h |
23 | | -index ea1870db..16565555 100644 |
24 | | ---- a/lib/include/libv4l2.h |
25 | | -+++ b/lib/include/libv4l2.h |
26 | | -@@ -63,7 +63,11 @@ LIBV4L_PUBLIC extern FILE *v4l2_log_file; |
27 | | - LIBV4L_PUBLIC int v4l2_open(const char *file, int oflag, ...); |
28 | | - LIBV4L_PUBLIC int v4l2_close(int fd); |
29 | | - LIBV4L_PUBLIC int v4l2_dup(int fd); |
30 | | -+#ifdef HAVE_POSIX_IOCTL |
31 | | -+LIBV4L_PUBLIC int v4l2_ioctl(int fd, int request, ...); |
32 | | -+#else |
33 | | - LIBV4L_PUBLIC int v4l2_ioctl(int fd, unsigned long int request, ...); |
34 | | -+#endif |
35 | | - LIBV4L_PUBLIC ssize_t v4l2_read(int fd, void *buffer, size_t n); |
36 | | - LIBV4L_PUBLIC ssize_t v4l2_write(int fd, const void *buffer, size_t n); |
37 | | - LIBV4L_PUBLIC void *v4l2_mmap(void *start, size_t length, int prot, int flags, |
38 | | -diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c |
39 | | -index 032a4f1c..1607ec35 100644 |
40 | | ---- a/lib/libv4l2/libv4l2.c |
41 | | -+++ b/lib/libv4l2/libv4l2.c |
42 | | -@@ -1051,7 +1051,11 @@ static int v4l2_s_fmt(int index, struct v4l2_format *dest_fmt) |
43 | | - return 0; |
44 | | - } |
| 3 | +diff -rup meson.build.orig meson.build |
| 4 | +--- a/meson.build.orig |
| 5 | ++++ b/meson.build |
| 6 | +@@ -383,12 +383,14 @@ if have_qt_opengl |
| 7 | + conf.set('HAVE_QTGL', 1) |
| 8 | + endif |
| 9 | + |
| 10 | ++pkg_arguments = [] |
| 11 | + ioctl_posix_test = ''' |
| 12 | + #include <sys/ioctl.h> |
| 13 | + int ioctl (int, int, ...); |
| 14 | + ''' |
| 15 | + if cc.compiles(ioctl_posix_test) |
| 16 | + conf.set('LIBV4L_HAVE_POSIX_IOCTL', 1) |
| 17 | ++ pkg_arguments += '-DLIBV4L_HAVE_POSIX_IOCTL=1' |
| 18 | + endif |
| 19 | + |
| 20 | + c_arguments = [] |
| 21 | +diff -rup lib/libv4l2/meson.build.orig lib/libv4l2/meson.build |
| 22 | +--- a/lib/libv4l2/meson.build.orig |
| 23 | ++++ b/lib/libv4l2/meson.build |
| 24 | +@@ -48,7 +48,8 @@ pkg.generate( |
| 25 | + name : 'libv4l2', |
| 26 | + version : meson.project_version(), |
| 27 | + requires_private : 'libv4lconvert', |
| 28 | +- description : 'v4l2 device access library') |
| 29 | ++ description : 'v4l2 device access library', |
| 30 | ++ extra_cflags : pkg_arguments) |
45 | 31 |
|
46 | | -+#ifdef HAVE_POSIX_IOCTL |
47 | | -+int v4l2_ioctl(int fd, int request, ...) |
48 | | -+#else |
49 | | - int v4l2_ioctl(int fd, unsigned long int request, ...) |
50 | | -+#endif |
51 | | - { |
52 | | - void *arg; |
53 | | - va_list ap; |
54 | | --- |
55 | | -cgit v1.2.3 |
| 32 | + if not get_option('v4l-wrappers') |
| 33 | + subdir_done() |
56 | 34 |
|
0 commit comments