Commit 68581b00 authored by Vladimir Serbinenko's avatar Vladimir Serbinenko
Browse files

unix/cputime.c: Cache sc_clk_tck and check it for sanity.

parent 69aee43f
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/unix/cputime.c (grub_util_get_cpu_time_ms): Cache
sc_clk_tck and check it for sanity.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
 
* grub-core/kern/efi/mm.c (grub_efi_get_memory_map): Never return a
......@@ -9,7 +9,14 @@ grub_uint64_t
grub_util_get_cpu_time_ms (void)
{
struct tms tm;
static long sc_clk_tck;
if (!sc_clk_tck)
{
sc_clk_tck = sysconf(_SC_CLK_TCK);
if (sc_clk_tck <= 0)
sc_clk_tck = 1000;
}
times (&tm);
return (tm.tms_utime * 1000ULL) / sysconf(_SC_CLK_TCK);
return (tm.tms_utime * 1000ULL) / sc_clk_tck;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment