From: Michael Müller michael@fds-team.de
Remove extra ifdefs
From: Michael Müller michael@fds-team.de Signed-off-by: Vijay Kiran Kamuju infyquest@gmail.com --- dlls/ntdll/nt.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c index f429349698..687f31bd4f 100644 --- a/dlls/ntdll/nt.c +++ b/dlls/ntdll/nt.c @@ -30,6 +30,9 @@ #ifdef HAVE_SYS_SYSCTL_H # include <sys/sysctl.h> #endif +#ifdef HAVE_SYS_SYSINFO_H +# include <sys/sysinfo.h> +#endif #ifdef HAVE_MACHINE_CPU_H # include <machine/cpu.h> #endif @@ -2319,6 +2322,37 @@ NTSTATUS WINAPI NtQuerySystemInformation( spi.IdleTime.QuadPart = ++idle; }
+#ifdef HAVE_SYSINFO + struct sysinfo sinfo; + + if (!sysinfo(&sinfo)) + { + ULONG64 freeram = (ULONG64)sinfo.freeram * sinfo.mem_unit; + ULONG64 totalram = (ULONG64)sinfo.totalram * sinfo.mem_unit; + ULONG64 totalswap = (ULONG64)sinfo.totalswap * sinfo.mem_unit; + ULONG64 freeswap = (ULONG64)sinfo.freeswap * sinfo.mem_unit; + + if ((fp = fopen("/proc/meminfo", "r"))) + { + unsigned long long available; + char line[64]; + while (fgets(line, sizeof(line), fp)) + { + if (sscanf(line, "MemAvailable: %llu kB", &available) == 1) + { + freeram = min(available * 1024, totalram); + break; + } + } + fclose(fp); + } + + spi.AvailablePages = freeram / page_size; + spi.TotalCommittedPages = (totalram + totalswap - freeram - freeswap) / page_size; + spi.TotalCommitLimit = (totalram + totalswap) / page_size; + } +#endif + if (Length >= len) { if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION;