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: ea4baaacc3 ("libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Laurent Pinchart
2024-06-05 15:11:21 +03:00
parent 9c2ca46391
commit 9f0d88695e
+5
View File
@@ -13,6 +13,7 @@
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
@@ -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)