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;