ram: Use POSIX types
This commit is contained in:
parent
b65c058598
commit
fa7c266e2b
@ -4,15 +4,17 @@
|
|||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
ram_free(void)
|
ram_free(void)
|
||||||
{
|
{
|
||||||
long free;
|
uint64_t free;
|
||||||
|
|
||||||
if (pscanf("/proc/meminfo",
|
if (pscanf("/proc/meminfo",
|
||||||
"MemTotal: %ld kB\n"
|
"MemTotal: %" PRIu64 " kB\n"
|
||||||
"MemFree: %ld kB\n"
|
"MemFree: %" PRIu64 " kB\n"
|
||||||
"MemAvailable: %ld kB\n",
|
"MemAvailable: %" PRIu64 " kB\n",
|
||||||
&free, &free, &free) != 3) {
|
&free, &free, &free) != 3) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -23,13 +25,13 @@
|
|||||||
const char *
|
const char *
|
||||||
ram_perc(void)
|
ram_perc(void)
|
||||||
{
|
{
|
||||||
long total, free, buffers, cached;
|
uint64_t total, free, buffers, cached;
|
||||||
|
|
||||||
if (pscanf("/proc/meminfo",
|
if (pscanf("/proc/meminfo",
|
||||||
"MemTotal: %ld kB\n"
|
"MemTotal: %" PRIu64 " kB\n"
|
||||||
"MemFree: %ld kB\n"
|
"MemFree: %" PRIu64 " kB\n"
|
||||||
"MemAvailable: %ld kB\nBuffers: %ld kB\n"
|
"MemAvailable: %" PRIu64 " kB\nBuffers: %ld kB\n"
|
||||||
"Cached: %ld kB\n",
|
"Cached: %" PRIu64 " kB\n",
|
||||||
&total, &free, &buffers, &buffers, &cached) != 5) {
|
&total, &free, &buffers, &buffers, &cached) != 5) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -41,9 +43,9 @@
|
|||||||
const char *
|
const char *
|
||||||
ram_total(void)
|
ram_total(void)
|
||||||
{
|
{
|
||||||
long total;
|
uint64_t total;
|
||||||
|
|
||||||
if (pscanf("/proc/meminfo", "MemTotal: %ld kB\n",
|
if (pscanf("/proc/meminfo", "MemTotal: %" PRIu64 " kB\n",
|
||||||
&total) != 1) {
|
&total) != 1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -54,13 +56,13 @@
|
|||||||
const char *
|
const char *
|
||||||
ram_used(void)
|
ram_used(void)
|
||||||
{
|
{
|
||||||
long total, free, buffers, cached;
|
uint64_t total, free, buffers, cached;
|
||||||
|
|
||||||
if (pscanf("/proc/meminfo",
|
if (pscanf("/proc/meminfo",
|
||||||
"MemTotal: %ld kB\n"
|
"MemTotal: %" PRIu64 " kB\n"
|
||||||
"MemFree: %ld kB\n"
|
"MemFree: %" PRIu64 " kB\n"
|
||||||
"MemAvailable: %ld kB\nBuffers: %ld kB\n"
|
"MemAvailable: %" PRIu64 " kB\nBuffers: %" PRIu64 " kB\n"
|
||||||
"Cached: %ld kB\n",
|
"Cached: %" PRIu64 " kB\n",
|
||||||
&total, &free, &buffers, &buffers, &cached) != 5) {
|
&total, &free, &buffers, &buffers, &cached) != 5) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user