From adee7dee99e7afa218fbfd17b5ea4ff41ab99111 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 8 Jun 2020 20:38:32 +0000 Subject: [PATCH] Core: GetSystemMemoryStatus Win32, Linux git-svn-id: svn://ultimatepp.org/upp/trunk@14568 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Cpu.cpp | 25 +++++++++++++------------ uppsrc/Core/Defs.h | 2 +- uppsrc/CtrlCore/CtrlDraw.cpp | 4 +--- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/uppsrc/Core/Cpu.cpp b/uppsrc/Core/Cpu.cpp index 912765495..a08a795b8 100644 --- a/uppsrc/Core/Cpu.cpp +++ b/uppsrc/Core/Cpu.cpp @@ -129,21 +129,22 @@ int CPU_Cores() #endif +void GetSystemMemoryStatus(uint64& total, uint64& free) +{ #ifdef PLATFORM_WIN32 -bool IsDecentMachine() -{ - if(!IsWin2K()) - return false; - MEMORYSTATUS m; - GlobalMemoryStatus(&m); - return m.dwTotalPhys > 500 * 1024 * 1024; -} + MEMORYSTATUSEX m; + GlobalMemoryStatusEx(&m); + total = m.ullTotalPhys; + free = m.ullAvailPhys; +#elif defined(PLATFORM_LINUX) + int pgsz = getpagesize(); + total = sysconf(_SC_PHYS_PAGES) * pgsz; + free = sysconf(_SC_AVPHYS_PAGES) * pgsz; #else -bool IsDecentMachine() -{ - return true; -} + total = 512*1024*1024; + free = 16*1024*1024; #endif +} #define ENDIAN_SWAP { while(count--) { EndianSwap(*v++); } } diff --git a/uppsrc/Core/Defs.h b/uppsrc/Core/Defs.h index 91a941ef0..1aabe1d76 100644 --- a/uppsrc/Core/Defs.h +++ b/uppsrc/Core/Defs.h @@ -484,7 +484,7 @@ bool CpuAVX(); int CPU_Cores(); -bool IsDecentMachine(); +void GetSystemMemoryStatus(uint64& total, uint64& free); template inline void Swap(T& a, T& b) { T tmp = pick(a); a = pick(b); b = pick(tmp); } diff --git a/uppsrc/CtrlCore/CtrlDraw.cpp b/uppsrc/CtrlCore/CtrlDraw.cpp index 846a804e1..ca293d63b 100644 --- a/uppsrc/CtrlCore/CtrlDraw.cpp +++ b/uppsrc/CtrlCore/CtrlDraw.cpp @@ -697,7 +697,6 @@ void Ctrl::SyncMoves() Ctrl& Ctrl::BackPaintHint() { GuiLock __; - if(IsDecentMachine()) BackPaint(); return *this; } @@ -710,8 +709,7 @@ void Ctrl::GlobalBackPaint(bool b) void Ctrl::GlobalBackPaintHint() { - if(IsDecentMachine()) - GlobalBackPaint(); + GlobalBackPaint(); } void Ctrl::GlobalBackBuffer(bool b)