[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Optimized gcc 4.3.0 build on Windows returns 0 secs for all time val
From: |
dhruva |
Subject: |
Re: Optimized gcc 4.3.0 build on Windows returns 0 secs for all time values of system-process-attributes |
Date: |
Thu, 1 Jan 2009 19:13:05 +0530 |
Here is a modified patch that seems to give me different values! Not
sure how to interpret it though :(
[dk]bzr diff
=== modified file 'src/w32.c'
--- src/w32.c 2008-12-20 02:50:35 +0000
+++ src/w32.c 2009-01-01 13:39:13 +0000
@@ -2739,26 +2739,27 @@
}
static FILETIME utc_base_ft;
-static long double utc_base;
+static LONGLONG utc_base;
static int init = 0;
-static long double
+static LONGLONG
convert_time_raw (FILETIME ft)
{
- return
- (long double) ft.dwHighDateTime
- * 4096.0L * 1024.0L * 1024.0L + ft.dwLowDateTime;
+ LARGE_INTEGER tmp_var;
+ tmp_var.LowPart = ft.dwLowDateTime;
+ tmp_var.HighPart = ft.dwHighDateTime;
+
+ return tmp_var.QuadPart;
}
static time_t
convert_time (FILETIME ft)
{
- long double ret;
-
if (!init)
{
/* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */
SYSTEMTIME st;
+ LARGE_INTEGER utc;
st.wYear = 1970;
st.wMonth = 1;
@@ -2769,8 +2770,9 @@
st.wMilliseconds = 0;
SystemTimeToFileTime (&st, &utc_base_ft);
- utc_base = (long double) utc_base_ft.dwHighDateTime
- * 4096.0L * 1024.0L * 1024.0L + utc_base_ft.dwLowDateTime;
+ utc.LowPart = utc_base_ft.dwLowDateTime;
+ utc.HighPart = utc_base_ft.dwHighDateTime;
+ utc_base = utc.QuadPart;
init = 1;
}
@@ -2784,12 +2786,13 @@
void
convert_from_time_t (time_t time, FILETIME * pft)
{
- long double tmp;
+ LARGE_INTEGER tmp;
if (!init)
{
/* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */
SYSTEMTIME st;
+ LARGE_INTEGER utc;
st.wYear = 1970;
st.wMonth = 1;
@@ -2800,15 +2803,16 @@
st.wMilliseconds = 0;
SystemTimeToFileTime (&st, &utc_base_ft);
- utc_base = (long double) utc_base_ft.dwHighDateTime
- * 4096 * 1024 * 1024 + utc_base_ft.dwLowDateTime;
+ utc.LowPart = utc_base_ft.dwLowDateTime;
+ utc.HighPart = utc_base_ft.dwHighDateTime;
+ utc_base = utc.QuadPart;
init = 1;
}
/* time in 100ns units since 1-Jan-1601 */
- tmp = (long double) time * 1e7 + utc_base;
- pft->dwHighDateTime = (DWORD) (tmp / (4096.0 * 1024 * 1024));
- pft->dwLowDateTime = (DWORD) (tmp - (4096.0 * 1024 * 1024) *
pft->dwHighDateTime);
+ tmp.QuadPart = time * 1e7 + utc_base;
+ pft->dwHighDateTime = tmp.HighPart;
+ pft->dwLowDateTime = tmp.LowPart;
}
#if 0
@@ -3777,9 +3781,9 @@
double *pcpu;
{
FILETIME ft_creation, ft_exit, ft_kernel, ft_user, ft_current;
- long ctime_sec, ctime_usec, stime_sec, stime_usec, utime_sec, utime_usec;
- long etime_sec, etime_usec;
- long double tem1, tem2, tem;
+ LONGLONG ctime_sec, ctime_usec, stime_sec, stime_usec, utime_sec, utime_usec;
+ LONGLONG etime_sec, etime_usec;
+ LONGLONG tem1, tem2, tem;
if (!h_proc
|| !get_process_times_fn
On Thu, Jan 1, 2009 at 6:46 PM, Jason Rumney <address@hidden> wrote:
> dhruva wrote:
>>
>> + return tmp_var.QuadPart * 4096.0L * 1024.0L * 1024.0L;
>>
>
> Shouldn't this just be return tmp_var.QuadPart?
>
I guess you are right, I did not understand all the math till you pointed out.
--
Contents reflect my personal views only!
Re: Optimized gcc 4.3.0 build on Windows returns 0 secs for all time values of system-process-attributes, Juanma Barranquero, 2009/01/01