diff options
author | Simon Glass <sjg@chromium.org> | 2020-07-09 18:43:14 -0600 |
---|---|---|
committer | Bin Meng <bmeng.cn@gmail.com> | 2020-07-17 14:32:24 +0800 |
commit | e1ddf67cb3982b5c49c1165da87917a82a285783 (patch) | |
tree | 1361a00a2d8d7a282be4e6c529539ecd8acabc70 /include/time.h | |
parent | ce04a9020c41a2ebf1d85e01532da69d2d2e2119 (diff) | |
download | u-boot-e1ddf67cb3982b5c49c1165da87917a82a285783.tar.gz |
timer: Allow delays with a 32-bit microsecond timer
The current get_timer_us() uses 64-bit arithmetic on 32-bit machines.
When implementing microsecond-level timeouts, 32-bits is plenty. Add a
new function that uses an unsigned long. On 64-bit machines this is
still 64-bit, but this doesn't introduce a penalty. On 32-bit machines
it is more efficient.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'include/time.h')
-rw-r--r-- | include/time.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/time.h b/include/time.h index e99f9c8012..3f00e68713 100644 --- a/include/time.h +++ b/include/time.h @@ -17,6 +17,17 @@ unsigned long get_timer(unsigned long base); unsigned long timer_get_us(void); uint64_t get_timer_us(uint64_t base); +/** + * get_timer_us_long() - Get the number of elapsed microseconds + * + * This uses 32-bit arithmetic on 32-bit machines, which is enough to handle + * delays of over an hour. For 64-bit machines it uses a 64-bit value. + * + *@base: Base time to consider + *@return elapsed time since @base + */ +unsigned long get_timer_us_long(unsigned long base); + /* * timer_test_add_offset() * |