From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Juanma Barranquero" Newsgroups: gmane.emacs.devel 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 05:38:36 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1230784733 32443 80.91.229.12 (1 Jan 2009 04:38:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 Jan 2009 04:38:53 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Eli Zaretskii" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 01 05:40:03 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LIFLm-0001w2-BJ for ged-emacs-devel@m.gmane.org; Thu, 01 Jan 2009 05:40:03 +0100 Original-Received: from localhost ([127.0.0.1]:56718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LIFKX-0001hp-Bd for ged-emacs-devel@m.gmane.org; Wed, 31 Dec 2008 23:38:45 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LIFKT-0001hk-FC for emacs-devel@gnu.org; Wed, 31 Dec 2008 23:38:41 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LIFKR-0001hW-NV for emacs-devel@gnu.org; Wed, 31 Dec 2008 23:38:40 -0500 Original-Received: from [199.232.76.173] (port=49235 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LIFKR-0001hT-He for emacs-devel@gnu.org; Wed, 31 Dec 2008 23:38:39 -0500 Original-Received: from an-out-0708.google.com ([209.85.132.243]:41212) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LIFKP-0005Pr-3l; Wed, 31 Dec 2008 23:38:37 -0500 Original-Received: by an-out-0708.google.com with SMTP id c38so1888524ana.21 for ; Wed, 31 Dec 2008 20:38:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=BaaHFZtZb8INmfKikPDaKVCn7gv4mOewC/oZRJWL1pg=; b=rMqjQhb8AXIB+FoJ71k7qo47AzYrKPGStZk3cS9xme+foMCKM+QWwJosZk+ZuQBAwR B4CGYlJgbu/28fxWwFf8HoonpuroaeUtP+ey6OyvDmPUVibPDgRpk1vaxTuaMenWxHIS KHz2PilOWR/Qx/jyRXh7VDh64V0HJkuY97mfg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=vhK/NQ0A9p0O6ksopqLRSAyICRWhstz+m8oFBe8IE5e4P+rKf4CtCnfZUD2XFEArNg Vg0gXB/41dhvDuZpnkqG9bewTkdokiyvk86SwLVSIKccfLaLDB4JlpYwoCinzERm7yXj ZI1uJPB/8FsfeJczvhdXy2vDHYd5SVDC9Bogo= Original-Received: by 10.100.110.15 with SMTP id i15mr9262699anc.151.1230784716699; Wed, 31 Dec 2008 20:38:36 -0800 (PST) Original-Received: by 10.100.13.13 with HTTP; Wed, 31 Dec 2008 20:38:36 -0800 (PST) In-Reply-To: Content-Disposition: inline X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:107496 Archived-At: On Wed, Dec 31, 2008 at 20:12, Eli Zaretskii wrote: > It works for me with GCC 3.4.2 and MinGW 3.14: Optimized or unoptimized build? > Could you please step into process_times and ltime (or add printf's if > stepping doesn't work), and see what is going wrong and where? Stepping isn't much helpful because most variables are optimized away. As for printf, I'm not sure what's wrong, but long double x = 3.5; printf ("f = %Lf\n", x); printf ("g = %Lg\n", x); => f = -26815615859885194000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000.000000 g = -2.68156e+154 (Not just with gcc 4.3.0, I get the same result with 3.4.5.) Am I missing something obvious? I tried rewriting w32.c:process_time to do time computations by using ULARGE_INTEGER (see attached patch), as the Platform SDK recommends, and it works fine. Why it is implemented with long doubles? Juanma Index: src/w32.c =================================================================== RCS file: /sources/emacs/emacs/src/w32.c,v retrieving revision 1.157 diff -u -2 -r1.157 w32.c --- src/w32.c 19 Dec 2008 19:50:39 -0000 1.157 +++ src/w32.c 31 Dec 2008 17:04:23 -0000 @@ -3778,7 +3778,7 @@ { 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; + DWORD ctime_sec, ctime_usec, stime_sec, stime_usec, utime_sec, utime_usec; + DWORD etime_sec, etime_usec; + ULARGE_INTEGER tem1, tem2, tem, utc; if (!h_proc @@ -3788,31 +3788,43 @@ return 0; + utc.LowPart = utc_base_ft.dwLowDateTime; + utc.HighPart = utc_base_ft.dwHighDateTime; + GetSystemTimeAsFileTime (&ft_current); - tem1 = convert_time_raw (ft_kernel) * 0.1L; - stime_usec = fmodl (tem1, 1000000.0L); - stime_sec = tem1 * 0.000001L; + tem1.LowPart = ft_kernel.dwLowDateTime; + tem1.HighPart = ft_kernel.dwHighDateTime; + tem1.QuadPart /= 10L; + stime_usec = tem1.QuadPart % 1000000L; + stime_sec = tem1.QuadPart / 1000000L; *stime = ltime (stime_sec, stime_usec); - tem2 = convert_time_raw (ft_user) * 0.1L; - utime_usec = fmodl (tem2, 1000000.0L); - utime_sec = tem2 * 0.000001L; + tem2.LowPart = ft_user.dwLowDateTime; + tem2.HighPart = ft_user.dwHighDateTime; + tem2.QuadPart /= 10L; + utime_usec = tem2.QuadPart % 1000000L; + utime_sec = tem2.QuadPart / 1000000L; *utime = ltime (utime_sec, utime_usec); - tem = convert_time_raw (ft_creation); + tem.LowPart = ft_creation.dwLowDateTime; + tem.HighPart = ft_creation.dwHighDateTime; /* Process no 4 (System) returns zero creation time. */ - if (tem) - tem = (tem - utc_base) * 0.1; - ctime_usec = fmodl (tem, 1000000.0L); - ctime_sec = tem * 0.000001L; + if (tem.QuadPart) + tem.QuadPart = (tem.QuadPart - utc.QuadPart) / 10L; + ctime_usec = tem.QuadPart % 1000000L; + ctime_sec = tem.QuadPart / 1000000L; *ctime = ltime (ctime_sec, ctime_usec); - if (tem) - tem = (convert_time_raw (ft_current) - utc_base) * 0.1L - tem; - etime_usec = fmodl (tem, 1000000.0L); - etime_sec = tem * 0.000001L; + if (tem.QuadPart) + { + ULARGE_INTEGER current; + current.LowPart = ft_current.dwLowDateTime; + current.HighPart = ft_current.dwHighDateTime; + tem.QuadPart = (current.QuadPart - utc.QuadPart) / 10L - tem.QuadPart; + } + etime_usec = tem.QuadPart % 1000000L; + etime_sec = tem.QuadPart / 1000000L; *etime = ltime (etime_sec, etime_usec); - - if (tem) + if (tem.QuadPart) { - *pcpu = 100.0 * (tem1 + tem2) / tem; - if (*pcpu > 100) + *pcpu = (100.0 * (tem1.QuadPart + tem2.QuadPart)) / tem.QuadPart; + if (*pcpu > 100.0) *pcpu = 100.0; }