From 40b5739ff955fed86fd859ed0526bf624d8900ef Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 4 Dec 2013 08:26:13 +0100 Subject: [PATCH] * grub-core/kern/uboot/init.c (uboot_timer_ms): Fix overflow after 71 minutes. --- ChangeLog | 5 +++++ grub-core/kern/uboot/init.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 024faf8a0..5e0da02c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-12-04 Vladimir Serbinenko + + * grub-core/kern/uboot/init.c (uboot_timer_ms): Fix overflow after 71 + minutes. + 2013-12-04 Vladimir Serbinenko * grub-core/disk/ieee1275/ofdisk.c: Remove variable length arrays. diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c index 9d7924c04..775b689e9 100644 --- a/grub-core/kern/uboot/init.c +++ b/grub-core/kern/uboot/init.c @@ -61,7 +61,13 @@ grub_uboot_get_boot_data (void) static grub_uint64_t uboot_timer_ms (void) { - return (grub_uint64_t) grub_uboot_get_timer (timer_start) / 1000; + static grub_uint32_t last = 0, high = 0; + grub_uint32_t cur = grub_uboot_get_timer (timer_start); + if (cur < last) + high++; + last = cur; + return grub_divmod64 ((((grub_uint64_t) high) << 32) | cur, + 1000, 0); } void -- 2.47.2