From d9cd120af0c9ca967fb0a8b6a9ebeb3362ef366c Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 9 Sep 2021 13:40:47 +0200 Subject: IsPointerToStack() implementation for Linux --- zencore/zencore.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'zencore/zencore.cpp') diff --git a/zencore/zencore.cpp b/zencore/zencore.cpp index c2a57b653..27ac779b0 100644 --- a/zencore/zencore.cpp +++ b/zencore/zencore.cpp @@ -2,7 +2,13 @@ #include +#if ZEN_PLATFORM_WINDOWS #include +#endif + +#if ZEN_PLATFORM_LINUX +#include +#endif #include #include @@ -25,12 +31,26 @@ bool IsPointerToStack(const void* ptr) { +#if ZEN_PLATFORM_WINDOWS ULONG_PTR low, high; GetCurrentThreadStackLimits(&low, &high); const uintptr_t intPtr = reinterpret_cast(ptr); return (intPtr - low) < (high - low); +#elif ZEN_PLATFORM_LINUX + pthread_t self = pthread_self(); + + pthread_attr_t attr; + pthread_getattr_np(self, &attr); + + void* low; + size_t size; + pthread_attr_getstack(&attr, &low, &size); + + return (uintptr_t(ptr) - uintptr_t(low)) < uintptr_t(size); +#elif 0 +#endif } zen::AssertException::AssertException(const char* Msg) : m_Msg(Msg) -- cgit v1.2.3 From 22e1bfb58064637186b3112af4668c80f3492a86 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Tue, 14 Sep 2021 14:25:46 +0200 Subject: Added test case for some of intmath.h's functions --- zencore/zencore.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'zencore/zencore.cpp') diff --git a/zencore/zencore.cpp b/zencore/zencore.cpp index 27ac779b0..c53fd218f 100644 --- a/zencore/zencore.cpp +++ b/zencore/zencore.cpp @@ -85,6 +85,7 @@ zencore_forcelinktests() zen::blake3_forcelink(); zen::compositebuffer_forcelink(); zen::compress_forcelink(); + zen::intmath_forcelink(); zen::iobuffer_forcelink(); zen::memory_forcelink(); zen::refcount_forcelink(); -- cgit v1.2.3