// Copyright Epic Games, Inc. All Rights Reserved. #include #if ZEN_PLATFORM_WINDOWS # include #endif #if ZEN_PLATFORM_LINUX # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace zen { ////////////////////////////////////////////////////////////////////////// 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 } bool IsDebuggerPresent() { #if ZEN_PLATFORM_WINDOWS return ::IsDebuggerPresent(); #else return false; #endif } bool IsInteractiveSession() { #if ZEN_PLATFORM_WINDOWS DWORD dwSessionId = 0; if (ProcessIdToSessionId(GetCurrentProcessId(), &dwSessionId)) { return (dwSessionId != 0); } return false; #else // TODO: figure out what makes sense here return true; #endif } ////////////////////////////////////////////////////////////////////////// static int s_ApplicationExitCode = 0; static bool s_ApplicationExitRequested; bool IsApplicationExitRequested() { return s_ApplicationExitRequested; } void RequestApplicationExit(int ExitCode) { s_ApplicationExitCode = ExitCode; s_ApplicationExitRequested = true; } #if ZEN_WITH_TESTS void zencore_forcelinktests() { zen::blake3_forcelink(); zen::compositebuffer_forcelink(); zen::compress_forcelink(); zen::intmath_forcelink(); zen::iobuffer_forcelink(); zen::memory_forcelink(); zen::refcount_forcelink(); zen::sha1_forcelink(); zen::snapshotmanifest_forcelink(); zen::stats_forcelink(); zen::stream_forcelink(); zen::string_forcelink(); zen::thread_forcelink(); zen::timer_forcelink(); zen::uid_forcelink(); zen::uson_forcelink(); zen::usonbuilder_forcelink(); zen::usonpackage_forcelink(); } #endif } // namespace zen