Alexey Yerin: 1 os::exec: fill utime and stime 4 files changed, 31 insertions(+), 11 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~sircmpwn/hare-dev/patches/41682/mbox | git am -3Learn more about email & git
Signed-off-by: Alexey Yerin <yyp@disroot.org> --- os/exec/process+freebsd.ha | 14 ++++++++++++-- os/exec/process+linux.ha | 14 ++++++++++++-- scripts/gen-stdlib | 6 +++--- stdlib.mk | 8 ++++---- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/os/exec/process+freebsd.ha b/os/exec/process+freebsd.ha index a5220f2f..930f3b10 100644 --- 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 index 37a70365..1d19f6e8 100644 --- 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 index d5224474..cbb0cad4 100755 --- a/scripts/gen-stdlib +++ b/scripts/gen-stdlib @@ -237,7 +237,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 } @@ -1194,7 +1194,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 \ @@ -1202,7 +1202,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 index 163a5a9e..6ea9c030 100644 --- 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 \ @@ -4371,7 +4371,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 \ @@ -4384,7 +4384,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 \ -- 2.41.0
builds.sr.ht <builds@sr.ht>hare/patches: SUCCESS in 7m49s [os::exec: fill utime and stime][0] from [Alexey Yerin][1] [0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/41682 [1]: mailto:yyp@disroot.org ✓ #1002604 SUCCESS hare/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/1002604 ✓ #1002603 SUCCESS hare/patches/alpine.yml https://builds.sr.ht/~sircmpwn/job/1002603
Thanks! To gitsrht:~sircmpwn/hare d8bd0b28..da9256b2 master -> master