util: Implement os_get_available_system_memory on Win32

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18001>
This commit is contained in:
Yonggang Luo
2022-03-30 04:45:31 +08:00
committed by Marge Bot
parent b2bf20e28f
commit d85295e6a9

View File

@@ -317,6 +317,14 @@ os_get_available_system_memory(uint64_t *size)
*size = MIN2(mem_available, rl.rlim_cur);
return true;
#elif DETECT_OS_WINDOWS
MEMORYSTATUSEX status;
BOOL ret;
status.dwLength = sizeof(status);
ret = GlobalMemoryStatusEx(&status);
*size = status.ullAvailPhys;
return (ret == TRUE);
#else
return false;
#endif