You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/06/11 12:52:16 UTC

[incubator-nuttx-apps] 05/05: iperf: Make the use of CLOCK_MONOTONIC conditional for now

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit cc37729e29a464bcbe3c24650d36d7c867bad80d
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Jun 10 16:49:23 2021 +0900

    iperf: Make the use of CLOCK_MONOTONIC conditional for now
---
 netutils/iperf/Kconfig | 1 -
 netutils/iperf/iperf.c | 9 +++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/netutils/iperf/Kconfig b/netutils/iperf/Kconfig
index 0954ef7..3cebb9c 100644
--- a/netutils/iperf/Kconfig
+++ b/netutils/iperf/Kconfig
@@ -10,7 +10,6 @@ config NETUTILS_IPERF
 	select NETUTILS_NETLIB
 	select LIBC_FLOATINGPOINT
 	select SYSTEM_ARGTABLE3
-	select CLOCK_MONOTONIC
 	---help---
 		Enable the \"iperf example\"
 
diff --git a/netutils/iperf/iperf.c b/netutils/iperf/iperf.c
index 58efbcf..6ee511a 100644
--- a/netutils/iperf/iperf.c
+++ b/netutils/iperf/iperf.c
@@ -231,9 +231,14 @@ static void iperf_report_task(void *arg)
   struct timespec start;
   uintmax_t now_len;
   int ret;
+#ifdef CONFIG_CLOCK_MONOTONIC
+  const clockid_t clockid = CLOCK_MONOTONIC;
+#else
+  const clockid_t clockid = CLOCK_REALTIME;
+#endif
 
   now_len = s_iperf_ctrl.total_len;
-  ret = clock_gettime(CLOCK_MONOTONIC, &now);
+  ret = clock_gettime(clockid, &now);
   if (ret != 0)
     {
       fprintf(stderr, "clock_gettime failed\n");
@@ -251,7 +256,7 @@ static void iperf_report_task(void *arg)
       last_len = now_len;
       last = now;
       now_len = s_iperf_ctrl.total_len;
-      ret = clock_gettime(CLOCK_MONOTONIC, &now);
+      ret = clock_gettime(clockid, &now);
       if (ret != 0)
         {
           fprintf(stderr, "clock_gettime failed\n");