Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Simplify format specifiers for uintmax_t
[slstatus.git]
/
components
/
cpu.c
diff --git
a/components/cpu.c
b/components/cpu.c
index
e320ff6
..
43ee8a9
100644
(file)
--- a/
components/cpu.c
+++ b/
components/cpu.c
@@
-1,21
+1,19
@@
/* See LICENSE file for copyright and license details. */
/* See LICENSE file for copyright and license details. */
+#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "../util.h"
#if defined(__linux__)
#include <stdio.h>
#include <string.h>
#include "../util.h"
#if defined(__linux__)
- #include <inttypes.h>
- #include <stdint.h>
-
const char *
cpu_freq(void)
{
const char *
cpu_freq(void)
{
- uint
64
_t freq;
+ uint
max
_t freq;
/* in kHz */
if (pscanf("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
/* in kHz */
if (pscanf("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq",
- "%
"SCNu64
, &freq) != 1) {
+ "%
ju"
, &freq) != 1) {
return NULL;
}
return NULL;
}
@@
-45,7
+43,6
@@
(a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6]))));
}
#elif defined(__OpenBSD__)
(a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6]))));
}
#elif defined(__OpenBSD__)
- #include <inttypes.h>
#include <sys/param.h>
#include <sys/sched.h>
#include <sys/sysctl.h>
#include <sys/param.h>
#include <sys/sched.h>
#include <sys/sysctl.h>
@@
-53,7
+50,8
@@
const char *
cpu_freq(void)
{
const char *
cpu_freq(void)
{
- int freq, mib[2];
+ int mib[2];
+ uintmax_t freq;
size_t size;
mib[0] = CTL_HW;
size_t size;
mib[0] = CTL_HW;
@@
-67,15
+65,15
@@
return NULL;
}
return NULL;
}
- return fmt_human(
(size_t)freq * 1000 * 1000
, 1000);
+ return fmt_human(
freq * 1E6
, 1000);
}
const char *
cpu_perc(void)
{
int mib[2];
}
const char *
cpu_perc(void)
{
int mib[2];
- static uint
64
_t a[CPUSTATES];
- uint
64
_t b[CPUSTATES];
+ static uint
max
_t a[CPUSTATES];
+ uint
max
_t b[CPUSTATES];
size_t size;
mib[0] = CTL_KERN;
size_t size;
mib[0] = CTL_KERN;