diff mbox series

[4/7] Added clock_gettime(2) and clock_getres(2)

Message ID 20230422161934.2311-4-itachis6234@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/7] Create os-time.c and add t2h_freebsd_timeval | expand

Commit Message

Ajeet Singh April 22, 2023, 4:19 p.m. UTC
From: Stacey Son <sson@FreeBSD.org>

+Added clock_gettime(2) which gets the time
+Added clock_getres(2) which finds the resoultion of the specidfied
clock

Signed-off-by: Ajeets6 <itachis6234@gmail.com>
Signed-off-by: Stacey Son <sson@FreeBSD.org>
---
 bsd-user/freebsd/os-time.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
diff mbox series

Patch

diff --git a/bsd-user/freebsd/os-time.h b/bsd-user/freebsd/os-time.h
index 29d2c8d02a..f76744e808 100644
--- a/bsd-user/freebsd/os-time.h
+++ b/bsd-user/freebsd/os-time.h
@@ -63,3 +63,35 @@  static inline abi_long do_freebsd_clock_nanosleep(abi_long arg1, abi_long arg2,
 
     return ret;
 }
+
+/* clock_gettime(2) */
+static inline abi_long do_freebsd_clock_gettime(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    struct timespec ts;
+
+    ret = get_errno(clock_gettime(arg1, &ts));
+    if (!is_error(ret)) {
+        if (h2t_freebsd_timespec(arg2, &ts)) {
+            return -TARGET_EFAULT;
+        }
+    }
+
+    return ret;
+}
+
+/* clock_getres(2) */
+static inline abi_long do_freebsd_clock_getres(abi_long arg1, abi_long arg2)
+{
+    abi_long ret;
+    struct timespec ts;
+
+    ret = get_errno(clock_getres(arg1, &ts));
+    if (!is_error(ret)) {
+        if (h2t_freebsd_timespec(arg2, &ts)) {
+            return -TARGET_EFAULT;
+        }
+    }
+
+    return ret;
+}
\ No newline at end of file