From 5cc39a6a9d3f742aaee18e9439431474f0b6ea7a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Thu, 20 Apr 2023 17:11:32 +0800 Subject: [PATCH] Change clock source to boottime on linux. CLOCK_MONOTONIC does not account for time when suspend. And CLOCK_BOOTTIME does it. Signed-off-by: Jerry Yu --- library/platform_util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/platform_util.c b/library/platform_util.c index e903f8ed32..c67b80dea7 100644 --- a/library/platform_util.c +++ b/library/platform_util.c @@ -235,7 +235,11 @@ mbedtls_ms_time_t mbedtls_ms_time(void) struct timespec tv; mbedtls_ms_time_t current_ms; +#if defined(__linux__) + ret = clock_gettime(CLOCK_BOOTTIME, &tv); +#else ret = clock_gettime(CLOCK_MONOTONIC, &tv); +#endif if (ret) { return time(NULL) * 1000; }