[PATCH] ntdll: Report system information SystemPerformanceInformation info class. (v2)
Alexandre Julliard
julliard at winehq.org
Mon Apr 15 14:24:37 CDT 2019
Vijay Kiran Kamuju <infyquest at gmail.com> writes:
> +#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);
> + }
It seems to me that as long as we are parsing /proc/meminfo, we could
get everything from there, instead of mixing it up with sysinfo().
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list