Skip to content
Snippets Groups Projects
Commit 76de0eec authored by Florian Schmaus's avatar Florian Schmaus
Browse files

[ContextManager] Re-initialze contexts if necessary

In case a Context has been retrieved from the MemoryManager, without
it malloced, then we need to re-initialze some of the Context's values
before we can use the Context.
parent c66551bf
No related branches found
No related tags found
No related merge requests found
......@@ -106,6 +106,14 @@ class EMPER_CONTEXT_ALIGNAS Context : Logger<LogSubsystem::C> {
static auto calcBos(char* context) -> void*;
auto calcBos() -> void*;
/*
* Used by ContextManager to re-initialize a cached unused context.
*/
inline void reinit() {
currentFiber = nullptr;
savedStackpointer = const_cast<void*>(alphaFunctionIpLocation);
}
public:
Context(func_t mainFunction);
......
......@@ -31,6 +31,7 @@ auto ContextManager::getFreeContext() -> Context* {
}
auto* context = static_cast<Context*>(memory);
context->reinit();
if constexpr (emper::STATS_STACK_USAGE == emper::StatsStackUsage::accurate) {
// If we want accurate stack-usage stats, then we need to re-mark
// the stack if we got the memory from the memory manager but if
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment