Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Added some win32 platform functions #1617

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions src/platform_win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,46 @@ const char* Platform::GetProcessTitle(int *len) {


int Platform::GetMemory(size_t *rss, size_t *vsize) {
*rss = 0;
*vsize = 0;

HANDLE current_process = GetCurrentProcess();
PROCESS_MEMORY_COUNTERS pmc;

if ( !GetProcessMemoryInfo( current_process, &pmc, sizeof(pmc)) )
{
winapi_perror("GetProcessMemoryInfo");
}

*rss = pmc.WorkingSetSize;
*vsize = pmc.PeakWorkingSetSize;

return 0;
}


double Platform::GetFreeMemory() {
return -1;

MEMORYSTATUSEX memory_status;
memory_status.dwLength = sizeof(memory_status);

if(!GlobalMemoryStatusEx(&memory_status))
{
winapi_perror("GlobalMemoryStatusEx");
}

return (double)memory_status.ullAvailPhys;
}

double Platform::GetTotalMemory() {
return -1;

MEMORYSTATUSEX memory_status;
memory_status.dwLength = sizeof(memory_status);

if(!GlobalMemoryStatusEx(&memory_status))
{
winapi_perror("GlobalMemoryStatusEx");
}

return (double)memory_status.ullTotalPhys;
}


Expand All @@ -219,7 +247,7 @@ int Platform::GetCPUInfo(Local<Array> *cpus) {


double Platform::GetUptimeImpl() {
return -1;
return (double)GetTickCount()/1000.0;
}

int Platform::GetLoadAvg(Local<Array> *loads) {
Expand Down