v4l2-tracer: wrap open64/mmap64 functions only if linux && __GLIBC__
Subsystems (2)
PATCH 1/2 v4l2-tracer: wrap open64/mmap64 functions only if linux && __GLIBC__
Wrap open64/mmap64 functions only if linux && __GLIBC__, as done in lib/libv4l1/v4l1comapt.c and lib/libv4l2/v4l2convert.c since commit 'libv4l: Wrap LFS64 functions only if linux && __GLIBC__' (403a4e2697a1ff96fe2fa16589039595f21cadf0), should fix musl libc compile.
Signed-off-by Peter Seiderer <[email protected]>
--- utils/v4l2-tracer/libv4l2tracer.cpp | 4 ++++ 1 file changed, 4 insertions(+)
utils/v4l2-tracer/libv4l2tracer.cpp +4 -0
@@ -89,6 +89,7 @@ int open(const char *path, int oflag, ...) return fd; } +#if defined(linux) && defined(__GLIBC__) int open64(const char *path, int oflag, ...) { errno = 0;
@@ -124,6 +125,7 @@ int open64(const char *path, int oflag, ...) return fd; } +#endif int close(int fd) {
@@ -177,6 +179,7 @@ void *mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) return buf_address_pointer; } +#if defined(linux) && defined(__GLIBC__) void *mmap64(void *addr, size_t len, int prot, int flags, int fildes, off_t off) { errno = 0;
@@ -191,6 +194,7 @@ void *mmap64(void *addr, size_t len, int prot, int flags, int fildes, off_t off) return buf_address_pointer; } +#endif int munmap(void *start, size_t length) {
Signature · 1 line
2.40.0
PATCH 2/2 libv4l1/libv4l2/v4l2-tracer: use common meson c_args/cpp_args to disable transparent large file support
Use common meson c_args/cpp_args to disable transparent large file support for the wrappers as already done in utils/v4l2-tracer for lib/libv4l1/v4l1compat.c and lib/libv4l2/v4l2convert.c too.
Signed-off-by Peter Seiderer <[email protected]>
--- lib/libv4l1/meson.build | 1 + lib/libv4l1/v4l1compat.c | 5 ----- lib/libv4l2/meson.build | 1 + lib/libv4l2/v4l2convert.c | 5 ----- meson.build | 10 ++++++++++ utils/v4l2-tracer/meson.build | 13 +------------ 6 files changed, 13 insertions(+), 22 deletions(-)
lib/libv4l1/meson.build +1 -0
@@ -60,5 +60,6 @@ v4l1compat = shared_module('v4l1compat', name_prefix : '', install : true, install_dir : libv4l1privdir, + c_args : v4l2_wrapper_args, dependencies : v4l1compat_deps, include_directories : v4l2_utils_incdir)
lib/libv4l1/v4l1compat.c +0 -5
@@ -19,11 +19,6 @@# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ -/* ensure we see *64 variants and they aren't transparently used */ -#undef _LARGEFILE_SOURCE -#undef _FILE_OFFSET_BITS -#define _LARGEFILE64_SOURCE 1 -#include <stdlib.h> #include <stdarg.h> #include <fcntl.h>
lib/libv4l2/meson.build +1 -0
@@ -69,5 +69,6 @@ v4l2convert = shared_module('v4l2convert', name_prefix : '', install : true, install_dir : libv4l2privdir, + c_args : v4l2_wrapper_args, dependencies : v4l2convert_deps, include_directories : v4l2_utils_incdir)
lib/libv4l2/v4l2convert.c +0 -5
@@ -23,11 +23,6 @@/* prevent GCC 4.7 inlining error */ #undef _FORTIFY_SOURCE -/* ensure we see *64 variants and they aren't transparently used */ -#undef _LARGEFILE_SOURCE -#undef _FILE_OFFSET_BITS -#define _LARGEFILE64_SOURCE 1 -#include <stdarg.h> #include <stdlib.h> #include <fcntl.h>
meson.build +10 -0
@@ -47,6 +47,16 @@ common_arguments = [ '-include', meson.current_build_dir() / 'config.h', ] +v4l2_wrapper_args = [ + # As the library needs to provide both 32-bit and 64-bit versions + # of file operations, disable transparent large file support (fixes + # 'Error: symbol `open64/mmap64' is already defined' compile failure + # otherwise) + '-U_FILE_OFFSET_BITS', + '-D_FILE_OFFSET_BITS=32', + '-D_LARGEFILE64_SOURCE', +] + v4l2_utils_incdir_arr = [ 'lib' / 'include', ]
utils/v4l2-tracer/meson.build +1 -12
@@ -70,21 +70,10 @@ libv4l2_tracer_incdir = [ v4l2_utils_incdir, ] -libv4l2_tracer_cpp_args = [ - # Meson enables large file support unconditionally, which redirects file - # operations to 64-bit versions. This results in some symbols being - # renamed, for instance open() being renamed to open64(). As the library - # needs to provide both 32-bit and 64-bit versions of file operations, - # disable transparent large file support. - '-U_FILE_OFFSET_BITS', - '-D_FILE_OFFSET_BITS=32', - '-D_LARGEFILE64_SOURCE', -] - libv4l2tracer = shared_module('v4l2tracer', libv4l2tracer_sources, install : true, - cpp_args : libv4l2_tracer_cpp_args, + cpp_args : v4l2_wrapper_args, dependencies : libv4l2tracer_deps, include_directories : libv4l2_tracer_incdir)
Signature · 1 line
2.40.0