ffmpeg: fix build with gcc14 and musl ioctl type

This commit is contained in:
oreo639 2025-03-16 02:36:49 -07:00 committed by oreo639
parent 2c00367383
commit 6308f117fb
2 changed files with 118 additions and 0 deletions

View file

@ -0,0 +1,31 @@
From 7405f1ad5351cc24b91a0227aeeaf24ff9d12278 Mon Sep 17 00:00:00 2001
From: Ramiro Polla <ramiro.polla@gmail.com>
Date: Wed, 3 Jul 2024 00:30:08 +0200
Subject: [PATCH] configure: restore autodetection of v4l2 and fbdev
The detection logic for v4l2 and fbdev was accidentally modified to
depend on v4l2-m2m in 43b3412.
---
configure | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index b28221f258965..fa2e384350958 100755
--- a/configure
+++ b/configure
@@ -7145,11 +7145,12 @@ pod2man --help > /dev/null 2>&1 && enable pod2man || disable pod2man
rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
xmllint --version > /dev/null 2>&1 && enable xmllint || disable xmllint
+check_headers linux/fb.h
+check_headers linux/videodev2.h
+test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
+
# check V4L2 codecs available in the API
if enabled v4l2_m2m; then
- check_headers linux/fb.h
- check_headers linux/videodev2.h
- test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;"
check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;"
check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;"

View file

@ -0,0 +1,87 @@
From 008b0b4a3b0cbafa568d0dcbf78c798d56929802 Mon Sep 17 00:00:00 2001
From: Brad Smith <brad-at-comstyle.com@ffmpeg.org>
Date: Sun, 5 May 2024 23:59:47 -0400
Subject: [PATCH] lavd/v4l2: Use proper field type for second parameter of
ioctl() with BSD's
The proper type was used until 73251678c83cbe24d08264da693411b166239bc7.
This covers all of the OS's that currently have V4L2 support, permutations
of Linux glibc/musl, Android bionic, FreeBSD, NetBSD, OpenBSD, Solaris.
Copied from FreeBSD ports patch.
Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 9e674b31606c805dd31b4bb754364a72a5877238)
Signed-off-by: Brad Smith <brad@comstyle.com>
---
libavdevice/v4l2.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 365bacd7714b6..1dcbe04bb1741 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -95,10 +95,10 @@ struct video_data {
int (*open_f)(const char *file, int oflag, ...);
int (*close_f)(int fd);
int (*dup_f)(int fd);
-#ifdef __GLIBC__
- int (*ioctl_f)(int fd, unsigned long int request, ...);
-#else
+#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /* POSIX-like */
int (*ioctl_f)(int fd, int request, ...);
+#else
+ int (*ioctl_f)(int fd, unsigned long int request, ...);
#endif
ssize_t (*read_f)(int fd, void *buffer, size_t n);
void *(*mmap_f)(void *start, size_t length, int prot, int flags, int fd, int64_t offset);
From af17f55202e285d4d3d502078e5b6a41bcca90fb Mon Sep 17 00:00:00 2001
From: Ramiro Polla <ramiro.polla@gmail.com>
Date: Thu, 29 Aug 2024 15:40:00 +0200
Subject: [PATCH] configure: improve check for POSIX ioctl
Instead of relying on system #ifdefs which may or may not be correct,
detect the POSIX ioctl signature at configure time.
(cherry picked from commit 00b64fca55a3a009c9d0e391c85f4fd3291e5d12)
Signed-off-by: Brad Smith <brad@comstyle.com>
---
configure | 2 ++
libavdevice/v4l2.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index c89d3ad1ec291..175b70e20735c 100755
--- a/configure
+++ b/configure
@@ -2340,6 +2340,7 @@ HAVE_LIST="
opencl_vaapi_intel_media
perl
pod2man
+ posix_ioctl
texi2html
"
@@ -6616,6 +6617,7 @@ rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || d
check_headers linux/fb.h
check_headers linux/videodev2.h
test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
+test_code cc sys/ioctl.h "int ioctl(int, int, ...)" && enable posix_ioctl
# check V4L2 codecs available in the API
if enabled v4l2_m2m; then
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 1dcbe04bb1741..f90490eebfc86 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -95,7 +95,7 @@ struct video_data {
int (*open_f)(const char *file, int oflag, ...);
int (*close_f)(int fd);
int (*dup_f)(int fd);
-#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /* POSIX-like */
+#if HAVE_POSIX_IOCTL
int (*ioctl_f)(int fd, int request, ...);
#else
int (*ioctl_f)(int fd, unsigned long int request, ...);