aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-07-14 10:11:45 +0100
committerRon Yorston <rmy@pobox.com>2024-07-14 10:11:45 +0100
commit6198a0ff055751d5cda4017a3d4821dc93ad77d1 (patch)
treee637781f4d186a6c39e9f6c9aa42b8ad97f978bb
parentb18891bba511d4fc4fcd0a6ff5cd2df31a086f1b (diff)
parent371fe9f71d445d18be28c82a2a6d82115c8af19d (diff)
downloadbusybox-w32-6198a0ff055751d5cda4017a3d4821dc93ad77d1.tar.gz
busybox-w32-6198a0ff055751d5cda4017a3d4821dc93ad77d1.tar.bz2
busybox-w32-6198a0ff055751d5cda4017a3d4821dc93ad77d1.zip
Merge branch 'busybox' into merge
-rw-r--r--coreutils/timeout.c23
-rw-r--r--procps/powertop.c25
-rw-r--r--shell/ash.c22
3 files changed, 30 insertions, 40 deletions
diff --git a/coreutils/timeout.c b/coreutils/timeout.c
index 802ddfc07..764927a12 100644
--- a/coreutils/timeout.c
+++ b/coreutils/timeout.c
@@ -61,10 +61,10 @@ static void kill_child(void)
61} 61}
62 62
63/* Return TRUE if child exits before timeout expires */ 63/* Return TRUE if child exits before timeout expires */
64/* NB timeout is in milliseconds */ 64static NOINLINE int timeout_wait(duration_t timeout, HANDLE proc, DWORD *status)
65static NOINLINE int timeout_wait(int timeout, HANDLE proc, DWORD *status)
66{ 65{
67 if (WaitForSingleObject(proc, timeout) == WAIT_OBJECT_0) { 66 DWORD t = (DWORD)(timeout * 1000);
67 if (WaitForSingleObject(proc, t) == WAIT_OBJECT_0) {
68 /* process is gone */ 68 /* process is gone */
69 GetExitCodeProcess(proc, status); 69 GetExitCodeProcess(proc, status);
70 return TRUE; 70 return TRUE;
@@ -72,11 +72,16 @@ static NOINLINE int timeout_wait(int timeout, HANDLE proc, DWORD *status)
72 return FALSE; 72 return FALSE;
73} 73}
74#else 74#else
75static NOINLINE int timeout_wait(int timeout, pid_t pid) 75static NOINLINE int timeout_wait(duration_t timeout, pid_t pid)
76{ 76{
77 /* Just sleep(HUGE_NUM); kill(parent) may kill wrong process! */ 77 /* Just sleep(HUGE_NUM); kill(parent) may kill wrong process! */
78 while (1) { 78 while (1) {
79 sleep1(); 79#if ENABLE_FLOAT_DURATION
80 if (timeout < 1)
81 sleep_for_duration(timeout);
82 else
83#endif
84 sleep1();
80 if (--timeout <= 0) 85 if (--timeout <= 0)
81 break; 86 break;
82 if (kill(pid, 0)) { 87 if (kill(pid, 0)) {
@@ -99,8 +104,8 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
99 intptr_t ret; 104 intptr_t ret;
100 DWORD status = EXIT_SUCCESS; 105 DWORD status = EXIT_SUCCESS;
101#endif 106#endif
102 int timeout; 107 duration_t timeout;
103 int kill_timeout; 108 duration_t kill_timeout;
104 pid_t pid; 109 pid_t pid;
105#if !BB_MMU 110#if !BB_MMU
106 char *sv1, *sv2; 111 char *sv1, *sv2;
@@ -133,11 +138,11 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
133 138
134 kill_timeout = 0; 139 kill_timeout = 0;
135 if (opt_k) 140 if (opt_k)
136 kill_timeout = parse_duration_str(opt_k) IF_PLATFORM_MINGW32(* 1000); 141 kill_timeout = parse_duration_str(opt_k);
137 142
138 if (!argv[optind]) 143 if (!argv[optind])
139 bb_show_usage(); 144 bb_show_usage();
140 timeout = parse_duration_str(argv[optind++]) IF_PLATFORM_MINGW32(* 1000); 145 timeout = parse_duration_str(argv[optind++]);
141 if (!argv[optind]) /* no PROG? */ 146 if (!argv[optind]) /* no PROG? */
142 bb_show_usage(); 147 bb_show_usage();
143 148
diff --git a/procps/powertop.c b/procps/powertop.c
index 147b7a3ef..6fe892540 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -498,24 +498,11 @@ static NOINLINE int process_timer_stats(void)
498} 498}
499 499
500#ifdef __i386__ 500#ifdef __i386__
501/* 501static void cpuid_eax_ecx_edx(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
502 * Get information about CPU using CPUID opcode.
503 */
504static void cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
505 unsigned int *edx)
506{ 502{
507 /* EAX value specifies what information to return */ 503 asm ("cpuid"
508 asm ( 504 : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx)
509 " cpuid\n" 505 : "0" (*eax), "2" (*ecx), "3" (*edx)
510 : "=a"(*eax), /* Output */
511 "=b"(*ebx),
512 "=c"(*ecx),
513 "=d"(*edx)
514 : "0"(*eax), /* Input */
515 "1"(*ebx),
516 "2"(*ecx),
517 "3"(*edx)
518 /* No clobbered registers */
519 ); 506 );
520} 507}
521#endif 508#endif
@@ -592,8 +579,8 @@ static NOINLINE void print_intel_cstates(void)
592 return; 579 return;
593 580
594 eax = 5; 581 eax = 5;
595 ebx = ecx = edx = 0; 582 ecx = edx = 0; /* paranoia, should not be needed */
596 cpuid(&eax, &ebx, &ecx, &edx); 583 cpuid_eax_ecx_edx(&eax, /*unused:*/&ebx, &ecx, &edx);
597 if (!edx || !(ecx & 1)) 584 if (!edx || !(ecx & 1))
598 return; 585 return;
599 586
diff --git a/shell/ash.c b/shell/ash.c
index 7a9f20ec0..15c0e56a3 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -2592,9 +2592,11 @@ initvar(void)
2592} 2592}
2593 2593
2594static struct var ** 2594static struct var **
2595findvar(struct var **vpp, const char *name) 2595findvar(const char *name)
2596{ 2596{
2597 for (; *vpp; vpp = &(*vpp)->next) { 2597 struct var **vpp;
2598
2599 for (vpp = hashvar(name); *vpp; vpp = &(*vpp)->next) {
2598 if (varcmp((*vpp)->var_text, name) == 0) { 2600 if (varcmp((*vpp)->var_text, name) == 0) {
2599 break; 2601 break;
2600 } 2602 }
@@ -2610,7 +2612,7 @@ lookupvar(const char *name)
2610{ 2612{
2611 struct var *v; 2613 struct var *v;
2612 2614
2613 v = *findvar(hashvar(name), name); 2615 v = *findvar(name);
2614 if (v) { 2616 if (v) {
2615#if ENABLE_ASH_RANDOM_SUPPORT || BASH_EPOCH_VARS 2617#if ENABLE_ASH_RANDOM_SUPPORT || BASH_EPOCH_VARS
2616 /* 2618 /*
@@ -2756,9 +2758,8 @@ setvareq(char *s, int flags)
2756 } 2758 }
2757#endif 2759#endif
2758 2760
2759 vpp = hashvar(s);
2760 flags |= (VEXPORT & (((unsigned) (1 - aflag)) - 1)); 2761 flags |= (VEXPORT & (((unsigned) (1 - aflag)) - 1));
2761 vpp = findvar(vpp, s); 2762 vpp = findvar(s);
2762 vp = *vpp; 2763 vp = *vpp;
2763 if (vp) { 2764 if (vp) {
2764 if ((vp->flags & (VREADONLY|VDYNAMIC)) == VREADONLY) { 2765 if ((vp->flags & (VREADONLY|VDYNAMIC)) == VREADONLY) {
@@ -11131,7 +11132,6 @@ static void
11131mklocal(char *name, int flags) 11132mklocal(char *name, int flags)
11132{ 11133{
11133 struct localvar *lvp; 11134 struct localvar *lvp;
11134 struct var **vpp;
11135 struct var *vp; 11135 struct var *vp;
11136 char *eq = strchr(name, '='); 11136 char *eq = strchr(name, '=');
11137 11137
@@ -11160,8 +11160,7 @@ mklocal(char *name, int flags)
11160 lvp->text = memcpy(p, optlist, sizeof(optlist)); 11160 lvp->text = memcpy(p, optlist, sizeof(optlist));
11161 vp = NULL; 11161 vp = NULL;
11162 } else { 11162 } else {
11163 vpp = hashvar(name); 11163 vp = *findvar(name);
11164 vp = *findvar(vpp, name);
11165 if (vp == NULL) { 11164 if (vp == NULL) {
11166 /* variable did not exist yet */ 11165 /* variable did not exist yet */
11167 if (eq) 11166 if (eq)
@@ -15510,7 +15509,7 @@ exportcmd(int argc UNUSED_PARAM, char **argv)
15510 if (p != NULL) { 15509 if (p != NULL) {
15511 p++; 15510 p++;
15512 } else { 15511 } else {
15513 vp = *findvar(hashvar(name), name); 15512 vp = *findvar(name);
15514 if (vp) { 15513 if (vp) {
15515#if ENABLE_PLATFORM_MINGW32 15514#if ENABLE_PLATFORM_MINGW32
15516 if (is_bb_var(name) == BB_VAR_EXACT) { 15515 if (is_bb_var(name) == BB_VAR_EXACT) {
@@ -16553,7 +16552,7 @@ reinitvar(void)
16553{ 16552{
16554 int i; 16553 int i;
16555 const char *name; 16554 const char *name;
16556 struct var **vpp, **old; 16555 struct var **old;
16557 16556
16558 for (i=0; i<ARRAY_SIZE(varinit); ++i) { 16557 for (i=0; i<ARRAY_SIZE(varinit); ++i) {
16559 if (i == LINENO_INDEX) 16558 if (i == LINENO_INDEX)
@@ -16562,8 +16561,7 @@ reinitvar(void)
16562 name = "FUNCNAME="; 16561 name = "FUNCNAME=";
16563 else 16562 else
16564 name = varinit_data[i].var_text; 16563 name = varinit_data[i].var_text;
16565 vpp = hashvar(name); 16564 if ((old = findvar(name)) != NULL) {
16566 if ( (old=findvar(vpp, name)) != NULL ) {
16567 varinit[i] = **old; 16565 varinit[i] = **old;
16568 *old = varinit+i; 16566 *old = varinit+i;
16569 } 16567 }