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 --- archival/rpm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'archival') diff --git a/archival/rpm.c b/archival/rpm.c index a4d850b46..af8db99a6 100644 --- a/archival/rpm.c +++ b/archival/rpm.c @@ -83,7 +83,9 @@ struct globals { void *map; rpm_index *mytags; int tagcount; - unsigned mapsize, pagesize; + unsigned mapsize; + IF_VARIABLE_ARCH_PAGESIZE(unsigned pagesize;) +#define G_pagesize cached_pagesize(G.pagesize) } FIX_ALIASING; #define G (*(struct globals*)bb_common_bufsiz1) #define INIT_G() do { setup_common_bufsiz(); } while (0) @@ -141,7 +143,7 @@ static int rpm_gettags(const char *filename) G.mytags = tags; /* Map the store */ - storepos = (storepos + G.pagesize) & -(int)G.pagesize; + storepos = (storepos + G_pagesize) & -(int)G_pagesize; /* remember size for munmap */ G.mapsize = storepos; /* some NOMMU systems prefer MAP_PRIVATE over MAP_SHARED */ @@ -356,7 +358,7 @@ int rpm_main(int argc, char **argv) int opt, func = 0; INIT_G(); - G.pagesize = getpagesize(); + INIT_PAGESIZE(G.pagesize); while ((opt = getopt(argc, argv, "iqpldc")) != -1) { switch (opt) { @@ -523,7 +525,7 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv) int rpm_fd; INIT_G(); - G.pagesize = getpagesize(); + INIT_PAGESIZE(G.pagesize); rpm_fd = rpm_gettags(argv[1]); -- cgit v1.2.3