Module: Mesa
Branch: main
Commit: d85295e6a9c957fb9871cd3b0daeb64c05f00992
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d85295e6a9c957fb9871cd3b0daeb64c05f00992

Author: Yonggang Luo <[email protected]>
Date:   Wed Mar 30 04:45:31 2022 +0800

util: Implement os_get_available_system_memory on Win32

Signed-off-by: Yonggang Luo <[email protected]>
Reviewed-by: Jesse Natalie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18001>

---

 src/util/os_misc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/util/os_misc.c b/src/util/os_misc.c
index 367bd6c2857..1c1fbca159b 100644
--- a/src/util/os_misc.c
+++ b/src/util/os_misc.c
@@ -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

Reply via email to