Index: third_party/tcmalloc/chromium/src/base/cycleclock.h |
=================================================================== |
--- third_party/tcmalloc/chromium/src/base/cycleclock.h (revision 94429) |
+++ third_party/tcmalloc/chromium/src/base/cycleclock.h (working copy) |
@@ -50,16 +50,18 @@ |
#if defined(__MACH__) && defined(__APPLE__) |
# include <mach/mach_time.h> |
#endif |
-// For MSVC, we want the __rdtsc intrinsic, declared in <intrin.h>. |
-// Unfortunately, in some environments, <windows.h> and <intrin.h> have |
-// conflicting declarations of some other intrinsics, breaking compilation. |
+// For MSVC, we want to use '_asm rdtsc' when possible (since it works |
+// with even ancient MSVC compilers), and when not possible the |
+// __rdtsc intrinsic, declared in <intrin.h>. Unfortunately, in some |
+// environments, <windows.h> and <intrin.h> have conflicting |
+// declarations of some other intrinsics, breaking compilation. |
// Therefore, we simply declare __rdtsc ourselves. See also |
// http://connect.microsoft.com/VisualStudio/feedback/details/262047 |
-#if defined(_MSC_VER) |
+#if defined(_MSC_VER) && !defined(_M_IX86) |
extern "C" uint64 __rdtsc(); |
#pragma intrinsic(__rdtsc) |
#endif |
-#ifdef HAVE_SYS_TIME_H |
+#ifdef ARMV3 |
#include <sys/time.h> |
#endif |
@@ -108,6 +110,12 @@ |
int64 itc; |
asm("mov %0 = ar.itc" : "=r" (itc)); |
return itc; |
+#elif defined(_MSC_VER) && defined(_M_IX86) |
+ // Older MSVC compilers (like 7.x) don't seem to support the |
+ // __rdtsc intrinsic properly, so I prefer to use _asm instead |
+ // when I know it will work. Otherwise, I'll use __rdtsc and hope |
+ // the code is being compiled with a non-ancient compiler. |
+ _asm rdtsc |
#elif defined(_MSC_VER) |
return __rdtsc(); |
#elif defined(ARMV3) |