diff options
author | Cameron Esfahani | 2022-01-28 01:12:51 +0100 |
---|---|---|
committer | Laurent Vivier | 2022-01-28 11:08:54 +0100 |
commit | eb33cdaeda55d951f915152ad23816d47aca9955 (patch) | |
tree | 80047456f49e6a26144043469bde7df9163217b8 /linux-user/main.c | |
parent | linux-user: sigprocmask check read perms first (diff) | |
download | qemu-eb33cdaeda55d951f915152ad23816d47aca9955.tar.gz qemu-eb33cdaeda55d951f915152ad23816d47aca9955.tar.xz qemu-eb33cdaeda55d951f915152ad23816d47aca9955.zip |
linux-user: Implement starttime field in self stat emulation
Instead of always returning 0, return actual starttime.
Signed-off-by: Cameron Esfahani <dirty@apple.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20220128001251.45165-1-dirty@apple.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r-- | linux-user/main.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/linux-user/main.c b/linux-user/main.c index 16def5215d..fbc9bcfd5f 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -190,12 +190,26 @@ void stop_all_tasks(void) /* Assumes contents are already zeroed. */ void init_task_state(TaskState *ts) { + long ticks_per_sec; + struct timespec bt; + ts->used = 1; ts->sigaltstack_used = (struct target_sigaltstack) { .ss_sp = 0, .ss_size = 0, .ss_flags = TARGET_SS_DISABLE, }; + + /* Capture task start time relative to system boot */ + + ticks_per_sec = sysconf(_SC_CLK_TCK); + + if ((ticks_per_sec > 0) && !clock_gettime(CLOCK_BOOTTIME, &bt)) { + /* start_boottime is expressed in clock ticks */ + ts->start_boottime = bt.tv_sec * (uint64_t) ticks_per_sec; + ts->start_boottime += bt.tv_nsec * (uint64_t) ticks_per_sec / + NANOSECONDS_PER_SECOND; + } } CPUArchState *cpu_copy(CPUArchState *env) |