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
|
@ -1,3 +1,8 @@
|
|||
2013-10-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Move cpu time retrieval to separate grub_util_get_cpu_time_ms
|
||||
and remove export.h.
|
||||
|
||||
2013-10-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/emu/error.c: Removed.
|
||||
|
|
|
@ -217,7 +217,6 @@ endif
|
|||
if COND_emu
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/datetime.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/misc.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/export.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/net.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostdisk.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
|
||||
|
|
|
@ -258,6 +258,9 @@ kernel = {
|
|||
emu = osdep/emunet.c;
|
||||
extra_dist = osdep/linux/emunet.c;
|
||||
extra_dist = osdep/basic/emunet.c;
|
||||
emu = osdep/cputime.c;
|
||||
extra_dist = osdep/unix/cputime.c;
|
||||
extra_dist = osdep/windows/cputime.c;
|
||||
|
||||
videoinkernel = term/gfxterm.c;
|
||||
videoinkernel = font/font.c;
|
||||
|
|
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;
|
||||
}
|
||||
|
|
@ -485,11 +485,6 @@ grub_util_fd_t genfd = GRUB_UTIL_FD_INVALID;
|
|||
|
||||
#include <grub/time.h>
|
||||
|
||||
#if defined (GRUB_MACHINE_EMU) && defined (COLLECT_TIME_STATISTICS)
|
||||
#include <sys/times.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
write_time (void)
|
||||
{
|
||||
|
@ -498,13 +493,11 @@ write_time (void)
|
|||
static grub_uint64_t prev;
|
||||
grub_uint64_t cur;
|
||||
static grub_util_fd_t tmrfd = GRUB_UTIL_FD_INVALID;
|
||||
struct tms tm;
|
||||
if (!GRUB_UTIL_FD_IS_VALID (tmrfd))
|
||||
tmrfd = grub_util_fd_open ("time.txt", GRUB_UTIL_FD_O_WRONLY
|
||||
| GRUB_UTIL_FD_O_CREATTRUNC);
|
||||
|
||||
times (&tm);
|
||||
cur = (tm.tms_utime * 1000ULL) / sysconf(_SC_CLK_TCK);
|
||||
cur = grub_util_get_cpu_time_ms ();
|
||||
grub_snprintf (buf, sizeof (buf), "%s_%dx%dx%s:%d: %" PRIuGRUB_UINT64_T " ms\n",
|
||||
basename,
|
||||
capt_mode_info.width,
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
#ifdef GRUB_SYMBOL_GENERATOR
|
||||
void EXPORT_FUNC (sysconf) (void);
|
||||
void EXPORT_FUNC (times) (void);
|
||||
#else
|
||||
#include <sys/times.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
|
@ -50,6 +50,8 @@ void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (
|
|||
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2), noreturn));
|
||||
|
||||
grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void);
|
||||
|
||||
extern char * canonicalize_file_name (const char *path);
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
|
|
Loading…
Reference in a new issue