Loading...
Searching...
No Matches
memfd.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2024, Ideas on Board Oy
*
* Anonymous file creation
*/
#pragma once
#include <libcamera/base/flags.h>
#include <libcamera/base/unique_fd.h>
namespace libcamera {
class MemFd
{
public:
enum class Seal {
None = 0,
Shrink = (1 << 0),
Grow = (1 << 1),
};
using Seals = Flags<Seal>;
static UniqueFD create(const char *name, std::size_t size,
Seals seals = Seal::None);
};
LIBCAMERA_FLAGS_ENABLE_OPERATORS(MemFd::Seal)
} /* namespace libcamera */
libcamera::Flags
Type-safe container for enum-based bitfields.
Definition flags.h:16
libcamera::MemFd
Helper class to create anonymous files.
Definition memfd.h:16
libcamera::MemFd::Seal
Seal
Seals for the MemFd::create() function.
Definition memfd.h:18
libcamera::MemFd::Seal::Shrink
@ Shrink
Prevent the memfd from shrinking.
Definition memfd.h:20
libcamera::MemFd::Seal::None
@ None
No seals (used as default value).
Definition memfd.h:19
libcamera::MemFd::Seal::Grow
@ Grow
Prevent the memfd from growing.
Definition memfd.h:21
libcamera::MemFd::create
static UniqueFD create(const char *name, std::size_t size, Seals seals=Seal::None)
Create an anonymous file.
Definition memfd.cpp:84
libcamera::MemFd::Seals
Flags< Seal > Seals
A bitwise combination of MemFd::Seal values.
Definition memfd.h:24
libcamera::UniqueFD
unique_ptr-like wrapper for a file descriptor
Definition unique_fd.h:17
flags.h
Enum-based bit fields.
LIBCAMERA_FLAGS_ENABLE_OPERATORS
#define LIBCAMERA_FLAGS_ENABLE_OPERATORS(_enum)
Enable bitwise operations on the enum enumeration.
Definition flags.h:189
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
unique_fd.h
File descriptor wrapper that owns a file descriptor.