AbstractOperatingSystem.st
branchjv
changeset 18040 a11a12546f23
parent 18028 e39da2aa21bc
parent 14937 808947598c5b
child 18054 56594a8c6b83
--- a/AbstractOperatingSystem.st	Mon Mar 25 23:04:02 2013 +0000
+++ b/AbstractOperatingSystem.st	Wed Mar 27 12:24:15 2013 +0000
@@ -5510,13 +5510,13 @@
      Notice, that the # of cycles has to be multiplied by the cycle time (1/cpu-frequency).
 
      For x86:
-	the CPU cycle count register value is returned (RDTSC instruction).
-	Fails if RDTSC instruction is not supported (which is unlikely, nowadays).
+        the CPU cycle count register value is returned (RDTSC instruction).
+        Fails if RDTSC instruction is not supported (which is unlikely, nowadays).
      For others:
-	currently fails"
+        currently fails"
 
 %{  /* NOCONTEXT */
-    unsigned int low, high;
+    unsigned INT low, high;
 
 #ifdef i386
     // use RDTSC instruction (retrieves 64bit cycle count; hi in EDX, lo in EAX)
@@ -5532,13 +5532,24 @@
 # else
     goto unsupported;
 # endif
+    RETURN ( __MKLARGEINT64(1, low, high) );
 #endif /* i386 */
 
-    RETURN ( __MKLARGEINT64(1, low, high) );
+#ifdef __x86_64__
+# if defined(__GCC__)
+    asm volatile("rdtsc" : "=a"(low), "=d"(high));
+    RETURN ( __MKUINT(low + (high << 32)) );
+# endif
+#endif
+
 unsupported: ;
 %}.
     self primitiveFailed:'no CPU cycle register on this architecture'
 
+    "
+     OperatingSystem getCPUCycleCount
+    "
+
     "Created: / 05-01-2012 / 13:23:31 / cg"
 !
 
@@ -7186,11 +7197,11 @@
 !AbstractOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.233 2013-03-11 09:19:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.234 2013-03-23 11:47:44 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.233 2013-03-11 09:19:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.234 2013-03-23 11:47:44 cg Exp $'
 ! !