F´ Flight Software - C/C++ Documentation
NASA-v2.0.1
A framework for building embedded system applications to NASA flight quality standards.
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Functions
a
b
c
d
g
h
i
m
r
s
t
v
w
Variables
Typedefs
Enumerations
Enumerator
a
b
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
b
d
e
f
g
h
i
l
m
n
p
q
s
t
u
v
w
Typedefs
Enumerations
Enumerator
a
b
c
d
e
f
g
h
l
m
n
o
p
q
r
s
t
w
Related Functions
Files
File List
File Members
All
_
a
b
c
d
f
g
h
i
k
l
m
n
p
r
s
t
u
v
Functions
f
i
m
s
u
Variables
Typedefs
Enumerations
Enumerator
c
d
f
m
p
r
s
t
Macros
a
c
d
f
g
h
i
k
l
m
n
p
r
s
t
u
v
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
MmapAllocator.cpp
Go to the documentation of this file.
1
13
#include <
Fw/Types/MmapAllocator.hpp
>
14
#include <stdlib.h>
15
#include <sys/mman.h>
16
#include <
Fw/Types/Assert.hpp
>
17
18
namespace
Fw
{
19
20
MmapAllocator::MmapAllocator
() : m_length(0) {
21
}
22
23
MmapAllocator::~MmapAllocator
() {
24
}
25
26
void
*
MmapAllocator::allocate
(
const
NATIVE_UINT_TYPE
identifier,
NATIVE_UINT_TYPE
&size,
bool
& recoverable) {
27
void
* addr = mmap(
NULL
, size, PROT_READ | PROT_WRITE,
28
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
29
if
(addr == MAP_FAILED) {
30
size = 0;
31
return
NULL
;
32
}
33
this->m_length = size;
34
35
// mmap memory is never recoverable
36
recoverable =
false
;
37
38
return
addr;
39
}
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
}
47
48
}
/* namespace Fw */
Assert.hpp
MmapAllocator.hpp
A MemAllocator implementation class that uses mmap.
Fw::MmapAllocator::~MmapAllocator
virtual ~MmapAllocator()
Destructor with no arguments.
Definition:
MmapAllocator.cpp:23
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition:
BasicTypes.hpp:30
FW_ASSERT
#define FW_ASSERT(...)
Definition:
Assert.hpp:9
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::allocate
void * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)
Definition:
MmapAllocator.cpp:26
NULL
#define NULL
NULL.
Definition:
BasicTypes.hpp:100
Fw
Definition:
Buffer.cpp:21
Fw
Types
MmapAllocator.cpp
Generated by
1.8.17