LLVM: include/llvm/CAS/MappedFileRegionArena.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef LLVM_CAS_MAPPEDFILEREGIONARENA_H
16#define LLVM_CAS_MAPPEDFILEREGIONARENA_H
17
20#include
21
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
39public:
41
42
43
44
55
56
57
58
59
60
61
62
63
67
68
70
71 struct alignas(8) T {};
72 static_assert(alignof(T) == 8, "Tautology failed?");
74 }
75
76
80 return Offset.takeError();
82 }
83
85
86 char *data() const { return Region.data(); }
89
91
93
97 destroyImpl();
98 moveImpl(RHS);
99 return *this;
100 }
101
104
105private:
106
107 void initializeHeader(uint64_t HeaderOffset);
108
116 }
117
118private:
120 Header *H = nullptr;
121 std::string Path;
122
123 std::optional FD;
124
125 std::optional SharedLockFD;
126};
127
128}
129
130#endif
#define LLVM_UNLIKELY(EXPR)
#define LLVM_ABI_FOR_TEST
Tagged union holding either a T or a Error.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
MappedFileRegionArena()=default
uint64_t capacity() const
Definition MappedFileRegionArena.h:88
uint64_t size() const
Definition MappedFileRegionArena.h:87
MappedFileRegionArena & operator=(MappedFileRegionArena &&RHS)
Definition MappedFileRegionArena.h:96
MappedFileRegionArena(const MappedFileRegionArena &)=delete
LLVM_ABI_FOR_TEST Expected< int64_t > allocateOffset(uint64_t AllocSize)
Allocate, returning the offset from data() instead of a pointer.
MappedFileRegionArena(MappedFileRegionArena &&RHS)
Definition MappedFileRegionArena.h:95
Expected< char * > allocate(uint64_t AllocSize)
Allocate at least AllocSize. Rounds up to getAlign().
Definition MappedFileRegionArena.h:77
static LLVM_ABI_FOR_TEST Expected< MappedFileRegionArena > create(const Twine &Path, uint64_t Capacity, uint64_t HeaderOffset, function_ref< Error(MappedFileRegionArena &)> NewFileConstructor)
Create a MappedFileRegionArena.
static constexpr Align getAlign()
Minimum alignment for allocations, currently hardcoded to 8B.
Definition MappedFileRegionArena.h:69
RegionT & getRegion()
Definition MappedFileRegionArena.h:90
sys::fs::mapped_file_region RegionT
Definition MappedFileRegionArena.h:40
~MappedFileRegionArena()
Definition MappedFileRegionArena.h:92
char * data() const
Definition MappedFileRegionArena.h:86
MappedFileRegionArena & operator=(const MappedFileRegionArena &)=delete
An efficient, type-erasing, non-owning reference to a callable.
This class represents a memory mapped file.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static constexpr Align Of()
Allow constructions of constexpr Align from types.