Test for ioctl() function signature
PATCH 2/4 Test for ioctl() function signature
On glibc, ioctl has the signature ioctl(int, unsigned long int, ...). On musl, libc and according to POSIX it is ioctl(int, int, ...). Add a configure test adapted from gnulib's ioctl.m4 to make the DL_PRELOAD libraries work for both signatures.
--- configure.ac | 12 ++++++++++++ lib/libv4l1/v4l1compat.c | 4 ++++ lib/libv4l2/v4l2convert.c | 4 ++++ 3 files changed, 20 insertions(+)
configure.ac +12 -0
@@ -116,6 +116,18 @@ gl_VISIBILITY AC_CHECK_HEADERS([sys/klog.h]) AC_CHECK_FUNCS([klogctl]) +AC_CACHE_CHECK([for ioctl with POSIX signature], + [gl_cv_func_ioctl_posix_signature], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <sys/ioctl.h>]], + [[int ioctl (int, int, ...);]]) + ], + [gl_cv_func_ioctl_posix_signature=yes], + [gl_cv_func_ioctl_posix_signature=no]) + ]) +AC_DEFINE([HAVE_POSIX_IOCTL], [1], [test x$gl_cv_func_ioctl_posix_signature = xyes]) + AC_CHECK_FUNCS([__secure_getenv secure_getenv]) # Check host os
lib/libv4l1/v4l1compat.c +4 -0
@@ -93,7 +93,11 @@ LIBV4L_PUBLIC int dup(int fd)return v4l1_dup (fd); } +#ifdef HAVE_POSIX_IOCTL +LIBV4L_PUBLIC int ioctl(int fd, int request, ...) +#else LIBV4L_PUBLIC int ioctl(int fd, unsigned long int request, ...) +#endif {void *arg;va_list ap;
lib/libv4l2/v4l2convert.c +4 -0
@@ -121,7 +121,11 @@ LIBV4L_PUBLIC int dup(int fd)return v4l2_dup (fd); } +#ifdef HAVE_POSIX_IOCTL +LIBV4L_PUBLIC int ioctl(int fd, int request, ...) +#else LIBV4L_PUBLIC int ioctl(int fd, unsigned long int request, ...) +#endif {void *arg;va_list ap;
Signature · 1 line
2.0.5
Em Sun, 25 Jan 2015 21:36:25 +0100
Felix Janda <[email protected]> escreveu:
Quoted 4 lines
On glibc, ioctl has the signature
ioctl(int, unsigned long int, ...). On musl, libc and according to POSIX it isioctl(int, int, ...). Add a configure test adapted from gnulib's ioctl.m4 to make theDL_PRELOADlibraries work for both signatures.
This patch breaks compilation on Fedora:
v4l2convert.c:130:45: error: conflicting types for 'ioctl'
LIBV4L_PUBLIC int ioctl(int fd, int request, ...)
^
In file included from v4l2convert.c:37:0:
/usr/include/sys/ioctl.h:41:12: note: previous declaration of 'ioctl' was here
extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
^Quoted 63 lines
Signed-off-by Felix Janda <[email protected]>--- configure.ac | 12 ++++++++++++ lib/libv4l1/v4l1compat.c | 4 ++++ lib/libv4l2/v4l2convert.c | 4 ++++ 3 files changed, 20 insertions(+)configure.ac +12
-0@@ -116,6 +116,18 @@ gl_VISIBILITY AC_CHECK_HEADERS([sys/klog.h]) AC_CHECK_FUNCS([klogctl]) +AC_CACHE_CHECK([for ioctl with POSIX signature], + [gl_cv_func_ioctl_posix_signature], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <sys/ioctl.h>]], + [[int ioctl (int, int, ...);]]) + ], + [gl_cv_func_ioctl_posix_signature=yes], + [gl_cv_func_ioctl_posix_signature=no]) + ]) +AC_DEFINE([HAVE_POSIX_IOCTL], [1], [test x$gl_cv_func_ioctl_posix_signature = xyes]) + AC_CHECK_FUNCS([__secure_getenv secure_getenv]) # Check host oslib/libv4l1/v4l1compat.c +4
-0@@ -93,7 +93,11 @@ LIBV4L_PUBLIC int dup(int fd)return v4l1_dup (fd); } +#ifdef HAVE_POSIX_IOCTL +LIBV4L_PUBLIC int ioctl(int fd, int request, ...) +#else LIBV4L_PUBLIC int ioctl(int fd, unsigned long int request, ...) +#endif {void *arg;va_list ap;lib/libv4l2/v4l2convert.c +4
-0@@ -121,7 +121,11 @@ LIBV4L_PUBLIC int dup(int fd)return v4l2_dup (fd); } +#ifdef HAVE_POSIX_IOCTL +LIBV4L_PUBLIC int ioctl(int fd, int request, ...) +#else LIBV4L_PUBLIC int ioctl(int fd, unsigned long int request, ...) +#endif {void *arg;va_list ap;
PATCH v2 2/4 Test for ioctl() function signature
On glibc, ioctl has the signature ioctl(int, unsigned long int, ...). On musl, libc and according to POSIX it is ioctl(int, int, ...). Add a configure test adapted from gnulib's ioctl.m4 to make the DL_PRELOAD libraries work for both signatures.
---
v2: Fix declaration of HAVE_POSIX_IOCTL
Quoted 11 lines · Mauro Carvalho Chehab
Em Sun, 25 Jan 2015 21:36:25 +0100
Felix Janda <[email protected]> escreveu:Quoted 4 lines
On glibc, ioctl has the signature
ioctl(int, unsigned long int, ...). On musl, libc and according to POSIX it isioctl(int, int, ...). Add a configure test adapted from gnulib's ioctl.m4 to make theDL_PRELOADlibraries work for both signatures.This patch breaks compilation on Fedora:
Quoted 7 lines
v4l2convert.c:130:45: error: conflicting types for 'ioctl'
LIBV4L_PUBLICintioctl(int fd, int request, ...)^ In file included from v4l2convert.c:37:0: /usr/include/sys/ioctl.h:41:12: note: previous declaration of 'ioctl' was here extern int ioctl (int __fd, unsigned long int __request, ...) __THROW; ^
Sorry for the bad patch.
./configure will have correctly identified in your case that ioctl does not have the POSIX signature, but by my mistake it still put
#define HAVE_POSIX_IOCTL 1
into config.h. Should be fixed with this patch.
--- configure.ac | 14 ++++++++++++++ lib/libv4l1/v4l1compat.c | 4 ++++ lib/libv4l2/v4l2convert.c | 4 ++++ 3 files changed, 22 insertions(+)
configure.ac +14 -0
@@ -118,6 +118,20 @@ gl_VISIBILITY AC_CHECK_HEADERS([sys/klog.h]) AC_CHECK_FUNCS([klogctl]) +AC_CACHE_CHECK([for ioctl with POSIX signature], + [gl_cv_func_ioctl_posix_signature], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <sys/ioctl.h>]], + [[int ioctl (int, int, ...);]]) + ], + [gl_cv_func_ioctl_posix_signature=yes], + [gl_cv_func_ioctl_posix_signature=no]) + ]) +if test "x$gl_cv_func_ioctl_posix_signature" = xyes; then + AC_DEFINE([HAVE_POSIX_IOCTL], [1], [Have ioctl with POSIX signature]) +fi + AC_CHECK_FUNCS([__secure_getenv secure_getenv]) # Check host os
lib/libv4l1/v4l1compat.c +4 -0
@@ -94,7 +94,11 @@ LIBV4L_PUBLIC int dup(int fd)return v4l1_dup (fd); } +#ifdef HAVE_POSIX_IOCTL +LIBV4L_PUBLIC int ioctl(int fd, int request, ...) +#else LIBV4L_PUBLIC int ioctl(int fd, unsigned long int request, ...) +#endif {void *arg;va_list ap;
lib/libv4l2/v4l2convert.c +4 -0
@@ -126,7 +126,11 @@ LIBV4L_PUBLIC int dup(int fd)return v4l2_dup (fd); } +#ifdef HAVE_POSIX_IOCTL +LIBV4L_PUBLIC int ioctl(int fd, int request, ...) +#else LIBV4L_PUBLIC int ioctl(int fd, unsigned long int request, ...) +#endif {void *arg;va_list ap;
Signature · 1 line
2.3.6