aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/devmem.c2
-rw-r--r--miscutils/hexedit.c14
-rw-r--r--miscutils/time.c7
3 files changed, 10 insertions, 13 deletions
diff --git a/miscutils/devmem.c b/miscutils/devmem.c
index e8dce5225..f9f0276bc 100644
--- a/miscutils/devmem.c
+++ b/miscutils/devmem.c
@@ -75,7 +75,7 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
bb_show_usage(); /* one of bb_strtouXX failed */
fd = xopen("/dev/mem", argv[3] ? (O_RDWR | O_SYNC) : (O_RDONLY | O_SYNC));
- mapped_size = page_size = getpagesize();
+ mapped_size = page_size = bb_getpagesize();
offset_in_page = (unsigned)target & (page_size - 1);
if (offset_in_page + width > page_size) {
/* This access spans pages.
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 {
int fd;
unsigned height;
unsigned row;
- unsigned pagesize;
+ IF_VARIABLE_ARCH_PAGESIZE(unsigned pagesize;)
+#define G_pagesize cached_pagesize(G.pagesize)
uint8_t *baseaddr;
uint8_t *current_byte;
uint8_t *eof_byte;
@@ -46,15 +47,6 @@ struct globals {
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
} while (0)
-//TODO: move to libbb
-#if defined(__x86_64__) || defined(i386)
-# define G_pagesize 4096
-# define INIT_PAGESIZE() ((void)0)
-#else
-# define G_pagesize (G.pagesize)
-# define INIT_PAGESIZE() ((void)(G.pagesize = getpagesize()))
-#endif
-
/* hopefully there aren't arches with PAGE_SIZE > 64k */
#define G_mapsize (64*1024)
@@ -262,7 +254,7 @@ int hexedit_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int hexedit_main(int argc UNUSED_PARAM, char **argv)
{
INIT_G();
- INIT_PAGESIZE();
+ INIT_PAGESIZE(G.pagesize);
get_terminal_width_height(-1, NULL, &G.height);
if (1) {
diff --git a/miscutils/time.c b/miscutils/time.c
index d15d363f3..0006c59d8 100644
--- a/miscutils/time.c
+++ b/miscutils/time.c
@@ -111,6 +111,10 @@ static void printargv(char *const *argv)
This is funky since the pagesize could be less than 1K.
Note: Some machines express getrusage statistics in terms of K,
others in terms of pages. */
+#ifdef BB_ARCH_FIXED_PAGESIZE
+# define pagesize BB_ARCH_FIXED_PAGESIZE
+# define ptok(pagesize, pages) ptok(pages)
+#endif
static unsigned long ptok(const unsigned pagesize, const unsigned long pages)
{
unsigned long tmp;
@@ -124,6 +128,7 @@ static unsigned long ptok(const unsigned pagesize, const unsigned long pages)
tmp = pages * pagesize; /* Larger first, */
return tmp / 1024; /* then smaller. */
}
+#undef pagesize
/* summarize: Report on the system use of a command.
@@ -177,7 +182,7 @@ static void summarize(const char *fmt, char **command, resource_t *resp)
{
unsigned vv_ms; /* Elapsed virtual (CPU) milliseconds */
unsigned cpu_ticks; /* Same, in "CPU ticks" */
- unsigned pagesize = getpagesize();
+ unsigned pagesize = bb_getpagesize();
/* Impossible: we do not use WUNTRACED flag in wait()...
if (WIFSTOPPED(resp->waitstatus))