Add a Stack convenience class

This commit is contained in:
apio 2022-12-07 14:48:24 +01:00 committed by Gitea
parent 0bbd026660
commit 8da5521273
2 changed files with 33 additions and 0 deletions

23
luna/include/luna/Stack.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <luna/Types.h>
struct Stack
{
Stack(u64 base, usize bytes);
u64 bottom()
{
return m_base;
}
u64 top();
usize bytes()
{
return m_bytes;
}
private:
u64 m_base;
usize m_bytes;
};

10
luna/src/Stack.cpp Normal file
View File

@ -0,0 +1,10 @@
#include <luna/Stack.h>
Stack::Stack(u64 base, usize bytes) : m_base(base), m_bytes(bytes)
{
}
u64 Stack::top()
{
return (m_base + m_bytes) - sizeof(void*);
}