F´ Flight Software - C/C++ Documentation
devel
A framework for building embedded system applications to NASA flight quality standards.
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
z
Functions
a
b
c
d
g
h
i
m
o
p
r
s
t
v
w
Variables
Typedefs
a
b
c
d
e
f
g
h
l
o
p
r
s
t
u
w
Enumerations
Enumerator
a
b
c
f
h
i
n
o
p
s
v
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
w
Typedefs
c
e
s
t
u
w
Enumerations
b
c
d
g
h
m
o
q
s
t
u
w
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Related Symbols
a
b
c
d
f
g
h
l
p
r
s
t
u
Files
File List
File Members
All
_
a
b
c
d
f
g
h
i
l
m
n
p
r
s
t
u
v
Functions
c
i
m
p
s
u
Variables
_
b
c
f
i
l
p
r
s
Typedefs
b
c
f
i
n
p
s
u
Enumerations
Enumerator
a
b
c
d
f
g
h
p
r
s
t
Macros
_
a
c
d
f
g
h
i
l
m
p
r
s
t
u
v
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
MmapAllocator.cpp
Go to the documentation of this file.
1
13
#include <
Fw/Types/MmapAllocator.hpp
>
14
#include <cstdlib>
15
#include <sys/mman.h>
16
#include <
Fw/Types/Assert.hpp
>
17
18
namespace
Fw
{
19
20
MmapAllocator::MmapAllocator
() : m_length(0) {
21
}
20
MmapAllocator::MmapAllocator
() : m_length(0) {
…
}
22
23
MmapAllocator::~MmapAllocator
() {
24
}
23
MmapAllocator::~MmapAllocator
() {
…
}
25
26
void
*
MmapAllocator::allocate
(
const
NATIVE_UINT_TYPE
identifier,
NATIVE_UINT_TYPE
&size,
bool
& recoverable) {
27
void
* addr = mmap(
nullptr
, size, PROT_READ | PROT_WRITE,
28
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
29
if
(addr == MAP_FAILED) {
30
size = 0;
31
return
nullptr
;
32
}
33
this->m_length = size;
34
35
// mmap memory is never recoverable
36
recoverable =
false
;
37
38
return
addr;
39
}
26
void
*
MmapAllocator::allocate
(
const
NATIVE_UINT_TYPE
identifier,
NATIVE_UINT_TYPE
&size,
bool
& recoverable) {
…
}
40
41
void
MmapAllocator::deallocate
(
const
NATIVE_UINT_TYPE
identifier,
void
* ptr) {
42
if
(this->m_length) {
43
int
stat = munmap(ptr, this->m_length);
44
FW_ASSERT
(stat == 0, stat);
45
}
46
}
41
void
MmapAllocator::deallocate
(
const
NATIVE_UINT_TYPE
identifier,
void
* ptr) {
…
}
47
48
}
/* namespace Fw */
Assert.hpp
FW_ASSERT
#define FW_ASSERT(...)
Definition
Assert.hpp:14
NATIVE_UINT_TYPE
PlatformUIntType NATIVE_UINT_TYPE
Definition
BasicTypes.h:52
MmapAllocator.hpp
A MemAllocator implementation class that uses mmap.
Fw::MmapAllocator::MmapAllocator
MmapAllocator()
Definition
MmapAllocator.cpp:20
Fw::MmapAllocator::deallocate
void deallocate(const NATIVE_UINT_TYPE identifier, void *ptr)
Definition
MmapAllocator.cpp:41
Fw::MmapAllocator::~MmapAllocator
virtual ~MmapAllocator()
Destructor with no arguments.
Definition
MmapAllocator.cpp:23
Fw::MmapAllocator::allocate
void * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)
Definition
MmapAllocator.cpp:26
Fw
Definition
FppConstantsAc.hpp:98
Fw
Types
MmapAllocator.cpp
Generated by
1.10.0