[前][次][番号順一覧][スレッド一覧]

ruby-changes:7018

From: kouji <ko1@a...>
Date: Tue, 12 Aug 2008 18:55:20 +0900 (JST)
Subject: [ruby-changes:7018] Ruby:r18536 (trunk): * gc.c (getrusage_time): Returned effective value on Windows.

kouji	2008-08-12 18:55:06 +0900 (Tue, 12 Aug 2008)

  New Revision: 18536

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18536

  Log:
    * gc.c (getrusage_time): Returned effective value on Windows.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18535)
+++ ChangeLog	(revision 18536)
@@ -1,3 +1,7 @@
+Tue Aug 12 18:51:29 2008  TAKAO Kouji  <kouji@t...>
+
+	* gc.c (getrusage_time): Returned effective value on Windows.
+
 Tue Aug 12 18:51:11 2008  Tanaka Akira  <akr@f...>
 
 	* transcode.c (rb_trans_open): free ts before raise.
Index: gc.c
===================================================================
--- gc.c	(revision 18535)
+++ gc.c	(revision 18536)
@@ -119,7 +119,28 @@
     getrusage(RUSAGE_SELF, &usage);
     time = usage.ru_utime;
     return time.tv_sec + time.tv_usec * 1e-6;
+#elif defined _WIN32
+    FILETIME creation_time, exit_time, kernel_time, user_time;
+    ULARGE_INTEGER ui;
+    LONG_LONG q;
+    double t;
+    
+    if (GetProcessTimes(GetCurrentProcess(),
+			&creation_time, &exit_time, &kernel_time, &user_time) == 0)
+    {
+	return 0.0;
+    }
+    memcpy(&ui, &user_time, sizeof(FILETIME));
+    q = ui.QuadPart / 10L;
+    t = (DWORD)(q % 1000000L) * 1e-6;
+    q /= 1000000L;
+#ifdef __GNUC__
+    t += q;
 #else
+    t += (double)(DWORD)(q >> 16) * (1 << 16);
+    t += (DWORD)q & ~(~0 << 16);
+#endif
+#else
     return 0.0;
 #endif
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]