Skip to content

Commit

Permalink
Fixed removal of z_impl_clock_gettime in zephyr 3.5.99 (#378)
Browse files Browse the repository at this point in the history
* Fixed removal of z_impl_clock_gettime in zephyr 3.5.99

Signed-off-by: Daniel Huiskes <[email protected]>

* crustify z_impl_clock_gettime fix

* single return  z_impl_clock_gettime fix

---------

Signed-off-by: Daniel Huiskes <[email protected]>
Co-authored-by: Daniel Huiskes <[email protected]>
  • Loading branch information
danielallstar and Daniel Huiskes committed Jan 19, 2024
1 parent 371718c commit 83f129a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/c/util/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

//==================================================================
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 83f129a

Please sign in to comment.