commit 3d5400e7f259434020f8726557145587f59ff7e7
parent 100734fe5ca7b554fa3efe4e4b262eba7fde5ac6
Author: Alexey Yerin <yyp@disroot.org>
Date: Tue, 6 Jun 2023 17:33:16 +0300
os::exec: fill utime and stime
Signed-off-by: Alexey Yerin <yyp@disroot.org>
Diffstat:
4 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/os/exec/process+freebsd.ha b/os/exec/process+freebsd.ha
@@ -3,8 +3,9 @@
// (c) 2021-2022 Drew DeVault <sir@cmpwn.com>
// (c) 2021 Ember Sawady <ecs@d2evs.net>
use errors;
-use rt;
use fmt;
+use rt;
+use time;
use unix::signal;
// Stores information about a child process.
@@ -21,7 +22,8 @@ export type status = struct {
// Not all of these members are supported on all operating systems.
// Only utime and stime are guaranteed to be available.
rusage: struct {
- // TODO: utime, stime
+ utime: time::instant,
+ stime: time::instant,
maxrss: i64,
ixrss: i64,
idrss: i64,
@@ -40,6 +42,14 @@ export type status = struct {
};
fn rusage(st: *status, ru: *rt::rusage) void = {
+ st.rusage.utime = time::instant {
+ sec = ru.ru_utime.tv_sec,
+ nsec = ru.ru_utime.tv_usec * time::MICROSECOND: i64,
+ };
+ st.rusage.stime = time::instant {
+ sec = ru.ru_stime.tv_sec,
+ nsec = ru.ru_stime.tv_usec * time::MICROSECOND: i64,
+ };
st.rusage.maxrss = ru.ru_maxrss;
st.rusage.ixrss = ru.ru_ixrss;
st.rusage.idrss = ru.ru_idrss;
diff --git a/os/exec/process+linux.ha b/os/exec/process+linux.ha
@@ -3,8 +3,9 @@
// (c) 2021-2022 Drew DeVault <sir@cmpwn.com>
// (c) 2021 Ember Sawady <ecs@d2evs.net>
use errors;
-use rt;
use fmt;
+use rt;
+use time;
use unix::signal;
// Stores information about a child process.
@@ -21,7 +22,8 @@ export type status = struct {
// Not all of these members are supported on all operating systems.
// Only utime and stime are guaranteed to be available.
rusage: struct {
- // TODO: utime, stime
+ utime: time::instant,
+ stime: time::instant,
maxrss: u64,
minflt: u64,
majflt: u64,
@@ -33,6 +35,14 @@ export type status = struct {
};
fn rusage(st: *status, ru: *rt::rusage) void = {
+ st.rusage.utime = time::instant {
+ sec = ru.ru_utime.tv_sec,
+ nsec = ru.ru_utime.tv_usec * time::MICROSECOND: i64,
+ };
+ st.rusage.stime = time::instant {
+ sec = ru.ru_stime.tv_sec,
+ nsec = ru.ru_stime.tv_usec * time::MICROSECOND: i64,
+ };
st.rusage.maxrss = ru.ru_maxrss;
st.rusage.minflt = ru.ru_minflt;
st.rusage.majflt = ru.ru_majflt;
diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib
@@ -236,7 +236,7 @@ crypto_aes() {
rt+test.ha \
+test/gcm.ha
gen_ssa crypto::aes bufio bytes crypto::cipher crypto::math \
- endian errors io rt
+ endian errors io rt
fi
}
@@ -1193,7 +1193,7 @@ os_exec() {
types.ha \
cmd.ha
gen_ssa -plinux os::exec os strings fmt errors unix rt io ascii \
- unix::signal types::c
+ unix::signal types::c time
gen_srcs -pfreebsd os::exec \
exec+freebsd.ha \
@@ -1201,7 +1201,7 @@ os_exec() {
types.ha \
cmd.ha
gen_ssa -pfreebsd os::exec os strings fmt errors unix rt io ascii \
- unix::signal types::c
+ unix::signal types::c time
}
path() {
diff --git a/stdlib.mk b/stdlib.mk
@@ -1918,7 +1918,7 @@ stdlib_os_exec_linux_srcs = \
$(STDLIB)/os/exec/types.ha \
$(STDLIB)/os/exec/cmd.ha
-$(HARECACHE)/os/exec/os_exec-linux.ssa: $(stdlib_os_exec_linux_srcs) $(stdlib_rt) $(stdlib_os_$(PLATFORM)) $(stdlib_strings_$(PLATFORM)) $(stdlib_fmt_$(PLATFORM)) $(stdlib_errors_$(PLATFORM)) $(stdlib_unix_$(PLATFORM)) $(stdlib_rt_$(PLATFORM)) $(stdlib_io_$(PLATFORM)) $(stdlib_ascii_$(PLATFORM)) $(stdlib_unix_signal_$(PLATFORM)) $(stdlib_types_c_$(PLATFORM))
+$(HARECACHE)/os/exec/os_exec-linux.ssa: $(stdlib_os_exec_linux_srcs) $(stdlib_rt) $(stdlib_os_$(PLATFORM)) $(stdlib_strings_$(PLATFORM)) $(stdlib_fmt_$(PLATFORM)) $(stdlib_errors_$(PLATFORM)) $(stdlib_unix_$(PLATFORM)) $(stdlib_rt_$(PLATFORM)) $(stdlib_io_$(PLATFORM)) $(stdlib_ascii_$(PLATFORM)) $(stdlib_unix_signal_$(PLATFORM)) $(stdlib_types_c_$(PLATFORM)) $(stdlib_time_$(PLATFORM))
@printf 'HAREC \t$@\n'
@mkdir -p $(HARECACHE)/os/exec
@$(stdlib_env) $(HAREC) $(HAREFLAGS) -o $@ -Nos::exec \
@@ -1931,7 +1931,7 @@ stdlib_os_exec_freebsd_srcs = \
$(STDLIB)/os/exec/types.ha \
$(STDLIB)/os/exec/cmd.ha
-$(HARECACHE)/os/exec/os_exec-freebsd.ssa: $(stdlib_os_exec_freebsd_srcs) $(stdlib_rt) $(stdlib_os_$(PLATFORM)) $(stdlib_strings_$(PLATFORM)) $(stdlib_fmt_$(PLATFORM)) $(stdlib_errors_$(PLATFORM)) $(stdlib_unix_$(PLATFORM)) $(stdlib_rt_$(PLATFORM)) $(stdlib_io_$(PLATFORM)) $(stdlib_ascii_$(PLATFORM)) $(stdlib_unix_signal_$(PLATFORM)) $(stdlib_types_c_$(PLATFORM))
+$(HARECACHE)/os/exec/os_exec-freebsd.ssa: $(stdlib_os_exec_freebsd_srcs) $(stdlib_rt) $(stdlib_os_$(PLATFORM)) $(stdlib_strings_$(PLATFORM)) $(stdlib_fmt_$(PLATFORM)) $(stdlib_errors_$(PLATFORM)) $(stdlib_unix_$(PLATFORM)) $(stdlib_rt_$(PLATFORM)) $(stdlib_io_$(PLATFORM)) $(stdlib_ascii_$(PLATFORM)) $(stdlib_unix_signal_$(PLATFORM)) $(stdlib_types_c_$(PLATFORM)) $(stdlib_time_$(PLATFORM))
@printf 'HAREC \t$@\n'
@mkdir -p $(HARECACHE)/os/exec
@$(stdlib_env) $(HAREC) $(HAREFLAGS) -o $@ -Nos::exec \
@@ -4369,7 +4369,7 @@ testlib_os_exec_linux_srcs = \
$(STDLIB)/os/exec/types.ha \
$(STDLIB)/os/exec/cmd.ha
-$(TESTCACHE)/os/exec/os_exec-linux.ssa: $(testlib_os_exec_linux_srcs) $(testlib_rt) $(testlib_os_$(PLATFORM)) $(testlib_strings_$(PLATFORM)) $(testlib_fmt_$(PLATFORM)) $(testlib_errors_$(PLATFORM)) $(testlib_unix_$(PLATFORM)) $(testlib_rt_$(PLATFORM)) $(testlib_io_$(PLATFORM)) $(testlib_ascii_$(PLATFORM)) $(testlib_unix_signal_$(PLATFORM)) $(testlib_types_c_$(PLATFORM))
+$(TESTCACHE)/os/exec/os_exec-linux.ssa: $(testlib_os_exec_linux_srcs) $(testlib_rt) $(testlib_os_$(PLATFORM)) $(testlib_strings_$(PLATFORM)) $(testlib_fmt_$(PLATFORM)) $(testlib_errors_$(PLATFORM)) $(testlib_unix_$(PLATFORM)) $(testlib_rt_$(PLATFORM)) $(testlib_io_$(PLATFORM)) $(testlib_ascii_$(PLATFORM)) $(testlib_unix_signal_$(PLATFORM)) $(testlib_types_c_$(PLATFORM)) $(testlib_time_$(PLATFORM))
@printf 'HAREC \t$@\n'
@mkdir -p $(TESTCACHE)/os/exec
@$(testlib_env) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nos::exec \
@@ -4382,7 +4382,7 @@ testlib_os_exec_freebsd_srcs = \
$(STDLIB)/os/exec/types.ha \
$(STDLIB)/os/exec/cmd.ha
-$(TESTCACHE)/os/exec/os_exec-freebsd.ssa: $(testlib_os_exec_freebsd_srcs) $(testlib_rt) $(testlib_os_$(PLATFORM)) $(testlib_strings_$(PLATFORM)) $(testlib_fmt_$(PLATFORM)) $(testlib_errors_$(PLATFORM)) $(testlib_unix_$(PLATFORM)) $(testlib_rt_$(PLATFORM)) $(testlib_io_$(PLATFORM)) $(testlib_ascii_$(PLATFORM)) $(testlib_unix_signal_$(PLATFORM)) $(testlib_types_c_$(PLATFORM))
+$(TESTCACHE)/os/exec/os_exec-freebsd.ssa: $(testlib_os_exec_freebsd_srcs) $(testlib_rt) $(testlib_os_$(PLATFORM)) $(testlib_strings_$(PLATFORM)) $(testlib_fmt_$(PLATFORM)) $(testlib_errors_$(PLATFORM)) $(testlib_unix_$(PLATFORM)) $(testlib_rt_$(PLATFORM)) $(testlib_io_$(PLATFORM)) $(testlib_ascii_$(PLATFORM)) $(testlib_unix_signal_$(PLATFORM)) $(testlib_types_c_$(PLATFORM)) $(testlib_time_$(PLATFORM))
@printf 'HAREC \t$@\n'
@mkdir -p $(TESTCACHE)/os/exec
@$(testlib_env) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nos::exec \