summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorRob Barnes <robbarnes@google.com>2022-09-12 06:31:47 -0600
committerFelix Held <felix-coreboot@felixheld.de>2022-09-14 11:55:39 +0000
commitd522f38c7bfccdc4af71bcad133aec20096f3f6c (patch)
tree28824b7b1bb659fffc6d1b8cb793f98f93f53c89 /src/include
parent51249d6bed93f25569a35fa184038cafddc0dec0 (diff)
timer: Change timer util functions to 64-bit
Since mono_time is now 64-bit, the utility functions interfacing with mono_time should also be 64-bit so precision isn't lost. Fixed build errors related to printing the now int64_t result of stopwatch_duration_[m|u]secs in various places. BUG=b:237082996 BRANCH=All TEST=Boot dewatt Change-Id: I169588f5e14285557f2d03270f58f4c07c0154d5 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/66170 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-by: Raul Rangel <rrangel@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/timer.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/include/timer.h b/src/include/timer.h
index 0e7104b70e..0f49ec67c9 100644
--- a/src/include/timer.h
+++ b/src/include/timer.h
@@ -47,28 +47,28 @@ int timers_run(void);
/* Schedule a callback to be ran microseconds from time of invocation.
* 0 returned on success, < 0 on error. */
-int timer_sched_callback(struct timeout_callback *tocb, unsigned long us);
+int timer_sched_callback(struct timeout_callback *tocb, uint64_t us);
/* Set an absolute time to a number of microseconds. */
-static inline void mono_time_set_usecs(struct mono_time *mt, long us)
+static inline void mono_time_set_usecs(struct mono_time *mt, uint64_t us)
{
mt->microseconds = us;
}
/* Set an absolute time to a number of milliseconds. */
-static inline void mono_time_set_msecs(struct mono_time *mt, long ms)
+static inline void mono_time_set_msecs(struct mono_time *mt, uint64_t ms)
{
mt->microseconds = ms * USECS_PER_MSEC;
}
/* Add microseconds to an absolute time. */
-static inline void mono_time_add_usecs(struct mono_time *mt, long us)
+static inline void mono_time_add_usecs(struct mono_time *mt, int64_t us)
{
mt->microseconds += us;
}
/* Add milliseconds to an absolute time. */
-static inline void mono_time_add_msecs(struct mono_time *mt, long ms)
+static inline void mono_time_add_msecs(struct mono_time *mt, int64_t ms)
{
mono_time_add_usecs(mt, ms * USECS_PER_MSEC);
}
@@ -102,8 +102,8 @@ static inline int mono_time_before(const struct mono_time *t1,
}
/* Return time difference between t1 and t2. i.e. t2 - t1. */
-static inline long mono_time_diff_microseconds(const struct mono_time *t1,
- const struct mono_time *t2)
+static inline int64_t mono_time_diff_microseconds(const struct mono_time *t1,
+ const struct mono_time *t2)
{
return t2->microseconds - t1->microseconds;
}
@@ -124,13 +124,13 @@ static inline void stopwatch_init(struct stopwatch *sw)
sw->current = sw->expires = sw->start;
}
-static inline void stopwatch_init_usecs_expire(struct stopwatch *sw, long us)
+static inline void stopwatch_init_usecs_expire(struct stopwatch *sw, uint64_t us)
{
stopwatch_init(sw);
mono_time_add_usecs(&sw->expires, us);
}
-static inline void stopwatch_init_msecs_expire(struct stopwatch *sw, long ms)
+static inline void stopwatch_init_msecs_expire(struct stopwatch *sw, uint64_t ms)
{
stopwatch_init_usecs_expire(sw, USECS_PER_MSEC * ms);
}
@@ -167,7 +167,7 @@ static inline void stopwatch_wait_until_expired(struct stopwatch *sw)
/*
* Return number of microseconds since starting the stopwatch.
*/
-static inline long stopwatch_duration_usecs(struct stopwatch *sw)
+static inline int64_t stopwatch_duration_usecs(struct stopwatch *sw)
{
/*
* If the stopwatch hasn't been ticked (current == start) tick
@@ -179,7 +179,7 @@ static inline long stopwatch_duration_usecs(struct stopwatch *sw)
return mono_time_diff_microseconds(&sw->start, &sw->current);
}
-static inline long stopwatch_duration_msecs(struct stopwatch *sw)
+static inline int64_t stopwatch_duration_msecs(struct stopwatch *sw)
{
return stopwatch_duration_usecs(sw) / USECS_PER_MSEC;
}
@@ -197,7 +197,7 @@ static inline long stopwatch_duration_msecs(struct stopwatch *sw)
*/
#define wait_us(timeout_us, condition) \
({ \
- long __ret = 0; \
+ int64_t __ret = 0; \
struct stopwatch __sw; \
stopwatch_init_usecs_expire(&__sw, timeout_us); \
do { \