Skip to content

Commit 83f129a

Browse files
danielallstarDaniel Huiskes
andauthored
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>
1 parent 371718c commit 83f129a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/c/util/time.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#elif defined(UCLIENT_PLATFORM_FREERTOS_PLUS_TCP)
88
#include "FreeRTOS.h"
99
#include "task.h"
10+
#elif defined(UCLIENT_PLATFORM_ZEPHYR)
11+
#include <version.h>
1012
#endif /* ifdef WIN32 */
1113

1214
//==================================================================
@@ -53,7 +55,16 @@ int64_t uxr_nanos(
5355
return (( total_tick / (int64_t) portTICK_PERIOD_MS ) * 1000000 );
5456
#elif defined(UCLIENT_PLATFORM_ZEPHYR)
5557
struct timespec ts;
58+
59+
// From Zephyr version 3.5.99 the z_impl_clock_gettime function
60+
// has been renamed to the clock_gettime function.
61+
// This has been done to implement Zephyr's POSIX API as regular library functions
62+
// https://github.com/zephyrproject-rtos/zephyr/commit/95a22b12174621aeba8ca3e0e61f7c66f03202bf
63+
#if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3, 5, 99)
64+
clock_gettime(CLOCK_REALTIME, &ts);
65+
#else
5666
z_impl_clock_gettime(CLOCK_REALTIME, &ts);
67+
#endif /* if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3, 5, 99) */
5768
return (((int64_t)ts.tv_sec) * 1000000000) + ts.tv_nsec;
5869
#else
5970
struct timespec ts;

0 commit comments

Comments
 (0)