[Gd-chatter] r10723 - trunk/fundev/sources/runtime-manager/debugger-nub/x86-win32

housel at gwydiondylan.org housel at gwydiondylan.org
Thu May 11 17:26:11 CEST 2006


Author: housel
Date: Thu May 11 17:26:08 2006
New Revision: 10723

Modified:
   trunk/fundev/sources/runtime-manager/debugger-nub/x86-win32/misc_utils.c
Log:
Bug: 7311
Use floating-point arithmetic instead of 64-bit integer arithmetic on FILETIME
quantities in order to prevent the compiler from generating references to
statically-linked runtime library routines.

* fundev/sources/runtime-manager/debugger-nub/x86-win32/misc_utils.c
  (FileTimeToQuadWord): Copy the file time to a ULARGE_INTEGER using
  memcpy as recommended by MS documentation.
  (get_os_thread_cpu_time_accurate): Convert thread user and kernel times
  to miliseconds using floating-point arithmetic to prevent references
  to the _alldiv library routine.
  (get_os_wall_clock_time): Convert the system time to miliseconds using
  floating-point arithmetic.


Modified: trunk/fundev/sources/runtime-manager/debugger-nub/x86-win32/misc_utils.c
==============================================================================
--- trunk/fundev/sources/runtime-manager/debugger-nub/x86-win32/misc_utils.c	(original)
+++ trunk/fundev/sources/runtime-manager/debugger-nub/x86-win32/misc_utils.c	Thu May 11 17:26:08 2006
@@ -688,11 +688,9 @@
 
 __int64 FileTimeToQuadWord (PFILETIME pFileTime)
 {
-  __int64 qw;
-  qw = pFileTime->dwHighDateTime;
-  qw <<= 32;
-  qw |= pFileTime->dwLowDateTime;
-  return(qw);
+  ULARGE_INTEGER qw;
+  memcpy(&qw, pFileTime, sizeof qw);
+  return qw.QuadPart;
 }
 
 
@@ -710,13 +708,13 @@
    LPDBGTHREAD           thread)
 {
   FILETIME CreationTime, ExitTime, KernelTime, UserTime;
-  __int64 utime, ktime;
+  double utime, ktime;
   int milliseconds;
 
   GetThreadTimes (thread->ThreadHandle, &CreationTime, &ExitTime,
                   &KernelTime, &UserTime);
-  ktime = FileTimeToQuadWord(&KernelTime) / 10000;
-  utime = FileTimeToQuadWord(&UserTime) / 10000;
+  ktime = (double) FileTimeToQuadWord(&KernelTime) / 10000.0;
+  utime = (double) FileTimeToQuadWord(&UserTime) / 10000.0;
   milliseconds = (int)ktime + (int)utime;
   return (milliseconds);
 }
@@ -727,7 +725,7 @@
   int        milliseconds;
 
   GetSystemTimeAsFileTime(&CurrentTime);
-  milliseconds = (int)(FileTimeToQuadWord(&CurrentTime) / 10000);
+  milliseconds = (int)((double)FileTimeToQuadWord(&CurrentTime) / 10000.0);
   return(milliseconds);
 }
 



More information about the chatter mailing list