summaryrefslogtreecommitdiffstats
path: root/grub-core/osdep/unix/cputime.c
diff options
context:
space:
mode:
Diffstat (limited to 'grub-core/osdep/unix/cputime.c')
-rw-r--r--grub-core/osdep/unix/cputime.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/grub-core/osdep/unix/cputime.c b/grub-core/osdep/unix/cputime.c
new file mode 100644
index 0000000..cff359a
--- /dev/null
+++ b/grub-core/osdep/unix/cputime.c
@@ -0,0 +1,22 @@
+#include <config.h>
+#include <config-util.h>
+
+#include <sys/times.h>
+#include <unistd.h>
+#include <grub/emu/misc.h>
+
+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) / sc_clk_tck;
+}