diff options
author | Ron Yorston <rmy@pobox.com> | 2021-01-14 13:28:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-01-14 13:28:49 +0000 |
commit | 89963b524d211e1aec12b72b3725be05ee95c8cf (patch) | |
tree | 48590aef62b7ee7686b7898256f29def8d9c50b9 /miscutils | |
parent | 9aa5a829070392c2ac6494d0c4e674c0c2bc7dab (diff) | |
parent | 2b7c1aa92c68524559a2067609d09309d5c09adc (diff) | |
download | busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.gz busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.bz2 busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/adjtimex.c | 2 | ||||
-rw-r--r-- | miscutils/bc.c | 111 | ||||
-rw-r--r-- | miscutils/beep.c | 4 | ||||
-rw-r--r-- | miscutils/chat.c | 6 | ||||
-rw-r--r-- | miscutils/crond.c | 4 | ||||
-rw-r--r-- | miscutils/dc.c | 4 | ||||
-rw-r--r-- | miscutils/devfsd.c | 4 | ||||
-rw-r--r-- | miscutils/devmem.c | 2 | ||||
-rw-r--r-- | miscutils/hdparm.c | 6 | ||||
-rw-r--r-- | miscutils/hexedit.c | 14 | ||||
-rw-r--r-- | miscutils/i2c_tools.c | 31 | ||||
-rw-r--r-- | miscutils/man.c | 41 | ||||
-rw-r--r-- | miscutils/mt.c | 4 | ||||
-rw-r--r-- | miscutils/setserial.c | 3 | ||||
-rw-r--r-- | miscutils/time.c | 7 | ||||
-rw-r--r-- | miscutils/ts.c | 4 | ||||
-rw-r--r-- | miscutils/ubi_tools.c | 2 | ||||
-rw-r--r-- | miscutils/watchdog.c | 4 |
18 files changed, 142 insertions, 111 deletions
diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c index a9de0f9aa..209d1d560 100644 --- a/miscutils/adjtimex.c +++ b/miscutils/adjtimex.c | |||
@@ -22,7 +22,7 @@ | |||
22 | //kbuild:lib-$(CONFIG_ADJTIMEX) += adjtimex.o | 22 | //kbuild:lib-$(CONFIG_ADJTIMEX) += adjtimex.o |
23 | 23 | ||
24 | //usage:#define adjtimex_trivial_usage | 24 | //usage:#define adjtimex_trivial_usage |
25 | //usage: "[-q] [-o OFF] [-f FREQ] [-p TCONST] [-t TICK]" | 25 | //usage: "[-q] [-o OFS] [-f FREQ] [-p TCONST] [-t TICK]" |
26 | //usage:#define adjtimex_full_usage "\n\n" | 26 | //usage:#define adjtimex_full_usage "\n\n" |
27 | //usage: "Read or set kernel time variables. See adjtimex(2)\n" | 27 | //usage: "Read or set kernel time variables. See adjtimex(2)\n" |
28 | //usage: "\n -q Quiet" | 28 | //usage: "\n -q Quiet" |
diff --git a/miscutils/bc.c b/miscutils/bc.c index 4d987325e..53eb5c799 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -231,7 +231,7 @@ typedef struct BcNum { | |||
231 | #define BC_NUM_MAX_IBASE 36 | 231 | #define BC_NUM_MAX_IBASE 36 |
232 | // larger value might speed up BIGNUM calculations a bit: | 232 | // larger value might speed up BIGNUM calculations a bit: |
233 | #define BC_NUM_DEF_SIZE 16 | 233 | #define BC_NUM_DEF_SIZE 16 |
234 | #define BC_NUM_PRINT_WIDTH 69 | 234 | #define BC_NUM_PRINT_WIDTH 70 |
235 | 235 | ||
236 | #define BC_NUM_KARATSUBA_LEN 32 | 236 | #define BC_NUM_KARATSUBA_LEN 32 |
237 | 237 | ||
@@ -517,7 +517,7 @@ struct BcLexKeyword { | |||
517 | }; | 517 | }; |
518 | #define LEX_KW_ENTRY(a, b) \ | 518 | #define LEX_KW_ENTRY(a, b) \ |
519 | { .name8 = a /*, .posix = b */ } | 519 | { .name8 = a /*, .posix = b */ } |
520 | static const struct BcLexKeyword bc_lex_kws[20] = { | 520 | static const struct BcLexKeyword bc_lex_kws[20] ALIGN8 = { |
521 | LEX_KW_ENTRY("auto" , 1), // 0 | 521 | LEX_KW_ENTRY("auto" , 1), // 0 |
522 | LEX_KW_ENTRY("break" , 1), // 1 | 522 | LEX_KW_ENTRY("break" , 1), // 1 |
523 | LEX_KW_ENTRY("continue", 0), // 2 note: this one has no terminating NUL | 523 | LEX_KW_ENTRY("continue", 0), // 2 note: this one has no terminating NUL |
@@ -1827,7 +1827,7 @@ static FAST_FUNC BC_STATUS zbc_num_k(BcNum *restrict a, BcNum *restrict b, | |||
1827 | #define zbc_num_k(...) (zbc_num_k(__VA_ARGS__) COMMA_SUCCESS) | 1827 | #define zbc_num_k(...) (zbc_num_k(__VA_ARGS__) COMMA_SUCCESS) |
1828 | { | 1828 | { |
1829 | BcStatus s; | 1829 | BcStatus s; |
1830 | size_t max = BC_MAX(a->len, b->len), max2 = (max + 1) / 2; | 1830 | size_t max, max2; |
1831 | BcNum l1, h1, l2, h2, m2, m1, z0, z1, z2, temp; | 1831 | BcNum l1, h1, l2, h2, m2, m1, z0, z1, z2, temp; |
1832 | bool aone; | 1832 | bool aone; |
1833 | 1833 | ||
@@ -1841,9 +1841,9 @@ static FAST_FUNC BC_STATUS zbc_num_k(BcNum *restrict a, BcNum *restrict b, | |||
1841 | RETURN_STATUS(BC_STATUS_SUCCESS); | 1841 | RETURN_STATUS(BC_STATUS_SUCCESS); |
1842 | } | 1842 | } |
1843 | 1843 | ||
1844 | if (a->len + b->len < BC_NUM_KARATSUBA_LEN | 1844 | if (a->len < BC_NUM_KARATSUBA_LEN |
1845 | || a->len < BC_NUM_KARATSUBA_LEN | ||
1846 | || b->len < BC_NUM_KARATSUBA_LEN | 1845 | || b->len < BC_NUM_KARATSUBA_LEN |
1846 | /* || a->len + b->len < BC_NUM_KARATSUBA_LEN - redundant check */ | ||
1847 | ) { | 1847 | ) { |
1848 | size_t i, j, len; | 1848 | size_t i, j, len; |
1849 | 1849 | ||
@@ -1877,6 +1877,7 @@ static FAST_FUNC BC_STATUS zbc_num_k(BcNum *restrict a, BcNum *restrict b, | |||
1877 | RETURN_STATUS(BC_STATUS_SUCCESS); | 1877 | RETURN_STATUS(BC_STATUS_SUCCESS); |
1878 | } | 1878 | } |
1879 | 1879 | ||
1880 | max = BC_MAX(a->len, b->len); | ||
1880 | bc_num_init(&l1, max); | 1881 | bc_num_init(&l1, max); |
1881 | bc_num_init(&h1, max); | 1882 | bc_num_init(&h1, max); |
1882 | bc_num_init(&l2, max); | 1883 | bc_num_init(&l2, max); |
@@ -1888,6 +1889,7 @@ static FAST_FUNC BC_STATUS zbc_num_k(BcNum *restrict a, BcNum *restrict b, | |||
1888 | bc_num_init(&z2, max); | 1889 | bc_num_init(&z2, max); |
1889 | bc_num_init(&temp, max + max); | 1890 | bc_num_init(&temp, max + max); |
1890 | 1891 | ||
1892 | max2 = (max + 1) / 2; | ||
1891 | bc_num_split(a, max2, &l1, &h1); | 1893 | bc_num_split(a, max2, &l1, &h1); |
1892 | bc_num_split(b, max2, &l2, &h2); | 1894 | bc_num_split(b, max2, &l2, &h2); |
1893 | 1895 | ||
@@ -2201,8 +2203,8 @@ static BC_STATUS zbc_num_sqrt(BcNum *a, BcNum *restrict b, size_t scale) | |||
2201 | BcStatus s; | 2203 | BcStatus s; |
2202 | BcNum num1, num2, half, f, fprime, *x0, *x1, *temp; | 2204 | BcNum num1, num2, half, f, fprime, *x0, *x1, *temp; |
2203 | BcDig half_digs[1]; | 2205 | BcDig half_digs[1]; |
2204 | size_t pow, len, digs, digs1, resrdx, req, times = 0; | 2206 | size_t pow, len, digs, digs1, resrdx, req, times; |
2205 | ssize_t cmp = 1, cmp1 = SSIZE_MAX, cmp2 = SSIZE_MAX; | 2207 | ssize_t cmp, cmp1, cmp2; |
2206 | 2208 | ||
2207 | req = BC_MAX(scale, a->rdx) + ((BC_NUM_INT(a) + 1) >> 1) + 1; | 2209 | req = BC_MAX(scale, a->rdx) + ((BC_NUM_INT(a) + 1) >> 1) + 1; |
2208 | bc_num_expand(b, req); | 2210 | bc_num_expand(b, req); |
@@ -2255,11 +2257,12 @@ static BC_STATUS zbc_num_sqrt(BcNum *a, BcNum *restrict b, size_t scale) | |||
2255 | x0->rdx -= pow; | 2257 | x0->rdx -= pow; |
2256 | } | 2258 | } |
2257 | 2259 | ||
2258 | x0->rdx = digs = digs1 = 0; | 2260 | x0->rdx = digs = digs1 = times = 0; |
2259 | resrdx = scale + 2; | 2261 | resrdx = scale + 2; |
2260 | len = BC_NUM_INT(x0) + resrdx - 1; | 2262 | len = x0->len + resrdx - 1; |
2261 | 2263 | cmp = 1; | |
2262 | while (cmp != 0 || digs < len) { | 2264 | cmp1 = cmp2 = SSIZE_MAX; |
2265 | do { | ||
2263 | s = zbc_num_div(a, x0, &f, resrdx); | 2266 | s = zbc_num_div(a, x0, &f, resrdx); |
2264 | if (s) goto err; | 2267 | if (s) goto err; |
2265 | s = zbc_num_add(x0, &f, &fprime, resrdx); | 2268 | s = zbc_num_add(x0, &f, &fprime, resrdx); |
@@ -2284,11 +2287,12 @@ static BC_STATUS zbc_num_sqrt(BcNum *a, BcNum *restrict b, size_t scale) | |||
2284 | temp = x0; | 2287 | temp = x0; |
2285 | x0 = x1; | 2288 | x0 = x1; |
2286 | x1 = temp; | 2289 | x1 = temp; |
2287 | } | 2290 | } while (cmp != 0 || digs < len); |
2288 | 2291 | ||
2289 | bc_num_copy(b, x0); | 2292 | bc_num_copy(b, x0); |
2290 | scale -= 1; | 2293 | scale -= 1; |
2291 | if (b->rdx > scale) bc_num_truncate(b, b->rdx - scale); | 2294 | if (b->rdx > scale) |
2295 | bc_num_truncate(b, b->rdx - scale); | ||
2292 | err: | 2296 | err: |
2293 | bc_num_free(&fprime); | 2297 | bc_num_free(&fprime); |
2294 | bc_num_free(&f); | 2298 | bc_num_free(&f); |
@@ -2522,9 +2526,6 @@ static void xc_read_line(BcVec *vec, FILE *fp) | |||
2522 | 2526 | ||
2523 | #if ENABLE_FEATURE_BC_INTERACTIVE | 2527 | #if ENABLE_FEATURE_BC_INTERACTIVE |
2524 | if (G_interrupt) { // ^C was pressed | 2528 | if (G_interrupt) { // ^C was pressed |
2525 | # if ENABLE_FEATURE_EDITING | ||
2526 | intr: | ||
2527 | # endif | ||
2528 | if (fp != stdin) { | 2529 | if (fp != stdin) { |
2529 | // ^C while running a script (bc SCRIPT): die. | 2530 | // ^C while running a script (bc SCRIPT): die. |
2530 | // We do not return to interactive prompt: | 2531 | // We do not return to interactive prompt: |
@@ -2535,22 +2536,25 @@ static void xc_read_line(BcVec *vec, FILE *fp) | |||
2535 | // the shell would be unexpected. | 2536 | // the shell would be unexpected. |
2536 | xfunc_die(); | 2537 | xfunc_die(); |
2537 | } | 2538 | } |
2538 | // ^C while interactive input | 2539 | // There was ^C while running calculations |
2539 | G_interrupt = 0; | 2540 | G_interrupt = 0; |
2540 | // GNU bc says "interrupted execution." | 2541 | // GNU bc says "interrupted execution." (to stdout, not stderr) |
2541 | // GNU dc says "Interrupt!" | 2542 | // GNU dc says "Interrupt!" |
2542 | fputs("\ninterrupted execution\n", stderr); | 2543 | puts("\ninterrupted execution"); |
2543 | } | 2544 | } |
2544 | 2545 | ||
2545 | # if ENABLE_FEATURE_EDITING | 2546 | # if ENABLE_FEATURE_EDITING |
2546 | if (G_ttyin && fp == stdin) { | 2547 | if (G_ttyin && fp == stdin) { |
2547 | int n, i; | 2548 | int n, i; |
2549 | if (!G.line_input_state) | ||
2550 | G.line_input_state = new_line_input_t(DO_HISTORY); | ||
2548 | # define line_buf bb_common_bufsiz1 | 2551 | # define line_buf bb_common_bufsiz1 |
2549 | n = read_line_input(G.line_input_state, "", line_buf, COMMON_BUFSIZE); | 2552 | n = read_line_input(G.line_input_state, "", line_buf, COMMON_BUFSIZE); |
2550 | if (n <= 0) { // read errors or EOF, or ^D, or ^C | 2553 | if (n <= 0) { // read errors or EOF, or ^D, or ^C |
2551 | if (n == 0) // ^C | 2554 | //GNU bc prints this on ^C: |
2552 | goto intr; | 2555 | //if (n == 0) // ^C |
2553 | bc_vec_pushZeroByte(vec); // ^D or EOF (or error) | 2556 | // puts("(interrupt) Exiting bc."); |
2557 | bc_vec_pushZeroByte(vec); | ||
2554 | return; | 2558 | return; |
2555 | } | 2559 | } |
2556 | i = 0; | 2560 | i = 0; |
@@ -6872,22 +6876,6 @@ static BC_STATUS zxc_program_exec(void) | |||
6872 | } | 6876 | } |
6873 | #define zxc_program_exec(...) (zxc_program_exec(__VA_ARGS__) COMMA_SUCCESS) | 6877 | #define zxc_program_exec(...) (zxc_program_exec(__VA_ARGS__) COMMA_SUCCESS) |
6874 | 6878 | ||
6875 | static unsigned xc_vm_envLen(const char *var) | ||
6876 | { | ||
6877 | char *lenv; | ||
6878 | unsigned len; | ||
6879 | |||
6880 | lenv = getenv(var); | ||
6881 | len = BC_NUM_PRINT_WIDTH; | ||
6882 | if (!lenv) return len; | ||
6883 | |||
6884 | len = bb_strtou(lenv, NULL, 10) - 1; | ||
6885 | if (errno || len < 2 || len >= INT_MAX) | ||
6886 | len = BC_NUM_PRINT_WIDTH; | ||
6887 | |||
6888 | return len; | ||
6889 | } | ||
6890 | |||
6891 | static BC_STATUS zxc_vm_process(const char *text) | 6879 | static BC_STATUS zxc_vm_process(const char *text) |
6892 | { | 6880 | { |
6893 | BcStatus s; | 6881 | BcStatus s; |
@@ -7377,12 +7365,43 @@ static void xc_program_init(void) | |||
7377 | bc_char_vec_init(&G.input_buffer); | 7365 | bc_char_vec_init(&G.input_buffer); |
7378 | } | 7366 | } |
7379 | 7367 | ||
7368 | static unsigned xc_vm_envLen(const char *var) | ||
7369 | { | ||
7370 | char *lenv; | ||
7371 | unsigned len; | ||
7372 | |||
7373 | lenv = getenv(var); | ||
7374 | len = BC_NUM_PRINT_WIDTH; | ||
7375 | if (lenv) { | ||
7376 | len = bb_strtou(lenv, NULL, 10); | ||
7377 | if (len == 0 || len > INT_MAX) | ||
7378 | len = INT_MAX; | ||
7379 | if (errno) | ||
7380 | len = BC_NUM_PRINT_WIDTH; | ||
7381 | } | ||
7382 | |||
7383 | // dc (GNU bc 1.07.1) 1.4.1 seems to use width | ||
7384 | // 1 char wider than bc from the same package. | ||
7385 | // Both default width, and xC_LINE_LENGTH=N are wider: | ||
7386 | // "DC_LINE_LENGTH=5 dc -e'123456 p'" prints: | ||
7387 | // |1234\ | | ||
7388 | // |56 | | ||
7389 | // "echo '123456' | BC_LINE_LENGTH=5 bc" prints: | ||
7390 | // |123\ | | ||
7391 | // |456 | | ||
7392 | // Do the same, but it might be a bug in GNU package | ||
7393 | if (IS_BC) | ||
7394 | len--; | ||
7395 | |||
7396 | if (len < 2) | ||
7397 | len = IS_BC ? BC_NUM_PRINT_WIDTH - 1 : BC_NUM_PRINT_WIDTH; | ||
7398 | |||
7399 | return len; | ||
7400 | } | ||
7401 | |||
7380 | static int xc_vm_init(const char *env_len) | 7402 | static int xc_vm_init(const char *env_len) |
7381 | { | 7403 | { |
7382 | G.prog.len = xc_vm_envLen(env_len); | 7404 | G.prog.len = xc_vm_envLen(env_len); |
7383 | #if ENABLE_FEATURE_EDITING | ||
7384 | G.line_input_state = new_line_input_t(DO_HISTORY); | ||
7385 | #endif | ||
7386 | bc_vec_init(&G.files, sizeof(char *), NULL); | 7405 | bc_vec_init(&G.files, sizeof(char *), NULL); |
7387 | 7406 | ||
7388 | xc_program_init(); | 7407 | xc_program_init(); |
@@ -7466,16 +7485,6 @@ int dc_main(int argc UNUSED_PARAM, char **argv) | |||
7466 | 7485 | ||
7467 | INIT_G(); | 7486 | INIT_G(); |
7468 | 7487 | ||
7469 | // TODO: dc (GNU bc 1.07.1) 1.4.1 seems to use width | ||
7470 | // 1 char wider than bc from the same package. | ||
7471 | // Both default width, and xC_LINE_LENGTH=N are wider: | ||
7472 | // "DC_LINE_LENGTH=5 dc -e'123456 p'" prints: | ||
7473 | // |1234\ | | ||
7474 | // |56 | | ||
7475 | // "echo '123456' | BC_LINE_LENGTH=5 bc" prints: | ||
7476 | // |123\ | | ||
7477 | // |456 | | ||
7478 | // Do the same, or it's a bug? | ||
7479 | xc_vm_init("DC_LINE_LENGTH"); | 7488 | xc_vm_init("DC_LINE_LENGTH"); |
7480 | 7489 | ||
7481 | // Run -e'SCRIPT' and -fFILE in order of appearance, then handle FILEs | 7490 | // Run -e'SCRIPT' and -fFILE in order of appearance, then handle FILEs |
diff --git a/miscutils/beep.c b/miscutils/beep.c index 1669332fd..7c60aed08 100644 --- a/miscutils/beep.c +++ b/miscutils/beep.c | |||
@@ -114,10 +114,10 @@ int beep_main(int argc, char **argv) | |||
114 | while (rep) { | 114 | while (rep) { |
115 | //bb_error_msg("rep[%d] freq=%d, length=%d, delay=%d", rep, freq, length, delay); | 115 | //bb_error_msg("rep[%d] freq=%d, length=%d, delay=%d", rep, freq, length, delay); |
116 | xioctl(speaker, KIOCSOUND, (void*)(uintptr_t)tickrate_div_freq); | 116 | xioctl(speaker, KIOCSOUND, (void*)(uintptr_t)tickrate_div_freq); |
117 | usleep(1000 * length); | 117 | msleep(length); |
118 | ioctl(speaker, KIOCSOUND, (void*)0); | 118 | ioctl(speaker, KIOCSOUND, (void*)0); |
119 | if (--rep) | 119 | if (--rep) |
120 | usleep(1000 * delay); | 120 | msleep(delay); |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
diff --git a/miscutils/chat.c b/miscutils/chat.c index a04565063..86a114df6 100644 --- a/miscutils/chat.c +++ b/miscutils/chat.c | |||
@@ -379,7 +379,7 @@ int chat_main(int argc UNUSED_PARAM, char **argv) | |||
379 | // dump device input if ECHO ON | 379 | // dump device input if ECHO ON |
380 | if (echo) { | 380 | if (echo) { |
381 | // if (buf[buf_len] < ' ') { | 381 | // if (buf[buf_len] < ' ') { |
382 | // full_write(STDERR_FILENO, "^", 1); | 382 | // full_write2_str("^"); |
383 | // buf[buf_len] += '@'; | 383 | // buf[buf_len] += '@'; |
384 | // } | 384 | // } |
385 | full_write(STDERR_FILENO, buf+buf_len, 1); | 385 | full_write(STDERR_FILENO, buf+buf_len, 1); |
@@ -473,7 +473,7 @@ int chat_main(int argc UNUSED_PARAM, char **argv) | |||
473 | if ('\\' == c) { | 473 | if ('\\' == c) { |
474 | c = *++buf; | 474 | c = *++buf; |
475 | if ('d' == c) { | 475 | if ('d' == c) { |
476 | sleep(1); | 476 | sleep1(); |
477 | len--; | 477 | len--; |
478 | continue; | 478 | continue; |
479 | } | 479 | } |
@@ -509,7 +509,7 @@ int chat_main(int argc UNUSED_PARAM, char **argv) | |||
509 | #if ENABLE_FEATURE_CHAT_IMPLICIT_CR | 509 | #if ENABLE_FEATURE_CHAT_IMPLICIT_CR |
510 | // or terminate command with \r (if not inhibited) | 510 | // or terminate command with \r (if not inhibited) |
511 | else if (!nocr) | 511 | else if (!nocr) |
512 | xwrite(STDOUT_FILENO, "\r", 1); | 512 | xwrite_str(STDOUT_FILENO, "\r"); |
513 | #endif | 513 | #endif |
514 | // bail out unless we sent command successfully | 514 | // bail out unless we sent command successfully |
515 | if (exitcode) | 515 | if (exitcode) |
diff --git a/miscutils/crond.c b/miscutils/crond.c index 2e8ca8b68..b74427351 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c | |||
@@ -63,7 +63,7 @@ | |||
63 | //kbuild:lib-$(CONFIG_CROND) += crond.o | 63 | //kbuild:lib-$(CONFIG_CROND) += crond.o |
64 | 64 | ||
65 | //usage:#define crond_trivial_usage | 65 | //usage:#define crond_trivial_usage |
66 | //usage: "-fbS -l N " IF_FEATURE_CROND_D("-d N ") "-L LOGFILE -c DIR" | 66 | //usage: "[-fbS] [-l N] " IF_FEATURE_CROND_D("[-d N] ") "[-L LOGFILE] [-c DIR]" |
67 | //usage:#define crond_full_usage "\n\n" | 67 | //usage:#define crond_full_usage "\n\n" |
68 | //usage: " -f Foreground" | 68 | //usage: " -f Foreground" |
69 | //usage: "\n -b Background (default)" | 69 | //usage: "\n -b Background (default)" |
@@ -492,7 +492,7 @@ static void load_crontab(const char *fileName) | |||
492 | const char *name; | 492 | const char *name; |
493 | const char tokens[8]; | 493 | const char tokens[8]; |
494 | } SpecialEntry; | 494 | } SpecialEntry; |
495 | static const SpecialEntry SpecAry[] = { | 495 | static const SpecialEntry SpecAry[] ALIGN8 = { |
496 | /* hour day month weekday */ | 496 | /* hour day month weekday */ |
497 | { "yearly", "0\0" "1\0" "1\0" "*" }, | 497 | { "yearly", "0\0" "1\0" "1\0" "*" }, |
498 | { "annually", "0\0" "1\0" "1\0" "*" }, | 498 | { "annually", "0\0" "1\0" "1\0" "*" }, |
diff --git a/miscutils/dc.c b/miscutils/dc.c index b6c6795b6..918f2b5c8 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c | |||
@@ -100,7 +100,7 @@ static void mod(void) | |||
100 | * 0 | 100 | * 0 |
101 | */ | 101 | */ |
102 | if (d == 0) { | 102 | if (d == 0) { |
103 | bb_error_msg("remainder by zero"); | 103 | bb_simple_error_msg("remainder by zero"); |
104 | pop(); | 104 | pop(); |
105 | push(0); | 105 | push(0); |
106 | return; | 106 | return; |
@@ -195,7 +195,7 @@ struct op { | |||
195 | void (*function) (void); | 195 | void (*function) (void); |
196 | }; | 196 | }; |
197 | 197 | ||
198 | static const struct op operators[] = { | 198 | static const struct op operators[] ALIGN_PTR = { |
199 | #if ENABLE_FEATURE_DC_LIBM | 199 | #if ENABLE_FEATURE_DC_LIBM |
200 | {"^", power}, | 200 | {"^", power}, |
201 | // {"exp", power}, | 201 | // {"exp", power}, |
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 17d8fb6b9..e5bb8a2d8 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
@@ -362,7 +362,7 @@ static const char bb_msg_variable_not_found[] ALIGN1 = "variable: %s not found"; | |||
362 | 362 | ||
363 | static void safe_memcpy(char *dest, const char *src, int len) | 363 | static void safe_memcpy(char *dest, const char *src, int len) |
364 | { | 364 | { |
365 | memcpy(dest , src, len); | 365 | memcpy(dest, src, len); |
366 | dest[len] = '\0'; | 366 | dest[len] = '\0'; |
367 | } | 367 | } |
368 | 368 | ||
@@ -1106,7 +1106,7 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat, | |||
1106 | do_chown: | 1106 | do_chown: |
1107 | if (chown(destpath, source_stat->st_uid, source_stat->st_gid) == 0) | 1107 | if (chown(destpath, source_stat->st_uid, source_stat->st_gid) == 0) |
1108 | return TRUE; | 1108 | return TRUE; |
1109 | /*break;*/ | 1109 | /*break;*/ |
1110 | } | 1110 | } |
1111 | return FALSE; | 1111 | return FALSE; |
1112 | } /* End Function copy_inode */ | 1112 | } /* End Function copy_inode */ |
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) | |||
75 | bb_show_usage(); /* one of bb_strtouXX failed */ | 75 | bb_show_usage(); /* one of bb_strtouXX failed */ |
76 | 76 | ||
77 | fd = xopen("/dev/mem", argv[3] ? (O_RDWR | O_SYNC) : (O_RDONLY | O_SYNC)); | 77 | fd = xopen("/dev/mem", argv[3] ? (O_RDWR | O_SYNC) : (O_RDONLY | O_SYNC)); |
78 | mapped_size = page_size = getpagesize(); | 78 | mapped_size = page_size = bb_getpagesize(); |
79 | offset_in_page = (unsigned)target & (page_size - 1); | 79 | offset_in_page = (unsigned)target & (page_size - 1); |
80 | if (offset_in_page + width > page_size) { | 80 | if (offset_in_page + width > page_size) { |
81 | /* This access spans pages. | 81 | /* This access spans pages. |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index d25a2466e..01b4e8e2e 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -1366,7 +1366,7 @@ static NOINLINE void dump_identity(const struct hd_driveid *id) | |||
1366 | } | 1366 | } |
1367 | if (id->capability & 1) { | 1367 | if (id->capability & 1) { |
1368 | if (id->dma_1word | id->dma_mword) { | 1368 | if (id->dma_1word | id->dma_mword) { |
1369 | static const int dma_wmode_masks[] = { 0x100, 1, 0x200, 2, 0x400, 4, 0xf800, 0xf8 }; | 1369 | static const int dma_wmode_masks[] ALIGN4 = { 0x100, 1, 0x200, 2, 0x400, 4, 0xf800, 0xf8 }; |
1370 | printf("\n DMA modes: "); | 1370 | printf("\n DMA modes: "); |
1371 | print_flags_separated(dma_wmode_masks, | 1371 | print_flags_separated(dma_wmode_masks, |
1372 | "*\0""sdma0 \0""*\0""sdma1 \0""*\0""sdma2 \0""*\0""sdma? \0", | 1372 | "*\0""sdma0 \0""*\0""sdma1 \0""*\0""sdma2 \0""*\0""sdma? \0", |
@@ -1436,7 +1436,7 @@ static void flush_buffer_cache(/*int fd*/ void) | |||
1436 | fsync(fd); /* flush buffers */ | 1436 | fsync(fd); /* flush buffers */ |
1437 | ioctl_or_warn(fd, BLKFLSBUF, NULL); /* do it again, big time */ | 1437 | ioctl_or_warn(fd, BLKFLSBUF, NULL); /* do it again, big time */ |
1438 | #ifdef HDIO_DRIVE_CMD | 1438 | #ifdef HDIO_DRIVE_CMD |
1439 | sleep(1); | 1439 | sleep1(); |
1440 | if (ioctl(fd, HDIO_DRIVE_CMD, NULL) && errno != EINVAL) { /* await completion */ | 1440 | if (ioctl(fd, HDIO_DRIVE_CMD, NULL) && errno != EINVAL) { /* await completion */ |
1441 | if (ENABLE_IOCTL_HEX2STR_ERROR) /* To be coherent with ioctl_or_warn */ | 1441 | if (ENABLE_IOCTL_HEX2STR_ERROR) /* To be coherent with ioctl_or_warn */ |
1442 | bb_simple_perror_msg("HDIO_DRIVE_CMD"); | 1442 | bb_simple_perror_msg("HDIO_DRIVE_CMD"); |
@@ -1511,7 +1511,7 @@ static void do_time(int cache /*,int fd*/) | |||
1511 | * NB: *small* delay. User is expected to have a clue and to not run | 1511 | * NB: *small* delay. User is expected to have a clue and to not run |
1512 | * heavy io in parallel with measurements. */ | 1512 | * heavy io in parallel with measurements. */ |
1513 | sync(); | 1513 | sync(); |
1514 | sleep(1); | 1514 | sleep1(); |
1515 | if (cache) { /* Time cache */ | 1515 | if (cache) { /* Time cache */ |
1516 | seek_to_zero(); | 1516 | seek_to_zero(); |
1517 | read_big_block(buf); | 1517 | read_big_block(buf); |
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) { |
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index cc8b99a92..48135921d 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c | |||
@@ -273,7 +273,7 @@ static int i2c_bus_lookup(const char *bus_str) | |||
273 | return xstrtou_range(bus_str, 10, 0, 0xfffff); | 273 | return xstrtou_range(bus_str, 10, 0, 0xfffff); |
274 | } | 274 | } |
275 | 275 | ||
276 | #if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP || ENABLE_I2CTRANSFER | 276 | #if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP |
277 | static int i2c_parse_bus_addr(const char *addr_str) | 277 | static int i2c_parse_bus_addr(const char *addr_str) |
278 | { | 278 | { |
279 | /* Slave address must be in range 0x03 - 0x77. */ | 279 | /* Slave address must be in range 0x03 - 0x77. */ |
@@ -286,14 +286,16 @@ static void i2c_set_pec(int fd, int pec) | |||
286 | itoptr(pec ? 1 : 0), | 286 | itoptr(pec ? 1 : 0), |
287 | "can't set PEC"); | 287 | "can't set PEC"); |
288 | } | 288 | } |
289 | #endif | ||
289 | 290 | ||
291 | #if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP || ENABLE_I2CTRANSFER | ||
290 | static void i2c_set_slave_addr(int fd, int addr, int force) | 292 | static void i2c_set_slave_addr(int fd, int addr, int force) |
291 | { | 293 | { |
292 | ioctl_or_perror_and_die(fd, force ? I2C_SLAVE_FORCE : I2C_SLAVE, | 294 | ioctl_or_perror_and_die(fd, force ? I2C_SLAVE_FORCE : I2C_SLAVE, |
293 | itoptr(addr), | 295 | itoptr(addr), |
294 | "can't set address to 0x%02x", addr); | 296 | "can't set address to 0x%02x", addr); |
295 | } | 297 | } |
296 | #endif /* ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP */ | 298 | #endif |
297 | 299 | ||
298 | #if ENABLE_I2CGET || ENABLE_I2CSET | 300 | #if ENABLE_I2CGET || ENABLE_I2CSET |
299 | static int i2c_parse_data_addr(const char *data_addr) | 301 | static int i2c_parse_data_addr(const char *data_addr) |
@@ -1052,24 +1054,19 @@ struct adap_desc { | |||
1052 | const char *algo; | 1054 | const char *algo; |
1053 | }; | 1055 | }; |
1054 | 1056 | ||
1055 | static const struct adap_desc adap_descs[] = { | 1057 | static const struct adap_desc adap_descs[] ALIGN_PTR = { |
1056 | { .funcs = "dummy", | 1058 | { .funcs = "dummy", .algo = "Dummy bus", }, |
1057 | .algo = "Dummy bus", }, | 1059 | { .funcs = "isa", .algo = "ISA bus", }, |
1058 | { .funcs = "isa", | 1060 | { .funcs = "i2c", .algo = "I2C adapter", }, |
1059 | .algo = "ISA bus", }, | 1061 | { .funcs = "smbus", .algo = "SMBus adapter", }, |
1060 | { .funcs = "i2c", | ||
1061 | .algo = "I2C adapter", }, | ||
1062 | { .funcs = "smbus", | ||
1063 | .algo = "SMBus adapter", }, | ||
1064 | }; | 1062 | }; |
1065 | 1063 | ||
1066 | struct i2c_func | 1064 | struct i2c_func { |
1067 | { | ||
1068 | long value; | 1065 | long value; |
1069 | const char* name; | 1066 | const char* name; |
1070 | }; | 1067 | }; |
1071 | 1068 | ||
1072 | static const struct i2c_func i2c_funcs_tab[] = { | 1069 | static const struct i2c_func i2c_funcs_tab[] ALIGN_PTR = { |
1073 | { .value = I2C_FUNC_I2C, | 1070 | { .value = I2C_FUNC_I2C, |
1074 | .name = "I2C" }, | 1071 | .name = "I2C" }, |
1075 | { .value = I2C_FUNC_SMBUS_QUICK, | 1072 | { .value = I2C_FUNC_SMBUS_QUICK, |
@@ -1152,12 +1149,12 @@ static void NORETURN list_i2c_busses_and_exit(void) | |||
1152 | /* Simple version for ISA chips. */ | 1149 | /* Simple version for ISA chips. */ |
1153 | snprintf(path, NAME_MAX, "%s/%s/name", | 1150 | snprintf(path, NAME_MAX, "%s/%s/name", |
1154 | i2cdev_path, de->d_name); | 1151 | i2cdev_path, de->d_name); |
1155 | fp = fopen(path, "r"); | 1152 | fp = fopen_for_read(path); |
1156 | if (fp == NULL) { | 1153 | if (fp == NULL) { |
1157 | snprintf(path, NAME_MAX, | 1154 | snprintf(path, NAME_MAX, |
1158 | "%s/%s/device/name", | 1155 | "%s/%s/device/name", |
1159 | i2cdev_path, de->d_name); | 1156 | i2cdev_path, de->d_name); |
1160 | fp = fopen(path, "r"); | 1157 | fp = fopen_for_read(path); |
1161 | } | 1158 | } |
1162 | 1159 | ||
1163 | /* Non-ISA chips require the hard-way. */ | 1160 | /* Non-ISA chips require the hard-way. */ |
@@ -1178,7 +1175,7 @@ static void NORETURN list_i2c_busses_and_exit(void) | |||
1178 | "%s/%s/device/%s/name", | 1175 | "%s/%s/device/%s/name", |
1179 | i2cdev_path, de->d_name, | 1176 | i2cdev_path, de->d_name, |
1180 | subde->d_name); | 1177 | subde->d_name); |
1181 | fp = fopen(path, "r"); | 1178 | fp = fopen_for_read(path); |
1182 | break; | 1179 | break; |
1183 | } | 1180 | } |
1184 | } | 1181 | } |
diff --git a/miscutils/man.c b/miscutils/man.c index 6724b4b5d..052b50054 100644 --- a/miscutils/man.c +++ b/miscutils/man.c | |||
@@ -13,7 +13,7 @@ | |||
13 | //kbuild:lib-$(CONFIG_MAN) += man.o | 13 | //kbuild:lib-$(CONFIG_MAN) += man.o |
14 | 14 | ||
15 | //usage:#define man_trivial_usage | 15 | //usage:#define man_trivial_usage |
16 | //usage: "[-aw] MANPAGE..." | 16 | //usage: "[-aw] [SECTION] MANPAGE[.SECTION]..." |
17 | //usage:#define man_full_usage "\n\n" | 17 | //usage:#define man_full_usage "\n\n" |
18 | //usage: "Display manual page\n" | 18 | //usage: "Display manual page\n" |
19 | //usage: "\n -a Display all pages" | 19 | //usage: "\n -a Display all pages" |
@@ -239,10 +239,21 @@ static const char *if_redefined(const char *var, const char *key, const char *li | |||
239 | return xstrdup(skip_whitespace(line)); | 239 | return xstrdup(skip_whitespace(line)); |
240 | } | 240 | } |
241 | 241 | ||
242 | static int is_section_name(const char *sections, const char *str) | ||
243 | { | ||
244 | const char *s = strstr(sections, str); | ||
245 | if (s) { | ||
246 | int l = strlen(str); | ||
247 | return (s[l] == ':' || s[l] == '\0'); | ||
248 | } | ||
249 | return 0; | ||
250 | } | ||
251 | |||
242 | int man_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 252 | int man_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
243 | int man_main(int argc UNUSED_PARAM, char **argv) | 253 | int man_main(int argc UNUSED_PARAM, char **argv) |
244 | { | 254 | { |
245 | parser_t *parser; | 255 | parser_t *parser; |
256 | char *conf_sec_list; | ||
246 | char *sec_list; | 257 | char *sec_list; |
247 | char **man_path_list; | 258 | char **man_path_list; |
248 | int count_mp; | 259 | int count_mp; |
@@ -267,7 +278,7 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
267 | chdir_system_drive(); | 278 | chdir_system_drive(); |
268 | #endif | 279 | #endif |
269 | 280 | ||
270 | sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9"); | 281 | conf_sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9"); |
271 | 282 | ||
272 | count_mp = 0; | 283 | count_mp = 0; |
273 | man_path_list = add_MANPATH(NULL, &count_mp, | 284 | man_path_list = add_MANPATH(NULL, &count_mp, |
@@ -297,8 +308,8 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
297 | man_path_list = add_MANPATH(man_path_list, &count_mp, token[1]); | 308 | man_path_list = add_MANPATH(man_path_list, &count_mp, token[1]); |
298 | } | 309 | } |
299 | if (strcmp("MANSECT", token[0]) == 0) { | 310 | if (strcmp("MANSECT", token[0]) == 0) { |
300 | free(sec_list); | 311 | free(conf_sec_list); |
301 | sec_list = xstrdup(token[1]); | 312 | conf_sec_list = xstrdup(token[1]); |
302 | } | 313 | } |
303 | } | 314 | } |
304 | config_close(parser); | 315 | config_close(parser); |
@@ -337,6 +348,13 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
337 | G.pager = xasprintf("%s -b -p -x", G.col); | 348 | G.pager = xasprintf("%s -b -p -x", G.col); |
338 | } | 349 | } |
339 | 350 | ||
351 | /* is 1st ARG a SECTION? */ | ||
352 | sec_list = conf_sec_list; | ||
353 | if (is_section_name(conf_sec_list, *argv)) { | ||
354 | /* yes */ | ||
355 | sec_list = *argv++; | ||
356 | } | ||
357 | |||
340 | not_found = 0; | 358 | not_found = 0; |
341 | do { /* for each argv[] */ | 359 | do { /* for each argv[] */ |
342 | const char *cur_path; | 360 | const char *cur_path; |
@@ -347,11 +365,20 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
347 | found = show_manpage(*argv, /*man:*/ 1, 0); | 365 | found = show_manpage(*argv, /*man:*/ 1, 0); |
348 | goto check_found; | 366 | goto check_found; |
349 | } | 367 | } |
368 | |||
369 | /* for each MANPATH */ | ||
350 | cur_mp = 0; | 370 | cur_mp = 0; |
351 | while ((cur_path = man_path_list[cur_mp++]) != NULL) { | 371 | while ((cur_path = man_path_list[cur_mp++]) != NULL) { |
352 | /* for each MANPATH */ | ||
353 | const char *cur_sect = sec_list; | 372 | const char *cur_sect = sec_list; |
354 | do { /* for each section */ | 373 | |
374 | /* is MANPAGE of the form NAME.SECTION? */ | ||
375 | char *sect_ext = strrchr(*argv, '.'); | ||
376 | if (sect_ext && is_section_name(conf_sec_list, sect_ext + 1)) { | ||
377 | *sect_ext = '\0'; | ||
378 | cur_sect = sect_ext + 1; | ||
379 | } | ||
380 | |||
381 | do { /* for each SECTION in cur_sect */ | ||
355 | char *next_sect = strchrnul(cur_sect, ':'); | 382 | char *next_sect = strchrnul(cur_sect, ':'); |
356 | int sect_len = next_sect - cur_sect; | 383 | int sect_len = next_sect - cur_sect; |
357 | char *man_filename; | 384 | char *man_filename; |
@@ -378,6 +405,8 @@ int man_main(int argc UNUSED_PARAM, char **argv) | |||
378 | while (*cur_sect == ':') | 405 | while (*cur_sect == ':') |
379 | cur_sect++; | 406 | cur_sect++; |
380 | } while (*cur_sect); | 407 | } while (*cur_sect); |
408 | |||
409 | if (sect_ext) *sect_ext = '.'; | ||
381 | } | 410 | } |
382 | check_found: | 411 | check_found: |
383 | if (!found) { | 412 | if (!found) { |
diff --git a/miscutils/mt.c b/miscutils/mt.c index 9f1aecfca..1a4214664 100644 --- a/miscutils/mt.c +++ b/miscutils/mt.c | |||
@@ -15,7 +15,7 @@ | |||
15 | //kbuild:lib-$(CONFIG_MT) += mt.o | 15 | //kbuild:lib-$(CONFIG_MT) += mt.o |
16 | 16 | ||
17 | //usage:#define mt_trivial_usage | 17 | //usage:#define mt_trivial_usage |
18 | //usage: "[-f device] opcode value" | 18 | //usage: "[-f DEVICE] OPCODE VALUE" |
19 | //usage:#define mt_full_usage "\n\n" | 19 | //usage:#define mt_full_usage "\n\n" |
20 | //usage: "Control magnetic tape drive operation\n" | 20 | //usage: "Control magnetic tape drive operation\n" |
21 | //usage: "\n" | 21 | //usage: "\n" |
@@ -30,7 +30,7 @@ | |||
30 | #include <sys/mtio.h> | 30 | #include <sys/mtio.h> |
31 | 31 | ||
32 | /* missing: eod/seod, stoptions, stwrthreshold, densities */ | 32 | /* missing: eod/seod, stoptions, stwrthreshold, densities */ |
33 | static const short opcode_value[] = { | 33 | static const short opcode_value[] ALIGN2 = { |
34 | MTBSF, | 34 | MTBSF, |
35 | MTBSFM, | 35 | MTBSFM, |
36 | MTBSR, | 36 | MTBSR, |
diff --git a/miscutils/setserial.c b/miscutils/setserial.c index 1e75bf433..2006861e2 100644 --- a/miscutils/setserial.c +++ b/miscutils/setserial.c | |||
@@ -381,8 +381,7 @@ static bool cmd_needs_arg(int cmd) | |||
381 | # error "Unexpected flags size" | 381 | # error "Unexpected flags size" |
382 | #endif | 382 | #endif |
383 | 383 | ||
384 | static const uint16_t setbits[CMD_FLAG_LAST + 1] = | 384 | static const uint16_t setbits[CMD_FLAG_LAST + 1] ALIGN2 = { |
385 | { | ||
386 | 0, | 385 | 0, |
387 | ASYNC_SPD_HI, | 386 | ASYNC_SPD_HI, |
388 | ASYNC_SPD_VHI, | 387 | ASYNC_SPD_VHI, |
diff --git a/miscutils/time.c b/miscutils/time.c index dcc3a5b4c..12c540211 100644 --- a/miscutils/time.c +++ b/miscutils/time.c | |||
@@ -127,6 +127,10 @@ static void printargv(char *const *argv) | |||
127 | This is funky since the pagesize could be less than 1K. | 127 | This is funky since the pagesize could be less than 1K. |
128 | Note: Some machines express getrusage statistics in terms of K, | 128 | Note: Some machines express getrusage statistics in terms of K, |
129 | others in terms of pages. */ | 129 | others in terms of pages. */ |
130 | #ifdef BB_ARCH_FIXED_PAGESIZE | ||
131 | # define pagesize BB_ARCH_FIXED_PAGESIZE | ||
132 | # define ptok(pagesize, pages) ptok(pages) | ||
133 | #endif | ||
130 | static unsigned long ptok(const unsigned pagesize, const unsigned long pages) | 134 | static unsigned long ptok(const unsigned pagesize, const unsigned long pages) |
131 | { | 135 | { |
132 | unsigned long tmp; | 136 | unsigned long tmp; |
@@ -140,6 +144,7 @@ static unsigned long ptok(const unsigned pagesize, const unsigned long pages) | |||
140 | tmp = pages * pagesize; /* Larger first, */ | 144 | tmp = pages * pagesize; /* Larger first, */ |
141 | return tmp / 1024; /* then smaller. */ | 145 | return tmp / 1024; /* then smaller. */ |
142 | } | 146 | } |
147 | #undef pagesize | ||
143 | #endif | 148 | #endif |
144 | 149 | ||
145 | /* summarize: Report on the system use of a command. | 150 | /* summarize: Report on the system use of a command. |
@@ -199,7 +204,7 @@ static void summarize(const char *fmt, char **command, resource_t *resp) | |||
199 | #if !ENABLE_PLATFORM_MINGW32 | 204 | #if !ENABLE_PLATFORM_MINGW32 |
200 | unsigned vv_ms; /* Elapsed virtual (CPU) milliseconds */ | 205 | unsigned vv_ms; /* Elapsed virtual (CPU) milliseconds */ |
201 | unsigned cpu_ticks; /* Same, in "CPU ticks" */ | 206 | unsigned cpu_ticks; /* Same, in "CPU ticks" */ |
202 | unsigned pagesize = getpagesize(); | 207 | unsigned pagesize = bb_getpagesize(); |
203 | #endif | 208 | #endif |
204 | 209 | ||
205 | /* Impossible: we do not use WUNTRACED flag in wait()... | 210 | /* Impossible: we do not use WUNTRACED flag in wait()... |
diff --git a/miscutils/ts.c b/miscutils/ts.c index f769d663b..3eecb7464 100644 --- a/miscutils/ts.c +++ b/miscutils/ts.c | |||
@@ -50,13 +50,13 @@ int ts_main(int argc UNUSED_PARAM, char **argv) | |||
50 | 50 | ||
51 | #define date_buf bb_common_bufsiz1 | 51 | #define date_buf bb_common_bufsiz1 |
52 | setup_common_bufsiz(); | 52 | setup_common_bufsiz(); |
53 | gettimeofday(&base, NULL); | 53 | xgettimeofday(&base); |
54 | 54 | ||
55 | while ((line = xmalloc_fgets(stdin)) != NULL) { | 55 | while ((line = xmalloc_fgets(stdin)) != NULL) { |
56 | struct timeval ts; | 56 | struct timeval ts; |
57 | struct tm tm_time; | 57 | struct tm tm_time; |
58 | 58 | ||
59 | gettimeofday(&ts, NULL); | 59 | xgettimeofday(&ts); |
60 | if (opt) { | 60 | if (opt) { |
61 | /* -i and/or -s */ | 61 | /* -i and/or -s */ |
62 | struct timeval ts1 = ts1; | 62 | struct timeval ts1 = ts1; |
diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c index 94a637eee..69ead7a13 100644 --- a/miscutils/ubi_tools.c +++ b/miscutils/ubi_tools.c | |||
@@ -97,7 +97,7 @@ static unsigned get_num_from_file(const char *path, unsigned max) | |||
97 | int ubi_tools_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 97 | int ubi_tools_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
98 | int ubi_tools_main(int argc UNUSED_PARAM, char **argv) | 98 | int ubi_tools_main(int argc UNUSED_PARAM, char **argv) |
99 | { | 99 | { |
100 | static const struct suffix_mult size_suffixes[] = { | 100 | static const struct suffix_mult size_suffixes[] ALIGN_SUFFIX = { |
101 | { "KiB", 1024 }, | 101 | { "KiB", 1024 }, |
102 | { "MiB", 1024*1024 }, | 102 | { "MiB", 1024*1024 }, |
103 | { "GiB", 1024*1024*1024 }, | 103 | { "GiB", 1024*1024*1024 }, |
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index 8c8d7217f..0ed10bcf1 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c | |||
@@ -88,7 +88,7 @@ int watchdog_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
88 | int watchdog_main(int argc UNUSED_PARAM, char **argv) | 88 | int watchdog_main(int argc UNUSED_PARAM, char **argv) |
89 | { | 89 | { |
90 | static const int enable = WDIOS_ENABLECARD; | 90 | static const int enable = WDIOS_ENABLECARD; |
91 | static const struct suffix_mult suffixes[] = { | 91 | static const struct suffix_mult suffixes[] ALIGN_SUFFIX = { |
92 | { "ms", 1 }, | 92 | { "ms", 1 }, |
93 | { "", 1000 }, | 93 | { "", 1000 }, |
94 | { "", 0 } | 94 | { "", 0 } |
@@ -143,7 +143,7 @@ int watchdog_main(int argc UNUSED_PARAM, char **argv) | |||
143 | * as the counter value is undefined at this point -- PFM | 143 | * as the counter value is undefined at this point -- PFM |
144 | */ | 144 | */ |
145 | write(3, "", 1); /* write zero byte */ | 145 | write(3, "", 1); /* write zero byte */ |
146 | usleep(stimer_duration * 1000L); | 146 | msleep(stimer_duration); |
147 | } | 147 | } |
148 | return EXIT_SUCCESS; /* - not reached, but gcc 4.2.1 is too dumb! */ | 148 | return EXIT_SUCCESS; /* - not reached, but gcc 4.2.1 is too dumb! */ |
149 | } | 149 | } |