[PATCH mercury] clock: use i64 as time representation
Export this patch
This allow to get/set time before an epoch, and is already enough for
most use cases.
Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
---
cmd/date/main.ha | 2 + -
cmd/rtc/main.ha | 8 ++++ ----
proto/dev/clock.ipc | 4 ++ --
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/cmd/date/main.ha b/cmd/date/main.ha
index 9f71460..f69645a 100644
--- a/cmd/date/main.ha
+++ b/cmd/date/main.ha
@@ -26,7 +26,7 @@ export fn main() void = {
} else if (2 == len(os::args)) {
const time = match (strconv::stoi64(os::args[1])) {
case let time: i64 =>
- yield time: u64;
+ yield time;
case =>
return;
};
diff --git a/cmd/rtc/main.ha b/cmd/rtc/main.ha
index a7fd6e0..432f460 100644
--- a/cmd/rtc/main.ha
+++ b/cmd/rtc/main.ha
@@ -283,7 +283,7 @@ const rtc_impl = dev::clock_iface {
set_time = &rtc_set_time,
};
- fn rtc_get_time(obj: *dev::clock) u64 = {
+ fn rtc_get_time(obj: *dev::clock) i64 = {
let rtc = obj: *rtc;
const delta_time = time::diff(
@@ -296,13 +296,13 @@ fn rtc_get_time(obj: *dev::clock) u64 = {
time::add(*(&rtc.initial_date: *time::instant), delta_time)
);
- return time::unix(*(&new_date: *time::instant)): u64;
+ return time::unix(*(&new_date: *time::instant));
};
- fn rtc_set_time(obj: *dev::clock, time: u64) void = {
+ fn rtc_set_time(obj: *dev::clock, time: i64) void = {
let rtc = obj: *rtc;
- const instant = time::from_unix(time: i64);
+ const instant = time::from_unix(time);
const dt = date::from_instant(chrono::LOCAL, instant);
write_date(dt);
diff --git a/proto/dev/clock.ipc b/proto/dev/clock.ipc
index a79fe3a..4dccfde 100644
--- a/proto/dev/clock.ipc
+++ b/proto/dev/clock.ipc
@@ -2,8 +2,8 @@ namespace dev;
interface clock {
# Return time in seconds.
- call get_time() u64;
+ call get_time() i64;
# Set time in seconds.
- call set_time(time: u64) void;
+ call set_time(time: i64) void;
};
--
2.41.0
mercury/patches/.build.yml: FAILED in 1m7s
[clock: use i64 as time representation][0] from [Willow Barraco][1]
[0]: https://lists.sr.ht/~sircmpwn/helios-devel/patches/43448
[1]: mailto:contact@willowbarraco.fr
✗ #1037778 FAILED mercury/patches/.build.yml https://builds.sr.ht/~sircmpwn/job/1037778
Thanks!
To git@git.sr.ht:~sircmpwn/mercury
797edf2..a5436f8 master -> master