From: dhruva <dhruvakm@gmail.com>
To: "Jason Rumney" <jasonr@gnu.org>
Cc: Juanma Barranquero <lekktu@gmail.com>,
Eli Zaretskii <eliz@gnu.org>,
emacs-devel@gnu.org
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 [thread overview]
Message-ID: <e3f230850901010543g4ded27f8g333dfc163ddd2d1a@mail.gmail.com> (raw)
In-Reply-To: <495CC210.6080900@gnu.org>
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 <jasonr@gnu.org> 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!
next prev parent reply other threads:[~2009-01-01 13:43 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-31 13:00 Optimized gcc 4.3.0 build on Windows returns 0 secs for all time values of system-process-attributes Juanma Barranquero
2008-12-31 17:29 ` dhruva
2008-12-31 19:12 ` Eli Zaretskii
2009-01-01 4:38 ` Juanma Barranquero
2009-01-01 12:57 ` dhruva
2009-01-01 13:08 ` dhruva
2009-01-01 13:16 ` Jason Rumney
2009-01-01 13:43 ` dhruva [this message]
2009-01-01 19:00 ` Eli Zaretskii
2009-01-02 4:59 ` dhruva
2009-01-02 14:33 ` Eli Zaretskii
2009-01-02 17:44 ` Chetan Pandya
2009-01-01 18:03 ` Juanma Barranquero
2009-01-01 18:54 ` Eli Zaretskii
2009-01-03 2:27 ` Juanma Barranquero
2009-01-03 12:29 ` Eli Zaretskii
2009-01-03 13:28 ` Juanma Barranquero
2009-01-03 13:53 ` Juanma Barranquero
2009-01-03 15:33 ` Eli Zaretskii
2009-01-03 16:00 ` Juanma Barranquero
2009-01-03 16:40 ` Eli Zaretskii
2009-01-03 16:56 ` Eli Zaretskii
2009-01-03 17:14 ` Juanma Barranquero
2009-01-03 19:02 ` Eli Zaretskii
2009-01-04 2:24 ` Jason Rumney
2009-01-04 2:30 ` Juanma Barranquero
2009-01-04 2:33 ` Jason Rumney
2009-01-04 2:35 ` Juanma Barranquero
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e3f230850901010543g4ded27f8g333dfc163ddd2d1a@mail.gmail.com \
--to=dhruvakm@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=jasonr@gnu.org \
--cc=lekktu@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.