Move cpu time retrieval to separate grub_util_get_cpu_time_ms
and remove export.h.
This commit is contained in:
parent
23934da26e
commit
7e45abcef4
9 changed files with 50 additions and 16 deletions
5
grub-core/osdep/cputime.c
Normal file
5
grub-core/osdep/cputime.c
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifdef __MINGW32__
|
||||
#include "windows/cputime.c"
|
||||
#else
|
||||
#include "unix/cputime.c"
|
||||
#endif
|
15
grub-core/osdep/unix/cputime.c
Normal file
15
grub-core/osdep/unix/cputime.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
#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;
|
||||
|
||||
times (&tm);
|
||||
return (tm.tms_utime * 1000ULL) / sysconf(_SC_CLK_TCK);
|
||||
}
|
19
grub-core/osdep/windows/cputime.c
Normal file
19
grub-core/osdep/windows/cputime.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <config.h>
|
||||
#include <config-util.h>
|
||||
|
||||
#include <grub/emu/misc.h>
|
||||
#include <windows.h>
|
||||
|
||||
grub_uint64_t
|
||||
grub_util_get_cpu_time_ms (void)
|
||||
{
|
||||
FILETIME cr, ex, ke, us;
|
||||
ULARGE_INTEGER us_ul;
|
||||
|
||||
GetProcessTimes (GetCurrentProcess (), &cr, &ex, &ke, &us);
|
||||
us_ul.LowPart = us.dwLowDateTime;
|
||||
us_ul.HighPart = us.dwHighDateTime;
|
||||
|
||||
return us_ul.QuadPart / 10000;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue