This is an automated email from Gerrit.

"Antonio Borneo <[email protected]>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9744

-- gerrit

commit a8142df2fcc63bfdddc17d3a9a3274a91d73a23e
Author: Antonio Borneo <[email protected]>
Date:   Mon Jun 15 23:23:03 2026 +0200

    helper: time_support: convert duration helpers to timeval_ms()
    
    Drop the use of gettimeofday() in the duration_*() helpers and use
    OpenOCD timeval_ms().
    
    Change-Id: I9a8dd77e0b03e636a3653a75561997b97c9a27ed
    Signed-off-by: Antonio Borneo <[email protected]>

diff --git a/src/helper/time_support.c b/src/helper/time_support.c
index 46fb172468..dd2cf3ccd6 100644
--- a/src/helper/time_support.c
+++ b/src/helper/time_support.c
@@ -70,31 +70,34 @@ int timeval_compare(const struct timeval *x, const struct 
timeval *y)
 
 int duration_start(struct duration *duration)
 {
-       if (gettimeofday(&duration->start, NULL) != 0)
+       int64_t now = timeval_ms();
+
+       if (now < 0)
                return ERROR_FAIL;
 
+       duration->start_ms = now;
+
        return ERROR_OK;
 }
 
 int duration_measure(struct duration *duration)
 {
-       struct timeval end;
-       if (gettimeofday(&end, NULL) != 0)
+       int64_t now = timeval_ms();
+
+       if (now < 0)
                return ERROR_FAIL;
 
-       timeval_subtract(&duration->elapsed, &end, &duration->start);
+       duration->elapsed_ms = now - duration->start_ms;
 
        return ERROR_OK;
 }
 
 float duration_elapsed(const struct duration *duration)
 {
-       float t = duration->elapsed.tv_sec;
-       t += (float)duration->elapsed.tv_usec / 1000000.0;
-       return t;
+       return ((float)duration->elapsed_ms) / 1000;
 }
 
 float duration_kbps(const struct duration *duration, size_t count)
 {
-       return count / (1024.0 * duration_elapsed(duration));
+       return count / (1024 * duration_elapsed(duration));
 }
diff --git a/src/helper/time_support.h b/src/helper/time_support.h
index c984296819..7e0a315c20 100644
--- a/src/helper/time_support.h
+++ b/src/helper/time_support.h
@@ -29,8 +29,8 @@ int timeval_compare(const struct timeval *x, const struct 
timeval *y);
 int64_t timeval_ms(void);
 
 struct duration {
-       struct timeval start;
-       struct timeval elapsed;
+       int64_t start_ms;
+       int64_t elapsed_ms;
 };
 
 /** Update the duration->start field to start the @a duration measurement. */

-- 

Reply via email to