diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-14 18:49:23 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-14 18:54:30 +0100 |
commit | c7b858ff8d2e8b2d785f74b2d319bc9c839f4faa (patch) | |
tree | 9ad109d5999444dfb3a281678b6b63d2570a76cd /miscutils/hexedit.c | |
parent | fd3c512f88d43e6633bd3c3110cfa0bb321adaa8 (diff) | |
download | busybox-w32-c7b858ff8d2e8b2d785f74b2d319bc9c839f4faa.tar.gz busybox-w32-c7b858ff8d2e8b2d785f74b2d319bc9c839f4faa.tar.bz2 busybox-w32-c7b858ff8d2e8b2d785f74b2d319bc9c839f4faa.zip |
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 <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/hexedit.c')
-rw-r--r-- | miscutils/hexedit.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/miscutils/hexedit.c b/miscutils/hexedit.c index 898d77376..f8ff9b62b 100644 --- a/miscutils/hexedit.c +++ b/miscutils/hexedit.c | |||
@@ -31,7 +31,8 @@ struct globals { | |||
31 | int fd; | 31 | int fd; |
32 | unsigned height; | 32 | unsigned height; |
33 | unsigned row; | 33 | unsigned row; |
34 | unsigned pagesize; | 34 | IF_VARIABLE_ARCH_PAGESIZE(unsigned pagesize;) |
35 | #define G_pagesize cached_pagesize(G.pagesize) | ||
35 | uint8_t *baseaddr; | 36 | uint8_t *baseaddr; |
36 | uint8_t *current_byte; | 37 | uint8_t *current_byte; |
37 | uint8_t *eof_byte; | 38 | uint8_t *eof_byte; |
@@ -46,15 +47,6 @@ struct globals { | |||
46 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 47 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
47 | } while (0) | 48 | } while (0) |
48 | 49 | ||
49 | //TODO: move to libbb | ||
50 | #if defined(__x86_64__) || defined(i386) | ||
51 | # define G_pagesize 4096 | ||
52 | # define INIT_PAGESIZE() ((void)0) | ||
53 | #else | ||
54 | # define G_pagesize (G.pagesize) | ||
55 | # define INIT_PAGESIZE() ((void)(G.pagesize = getpagesize())) | ||
56 | #endif | ||
57 | |||
58 | /* hopefully there aren't arches with PAGE_SIZE > 64k */ | 50 | /* hopefully there aren't arches with PAGE_SIZE > 64k */ |
59 | #define G_mapsize (64*1024) | 51 | #define G_mapsize (64*1024) |
60 | 52 | ||
@@ -262,7 +254,7 @@ int hexedit_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
262 | int hexedit_main(int argc UNUSED_PARAM, char **argv) | 254 | int hexedit_main(int argc UNUSED_PARAM, char **argv) |
263 | { | 255 | { |
264 | INIT_G(); | 256 | INIT_G(); |
265 | INIT_PAGESIZE(); | 257 | INIT_PAGESIZE(G.pagesize); |
266 | 258 | ||
267 | get_terminal_width_height(-1, NULL, &G.height); | 259 | get_terminal_width_height(-1, NULL, &G.height); |
268 | if (1) { | 260 | if (1) { |