summaryrefslogtreecommitdiffstats
path: root/sys/compat/cloudabi/cloudabi_clock.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/cloudabi/cloudabi_clock.c')
-rw-r--r--sys/compat/cloudabi/cloudabi_clock.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/sys/compat/cloudabi/cloudabi_clock.c b/sys/compat/cloudabi/cloudabi_clock.c
index 8462f23..ed32cf6 100644
--- a/sys/compat/cloudabi/cloudabi_clock.c
+++ b/sys/compat/cloudabi/cloudabi_clock.c
@@ -80,31 +80,27 @@ cloudabi_convert_timespec(const struct timespec *in, cloudabi_timestamp_t *out)
return (0);
}
+/* Fetches the time value of a clock. */
int
-cloudabi_sys_clock_res_get(struct thread *td,
- struct cloudabi_sys_clock_res_get_args *uap)
+cloudabi_clock_time_get(struct thread *td, cloudabi_clockid_t clock_id,
+ cloudabi_timestamp_t *ret)
{
struct timespec ts;
- cloudabi_timestamp_t cts;
int error;
clockid_t clockid;
- error = cloudabi_convert_clockid(uap->clock_id, &clockid);
- if (error != 0)
- return (error);
- error = kern_clock_getres(td, clockid, &ts);
+ error = cloudabi_convert_clockid(clock_id, &clockid);
if (error != 0)
return (error);
- error = cloudabi_convert_timespec(&ts, &cts);
+ error = kern_clock_gettime(td, clockid, &ts);
if (error != 0)
return (error);
- td->td_retval[0] = cts;
- return (0);
+ return (cloudabi_convert_timespec(&ts, ret));
}
int
-cloudabi_sys_clock_time_get(struct thread *td,
- struct cloudabi_sys_clock_time_get_args *uap)
+cloudabi_sys_clock_res_get(struct thread *td,
+ struct cloudabi_sys_clock_res_get_args *uap)
{
struct timespec ts;
cloudabi_timestamp_t cts;
@@ -114,7 +110,7 @@ cloudabi_sys_clock_time_get(struct thread *td,
error = cloudabi_convert_clockid(uap->clock_id, &clockid);
if (error != 0)
return (error);
- error = kern_clock_gettime(td, clockid, &ts);
+ error = kern_clock_getres(td, clockid, &ts);
if (error != 0)
return (error);
error = cloudabi_convert_timespec(&ts, &cts);
@@ -123,3 +119,15 @@ cloudabi_sys_clock_time_get(struct thread *td,
td->td_retval[0] = cts;
return (0);
}
+
+int
+cloudabi_sys_clock_time_get(struct thread *td,
+ struct cloudabi_sys_clock_time_get_args *uap)
+{
+ cloudabi_timestamp_t ts;
+ int error;
+
+ error = cloudabi_clock_time_get(td, uap->clock_id, &ts);
+ td->td_retval[0] = ts;
+ return (error);
+}
OpenPOWER on IntegriCloud