From 9f0d88695ed6691a3e18c256d9d49862b3af6e34 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 5 Jun 2024 10:34:17 +0300 Subject: libcamera: dma_buf_allocator: Work around lack of memfd_create() in uClibc uClibc doesn't provide a memfd_create() implementation. Fix it by using a direct syscall when the function isn't available. Fixes: ea4baaacc325 ("libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf") Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Hans de Goede --- src/libcamera/dma_buf_allocator.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp index 5ec29949..d7d08e18 100644 --- a/src/libcamera/dma_buf_allocator.cpp +++ b/src/libcamera/dma_buf_allocator.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -132,7 +133,11 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size) std::size_t pageMask = sysconf(_SC_PAGESIZE) - 1; size = (size + pageMask) & ~pageMask; +#if HAVE_MEMFD_CREATE int ret = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC); +#else + int ret = syscall(SYS_memfd_create, name, MFD_ALLOW_SEALING | MFD_CLOEXEC); +#endif if (ret < 0) { ret = errno; LOG(DmaBufAllocator, Error) -- cgit v1.2.1