|
From: openocd-gerrit <ope...@us...> - 2026-07-04 17:51:51
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 1950a58d85cd469332023dc937e9ecb59b0d557c (commit)
from 0240d2e3b77fb9d6ffba78194e6c43d34cad2fe5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 1950a58d85cd469332023dc937e9ecb59b0d557c
Author: Antonio Borneo <bor...@gm...>
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 <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9744
Reviewed-by: Grant Ramsay <gra...@ho...>
Tested-by: jenkins
diff --git a/src/helper/time_support.c b/src/helper/time_support.c
index 46fb17246..cc4c8c367 100644
--- a/src/helper/time_support.c
+++ b/src/helper/time_support.c
@@ -70,31 +70,39 @@ 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));
+ int64_t elapsed_ms = duration->elapsed_ms;
+
+ if (elapsed_ms == 0)
+ elapsed_ms = 1;
+
+ return 1000 * count / (1024 * (float)elapsed_ms);
}
diff --git a/src/helper/time_support.h b/src/helper/time_support.h
index c98429681..7e0a315c2 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. */
-----------------------------------------------------------------------
Summary of changes:
src/helper/time_support.c | 24 ++++++++++++++++--------
src/helper/time_support.h | 4 ++--
2 files changed, 18 insertions(+), 10 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|