libcamera v0.5.0
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
memfd.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2024, Ideas on Board Oy
4 *
5 * Anonymous file creation
6 */
7
8#pragma once
9
12
13// Flags for memfd_create (glibc < 2.27)
14#ifndef MFD_CLOEXEC
15#define MFD_CLOEXEC 1U
16#define MFD_ALLOW_SEALING 2U
17#endif
18
19namespace libcamera {
20
21class MemFd
22{
23public:
24 enum class Seal {
25 None = 0,
26 Shrink = (1 << 0),
27 Grow = (1 << 1),
28 };
29
31
32 static UniqueFD create(const char *name, std::size_t size,
33 Seals seals = Seal::None);
34};
35
37
38} /* namespace libcamera */
Type-safe container for enum-based bitfields.
Definition flags.h:16
Helper class to create anonymous files.
Definition memfd.h:22
Seal
Seals for the MemFd::create() function.
Definition memfd.h:24
@ Shrink
Prevent the memfd from shrinking.
@ None
No seals (used as default value)
@ Grow
Prevent the memfd from growing.
static UniqueFD create(const char *name, std::size_t size, Seals seals=Seal::None)
Create an anonymous file.
Definition memfd.cpp:84
unique_ptr-like wrapper for a file descriptor
Definition unique_fd.h:17
Enum-based bit fields.
#define LIBCAMERA_FLAGS_ENABLE_OPERATORS(_enum)
Enable bitwise operations on the enum enumeration.
Definition flags.h:189
Top-level libcamera namespace.
Definition backtrace.h:17
File descriptor wrapper that owns a file descriptor.