From 333c65ca71f1acb2cc6cd3920a346bb8ddf82dec Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 12 Apr 2026 11:49:29 +0100 Subject: ash: allow 'times' built-in to report process timing Move existing code which obtains process execution times into a separate function. Use it to allow times(2) to report execution times for the current process, though not child execution times. Change TICKS_PER_SECOND from 100 to 1000 to increase the displayed resolution of process times (though the measured resolution may well be less than this). Adds 48-80 bytes. (GitHub issue #574) --- include/libbb.h | 3 +++ include/mingw.h | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index ee3a5b56a..a73a04153 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -2435,6 +2435,9 @@ unsigned get_cpu_count(void) FAST_FUNC; unsigned long FAST_FUNC fast_strtoul_10(char **endptr); unsigned long long FAST_FUNC fast_strtoull_16(char **endptr); char* FAST_FUNC skip_fields(char *str, int count); +#if ENABLE_PLATFORM_MINGW32 +void get_process_times(DWORD pid, procps_status_t* sp); +#endif /* Use strict=1 if you process input from untrusted source: diff --git a/include/mingw.h b/include/mingw.h index a77aa35ac..ac824fd52 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -488,9 +488,9 @@ clock_t times(struct tms *buf); #define _SC_CLK_TCK 2 -#define TICKS_PER_SECOND 100 -#define MS_PER_TICK 10 -#define HNSEC_PER_TICK 100000 +#define TICKS_PER_SECOND 1000 +#define MS_PER_TICK 1 +#define HNSEC_PER_TICK 10000 IMPL(alarm,unsigned int,0,unsigned int seconds UNUSED_PARAM); IMPL(chown,int,0,const char *path UNUSED_PARAM, uid_t uid UNUSED_PARAM, gid_t gid UNUSED_PARAM); -- cgit v1.2.3-55-g6feb