From c7b858ff8d2e8b2d785f74b2d319bc9c839f4faa Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 14 Dec 2020 18:49:23 +0100 Subject: libbb: add and use infrastructure for fixed page size optimization function old new delta procps_scan 1121 1118 -3 getpagesize 6 - -6 rpm_main 1037 1027 -10 rpm2cpio_main 120 110 -10 ptok 38 21 -17 time_main 1282 1261 -21 mkswap_main 317 278 -39 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/6 up/down: 0/-106) Total: -106 bytes Signed-off-by: Denys Vlasenko --- libbb/procps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libbb') diff --git a/libbb/procps.c b/libbb/procps.c index 4cc3cb2a1..975e0d4dc 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -94,15 +94,15 @@ static int read_to_buf(const char *filename, void *buf) static procps_status_t* FAST_FUNC alloc_procps_scan(void) { - unsigned n = getpagesize(); procps_status_t* sp = xzalloc(sizeof(procps_status_t)); - sp->dir = xopendir("/proc"); + unsigned n = bb_getpagesize(); while (1) { n >>= 1; if (!n) break; sp->shift_pages_to_bytes++; } sp->shift_pages_to_kb = sp->shift_pages_to_bytes - 10; + sp->dir = xopendir("/proc"); return sp; } -- cgit v1.2.3