Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLASfpga
VILLASfpga
Commits
4471d735
Commit
4471d735
authored
Sep 20, 2018
by
Daniel Krebs
Browse files
mm/translation: let user choose the return type as template parameter
this can avoid sooo many reinterpret_cast<> in application code
parent
d10917d3
Changes
2
Show whitespace changes
Inline
Side-by-side
include/villas/memory_manager.hpp
View file @
4471d735
...
...
@@ -30,8 +30,14 @@ public:
MemoryTranslation
(
uintptr_t
src
,
uintptr_t
dst
,
size_t
size
)
:
src
(
src
),
dst
(
dst
),
size
(
size
)
{}
uintptr_t
getLocalAddr
(
uintptr_t
addrInForeignAddrSpace
)
const
;
template
<
typename
ReturnType
=
uintptr_t
>
ReturnType
getLocalAddr
(
uintptr_t
addrInForeignAddrSpace
)
const
{
assert
(
addrInForeignAddrSpace
>=
dst
);
assert
(
addrInForeignAddrSpace
<
(
dst
+
size
));
return
reinterpret_cast
<
ReturnType
>
(
src
+
addrInForeignAddrSpace
-
dst
);
}
uintptr_t
getForeignAddr
(
uintptr_t
addrInLocalAddrSpace
)
const
;
...
...
lib/common/memory_manager.cpp
View file @
4471d735
...
...
@@ -148,13 +148,6 @@ MemoryManager::pathCheck(const MemoryGraph::Path& path)
return
true
;
}
uintptr_t
MemoryTranslation
::
getLocalAddr
(
uintptr_t
addrInForeignAddrSpace
)
const
{
assert
(
addrInForeignAddrSpace
>=
dst
);
assert
(
addrInForeignAddrSpace
<
(
dst
+
size
));
return
src
+
addrInForeignAddrSpace
-
dst
;
}
uintptr_t
MemoryTranslation
::
getForeignAddr
(
uintptr_t
addrInLocalAddrSpace
)
const
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment