From 83f129a80770a09aac9e823896ecbf6a0eddf0fc Mon Sep 17 00:00:00 2001 From: danielallstar <60315977+danielallstar@users.noreply.github.com> Date: Fri, 19 Jan 2024 09:19:56 +0100 Subject: [PATCH] Fixed removal of z_impl_clock_gettime in zephyr 3.5.99 (#378) * Fixed removal of z_impl_clock_gettime in zephyr 3.5.99 Signed-off-by: Daniel Huiskes * crustify z_impl_clock_gettime fix * single return z_impl_clock_gettime fix --------- Signed-off-by: Daniel Huiskes Co-authored-by: Daniel Huiskes --- src/c/util/time.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/c/util/time.c b/src/c/util/time.c index 66c496dc..c4d9de68 100644 --- a/src/c/util/time.c +++ b/src/c/util/time.c @@ -7,6 +7,8 @@ #elif defined(UCLIENT_PLATFORM_FREERTOS_PLUS_TCP) #include "FreeRTOS.h" #include "task.h" +#elif defined(UCLIENT_PLATFORM_ZEPHYR) +#include #endif /* ifdef WIN32 */ //================================================================== @@ -53,7 +55,16 @@ int64_t uxr_nanos( return (( total_tick / (int64_t) portTICK_PERIOD_MS ) * 1000000 ); #elif defined(UCLIENT_PLATFORM_ZEPHYR) struct timespec ts; + + // From Zephyr version 3.5.99 the z_impl_clock_gettime function + // has been renamed to the clock_gettime function. + // This has been done to implement Zephyr's POSIX API as regular library functions + // https://github.com/zephyrproject-rtos/zephyr/commit/95a22b12174621aeba8ca3e0e61f7c66f03202bf + #if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3, 5, 99) + clock_gettime(CLOCK_REALTIME, &ts); + #else z_impl_clock_gettime(CLOCK_REALTIME, &ts); + #endif /* if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3, 5, 99) */ return (((int64_t)ts.tv_sec) * 1000000000) + ts.tv_nsec; #else struct timespec ts;