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 <d.v.huiskes@student.utwente.nl>

* crustify z_impl_clock_gettime fix

* single return  z_impl_clock_gettime fix

---------

Signed-off-by: Daniel Huiskes <d.v.huiskes@student.utwente.nl>
Co-authored-by: Daniel Huiskes <d.v.huiskes@student.utwente.nl>
This commit is contained in:
danielallstar 2024-01-19 09:19:56 +01:00 committed by GitHub
parent 371718ca16
commit 83f129a807
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -7,6 +7,8 @@
#elif defined(UCLIENT_PLATFORM_FREERTOS_PLUS_TCP)
#include "FreeRTOS.h"
#include "task.h"
#elif defined(UCLIENT_PLATFORM_ZEPHYR)
#include <version.h>
#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;