From 9424dad56ac13e7e5b40dcd2a307301b3597cb33 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Sat, 6 Nov 2021 15:58:21 +0800 Subject: [PATCH] Implement os_time_get_boot_microsecond() for sgx platform (#818) --- core/shared/platform/linux-sgx/sgx_time.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/shared/platform/linux-sgx/sgx_time.c b/core/shared/platform/linux-sgx/sgx_time.c index c945bbcc..d090083e 100644 --- a/core/shared/platform/linux-sgx/sgx_time.c +++ b/core/shared/platform/linux-sgx/sgx_time.c @@ -28,8 +28,16 @@ ocall_clock_nanosleep(int *p_ret, unsigned clock_id, int flags, uint64 os_time_get_boot_microsecond() { - /* TODO */ +#ifndef SGX_DISABLE_WASI + struct timespec ts; + if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { + return 0; + } + + return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000; +#else return 0; +#endif } #ifndef SGX_DISABLE_WASI