windows sigar_time_now_millis impl

This commit is contained in:
Doug MacEachern 2008-03-16 19:26:29 +00:00
parent 15f7996b8a
commit b37c690749
2 changed files with 11 additions and 3 deletions

View File

@ -1212,6 +1212,15 @@ SIGAR_DECLARE(int) sigar_proc_cred_get(sigar_t *sigar, sigar_pid_t pid,
#define FILETIME2MSEC(ft) \ #define FILETIME2MSEC(ft) \
NS100_2MSEC(((ft.dwHighDateTime << 32) | ft.dwLowDateTime)) NS100_2MSEC(((ft.dwHighDateTime << 32) | ft.dwLowDateTime))
sigar_int64_t sigar_time_now_millis(void)
{
FILETIME time;
GetSystemTimeAsFileTime(&time);
return FILETIME2MSEC(time);
}
SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid, SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_time_t *proctime) sigar_proc_time_t *proctime)
{ {

View File

@ -813,12 +813,11 @@ SIGAR_DECLARE(void) sigar_log_impl_file(sigar_t *sigar, void *data,
fprintf(fp, "[%s] %s\n", log_levels[level], message); fprintf(fp, "[%s] %s\n", log_levels[level], message);
} }
#ifndef WIN32
sigar_int64_t sigar_time_now_millis(void) sigar_int64_t sigar_time_now_millis(void)
{ {
#ifdef WIN32
#else
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
return ((tv.tv_sec * SIGAR_USEC) + tv.tv_usec) / SIGAR_MSEC; return ((tv.tv_sec * SIGAR_USEC) + tv.tv_usec) / SIGAR_MSEC;
#endif
} }
#endif