summaryrefslogtreecommitdiff
path: root/AK/StackInfo.cpp
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2023-03-04 05:53:51 -0700
committerAndreas Kling <kling@serenityos.org>2023-03-04 13:59:04 +0100
commitc1983244a29fafa5d2c13ba7438c548f413148ae (patch)
tree03ba1395d3aca1ab01411f1e6faf2b8f7eb08e19 /AK/StackInfo.cpp
parent0d0ad225726be7913433a5e1af93b0a224db65e5 (diff)
downloadserenity-c1983244a29fafa5d2c13ba7438c548f413148ae.zip
AK: Add StackInfo implementation for Windows
This prevents a warning when compiling jakt that it's not implemented.
Diffstat (limited to 'AK/StackInfo.cpp')
-rw-r--r--AK/StackInfo.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/AK/StackInfo.cpp b/AK/StackInfo.cpp
index 8e9e445b3e..fcd7860516 100644
--- a/AK/StackInfo.cpp
+++ b/AK/StackInfo.cpp
@@ -17,6 +17,10 @@
#elif defined(AK_OS_FREEBSD) or defined(AK_OS_OPENBSD)
# include <pthread.h>
# include <pthread_np.h>
+#elif defined(AK_OS_WINDOWS)
+# include <Windows.h>
+// NOTE: Prevent clang-format from re-ordering this header order
+# include <Processthreadsapi.h>
#endif
namespace AK {
@@ -77,6 +81,13 @@ StackInfo::StackInfo()
FlatPtr top_of_stack = (FlatPtr)thread_stack.ss_sp;
m_size = (size_t)thread_stack.ss_size;
m_base = top_of_stack - m_size;
+#elif defined(AK_OS_WINDOWS)
+ ULONG_PTR low_limit = 0;
+ ULONG_PTR high_limit = 0;
+ GetCurrentThreadStackLimits(&low_limit, &high_limit);
+
+ m_base = static_cast<FlatPtr>(low_limit);
+ m_size = static_cast<size_t>(high_limit - low_limit);
#else
# pragma message "StackInfo not supported on this platform! Recursion checks and stack scans may not work properly"
m_size = (size_t)~0;