Core: GetSystemMemoryStatus Win32, Linux

git-svn-id: svn://ultimatepp.org/upp/trunk@14568 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-06-08 20:38:32 +00:00
parent f42d9f1e30
commit adee7dee99
3 changed files with 15 additions and 16 deletions

View file

@ -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++); } }

View file

@ -484,7 +484,7 @@ bool CpuAVX();
int CPU_Cores();
bool IsDecentMachine();
void GetSystemMemoryStatus(uint64& total, uint64& free);
template <class T>
inline void Swap(T& a, T& b) { T tmp = pick(a); a = pick(b); b = pick(tmp); }

View file

@ -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)