1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/pkg/ccn-lite/patches/0002-src-ccnl-migrate-from-xtimer-to-ztimer64.patch
2021-12-10 17:04:57 +01:00

84 lines
2.6 KiB
Diff

From 3fe4a5842357bd14651d4cc0860da00c0649c182 Mon Sep 17 00:00:00 2001
From: Francisco Molina <femolina@uc.cl>
Date: Thu, 9 Dec 2021 15:25:22 +0100
Subject: [PATCH 1/2] src/ccnl%: migrate from xtimer to ztimer64
---
src/ccnl-core/src/ccnl-os-time.c | 8 +++++---
src/ccnl-riot/src/ccn-lite-riot.c | 8 ++++----
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/ccnl-core/src/ccnl-os-time.c b/src/ccnl-core/src/ccnl-os-time.c
index 21b4afb6..0087b9dc 100644
--- a/src/ccnl-core/src/ccnl-os-time.c
+++ b/src/ccnl-core/src/ccnl-os-time.c
@@ -38,12 +38,14 @@ struct ccnl_timer_s *eventqueue;
#if defined(CCNL_RIOT) && !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__linux__))
-#include <xtimer.h>
+#include <ztimer64.h>
+#include <timex.h>
+#include <div.h>
int gettimeofday(struct timeval *__restrict __p, void *__restrict __tz)
{
(void) __tz;
- uint64_t now = xtimer_now_usec64();
+ uint64_t now = ztimer64_now(ZTIMER64_USEC);
__p->tv_sec = div_u64_by_1000000(now);
__p->tv_usec = now - (__p->tv_sec * US_PER_SEC);
@@ -108,7 +110,7 @@ timestamp(void)
cp[5] = '\0';
else while (strlen(cp) < 5)
strcat(cp, "0");
-
+
return ts;
}
diff --git a/src/ccnl-riot/src/ccn-lite-riot.c b/src/ccnl-riot/src/ccn-lite-riot.c
index 33ca23cf..678e8301 100644
--- a/src/ccnl-riot/src/ccn-lite-riot.c
+++ b/src/ccnl-riot/src/ccn-lite-riot.c
@@ -32,7 +32,7 @@
#include "sched.h"
#include "random.h"
#include "timex.h"
-#include "xtimer.h"
+#include "ztimer64.h"
#include "net/gnrc/netreg.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/netif/hdr.h"
@@ -464,7 +464,7 @@ ccnl_start(void)
return ccnl_event_loop_pid;
}
-static xtimer_t _wait_timer;
+static ztimer64_t _wait_timer;
static msg_t _timeout_msg;
int
ccnl_wait_for_chunk(void *buf, size_t buf_len, uint64_t timeout)
@@ -480,7 +480,7 @@ ccnl_wait_for_chunk(void *buf, size_t buf_len, uint64_t timeout)
/* TODO: receive from socket or interface */
_timeout_msg.type = CCNL_MSG_TIMEOUT;
- xtimer_set_msg64(&_wait_timer, timeout, &_timeout_msg, thread_getpid());
+ ztimer64_set_msg(ZTIMER64_USEC, &_wait_timer, timeout, &_timeout_msg, thread_getpid());
msg_t m;
msg_receive(&m);
if (m.type == GNRC_NETAPI_MSG_TYPE_RCV) {
@@ -500,7 +500,7 @@ ccnl_wait_for_chunk(void *buf, size_t buf_len, uint64_t timeout)
gnrc_pktbuf_release(pkt);
continue;
}
- xtimer_remove(&_wait_timer);
+ ztimer64_remove(ZTIMER64_USEC, &_wait_timer);
break;
}
else if (m.type == CCNL_MSG_TIMEOUT) {
--
2.30.2