[OpenWrt-Devel] [PATCH] odhcp6c: fix compilation with musl 1.2.0

Rosen Penev rosenp at gmail.com
Wed Mar 25 18:37:09 EDT 2020


SYS_clock_gettime is gone with musl 1.2.0. Switch to using the normal
function.

This was done back in the day when uClibc was used when librt was
separate. Since only glibc is impacted now, this should be fine.

Added a link to rt just to be sure.

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 v2: Switched to function.
 CMakeLists.txt | 2 +-
 src/odhcp6c.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a5b0cb3..9cce2b6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,7 @@ endif(${EXT_CER_ID})
 
 set(SOURCES src/odhcp6c.c src/dhcpv6.c src/ra.c src/script.c)
 
-set(LIBRARIES resolv)
+set(LIBRARIES resolv rt)
 
 if(USE_LIBUBOX)
 	add_definitions(-DUSE_LIBUBOX)
diff --git a/src/odhcp6c.c b/src/odhcp6c.c
index 19a86f2..5191759 100644
--- a/src/odhcp6c.c
+++ b/src/odhcp6c.c
@@ -639,8 +639,8 @@ static int usage(void)
 // Don't want to pull-in librt and libpthread just for a monotonic clock...
 uint64_t odhcp6c_get_milli_time(void)
 {
-	struct timespec t = {0, 0};
-	syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &t);
+	struct timespec t;
+	clock_gettime(CLOCK_MONOTONIC, &t);
 
 	return ((uint64_t)t.tv_sec) * 1000 + ((uint64_t)t.tv_nsec) / 1000000;
 }
-- 
2.25.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list