Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/systat/sysput.c
Show All 34 Lines | |||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <err.h> | #include <err.h> | ||||
#include <libutil.h> | #include <libutil.h> | ||||
#include "systat.h" | #include "systat.h" | ||||
#include "extern.h" | #include "extern.h" | ||||
static int page_shift(); | |||||
uint64_t | |||||
byte_to_page(uint64_t size) | |||||
{ | |||||
return (size >> page_shift()); | |||||
kib: This does not look like a tab before return.
But, can you use e.g. atop() and ptoa() instead… | |||||
} | |||||
uint64_t | |||||
page_to_byte(uint64_t size) | |||||
{ | |||||
return (size << page_shift()); | |||||
} | |||||
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); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 48 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 | int | ||||
calc_page_shift() | page_shift() | ||||
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() | |||||
{ | { | ||||
u_int page_size; | u_int page_size; | ||||
int shifts; | static int shifts = 0; | ||||
shifts = 0; | if (shifts != 0) | ||||
return (shifts); | |||||
GETSYSCTL("vm.stats.vm.v_page_size", page_size); | GETSYSCTL("vm.stats.vm.v_page_size", page_size); | ||||
for(; page_size > 1; page_size >>= 1) | for (; page_size > 1; page_size >>= 1) | ||||
shifts++; | shifts++; | ||||
return shifts; | return shifts; | ||||
} | } | ||||
void | void | ||||
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, page_to_byte(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?