Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/systat/sysput.c
Show All 25 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <inttypes.h> | |||||
#include <string.h> | |||||
#include <err.h> | #include <err.h> | ||||
#include <inttypes.h> | |||||
#include <libutil.h> | #include <libutil.h> | ||||
#include <machine/param.h> | |||||
#include <string.h> | |||||
#include "systat.h" | #include "systat.h" | ||||
#include "extern.h" | #include "extern.h" | ||||
void | void | ||||
sysputspaces(WINDOW *wd, int row, int col, int width) | sysputspaces(WINDOW *wd, int row, int col, int width) | ||||
{ | { | ||||
static char str60[] = " " | static char str60[] = " " | ||||
" "; | " "; | ||||
mvwaddstr(wd, row, col, str60 + sizeof(str60) - width - 1); | mvwaddstr(wd, row, col, str60 + sizeof(str60) - width - 1); | ||||
kib: This does not look like a tab before return.
But, can you use e.g. atop() and ptoa() instead… | |||||
} | } | ||||
void | void | ||||
sysputstrs(WINDOW *wd, int row, int col, int width) | sysputstrs(WINDOW *wd, int row, int col, int width) | ||||
{ | { | ||||
static char str60[] = "********************" | static char str60[] = "********************" | ||||
"****************************************"; | "****************************************"; | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
sysputwuint64(WINDOW *wd, int row, int col, int width, uint64_t val, int flags) | sysputwuint64(WINDOW *wd, int row, int col, int width, uint64_t val, int flags) | ||||
{ | { | ||||
if(val == 0) | if(val == 0) | ||||
sysputspaces(wd, row, col, width); | sysputspaces(wd, row, col, width); | ||||
else | else | ||||
sysputuint64(wd, row, col, width, val, flags); | sysputuint64(wd, row, col, width, val, flags); | ||||
} | } | ||||
static int | |||||
calc_page_shift() | |||||
{ | |||||
u_int page_size; | |||||
int shifts; | |||||
shifts = 0; | |||||
GETSYSCTL("vm.stats.vm.v_page_size", page_size); | |||||
for(; page_size > 1; page_size >>= 1) | |||||
shifts++; | |||||
return shifts; | |||||
} | |||||
void | void | ||||
Done Inline ActionsChange function definition to ANSI. kib: Change function definition to ANSI.
BTW as I see it is not needed if you start using ptoa() | |||||
sysputpage(WINDOW *wd, int row, int col, int width, uint64_t pages, int flags) | sysputpage(WINDOW *wd, int row, int col, int width, uint64_t pages, int flags) | ||||
{ | { | ||||
static int shifts = 0; | |||||
if (shifts == 0) | sysputuint64(wd, row, col, width, ptoa(pages), flags); | ||||
shifts = calc_page_shift(); | |||||
pages <<= shifts; | |||||
sysputuint64(wd, row, col, width, pages, flags); | |||||
} | } |
This does not look like a tab before return.
But, can you use e.g. atop() and ptoa() instead of hand-rolled functions?