diff options
| author | Richard Brooksby | 2012-09-11 18:03:28 +0100 |
|---|---|---|
| committer | Richard Brooksby | 2012-09-11 18:03:28 +0100 |
| commit | c4d25ec6e6a7800fb2dbeafc9de606587343da70 (patch) | |
| tree | ea342015a6481735368a855c610e9f57c802f45e /mps/code | |
| parent | 019708da22caadb1946f35cd4f037b945b71ba79 (diff) | |
| download | emacs-c4d25ec6e6a7800fb2dbeafc9de606587343da70.tar.gz emacs-c4d25ec6e6a7800fb2dbeafc9de606587343da70.zip | |
Patching eventcom.h to provide a fast event clock on old versions of microsoft c.
Copied from Perforce
Change: 179431
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/eventcom.h | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/mps/code/eventcom.h b/mps/code/eventcom.h index 9c761a552f4..cc78a45d09d 100644 --- a/mps/code/eventcom.h +++ b/mps/code/eventcom.h | |||
| @@ -18,6 +18,10 @@ | |||
| 18 | * | 18 | * |
| 19 | * On platforms that support it, we want to stamp events with a very cheap | 19 | * On platforms that support it, we want to stamp events with a very cheap |
| 20 | * and fast high-resolution timer. | 20 | * and fast high-resolution timer. |
| 21 | * | ||
| 22 | * TODO: This is a sufficiently complicated nest of ifdefs that it should | ||
| 23 | * be quarantined in its own header with KEEP OUT signs attached. | ||
| 24 | * RB 2012-09-11 | ||
| 21 | */ | 25 | */ |
| 22 | 26 | ||
| 23 | /* TODO: Clang supposedly provides a cross-platform builtin for a fast | 27 | /* TODO: Clang supposedly provides a cross-platform builtin for a fast |
| @@ -36,9 +40,32 @@ | |||
| 36 | <http://msdn.microsoft.com/en-US/library/twchhe95%28v=vs.100%29.aspx> */ | 40 | <http://msdn.microsoft.com/en-US/library/twchhe95%28v=vs.100%29.aspx> */ |
| 37 | #if (defined(MPS_ARCH_I3) || defined(MPS_ARCH_I6)) && defined(MPS_BUILD_MV) | 41 | #if (defined(MPS_ARCH_I3) || defined(MPS_ARCH_I6)) && defined(MPS_BUILD_MV) |
| 38 | 42 | ||
| 43 | typedef unsigned __int64 EventClock; | ||
| 44 | |||
| 45 | #if _MSC_VER >= 1400 | ||
| 46 | |||
| 39 | #pragma intrinsic(__rdtsc) | 47 | #pragma intrinsic(__rdtsc) |
| 40 | 48 | ||
| 41 | typedef unsigned __int64 EventClock; | 49 | #else /* _MSC_VER < 1400 */ |
| 50 | |||
| 51 | /* Fake the __rdtsc intrinsic for old Microsoft C versions. */ | ||
| 52 | static __inline unsigned __int64 __rdtsc() | ||
| 53 | { | ||
| 54 | union { | ||
| 55 | struct { | ||
| 56 | unsigned low, high; | ||
| 57 | } half; | ||
| 58 | unsigned __int64 whole; | ||
| 59 | } li; | ||
| 60 | __asm { | ||
| 61 | __asm __emit 0fh __asm __emit 031h ; rdtsc | ||
| 62 | mov li.half.high, edx | ||
| 63 | mov li.half.low, eax | ||
| 64 | } | ||
| 65 | return li.whole; | ||
| 66 | } | ||
| 67 | |||
| 68 | #endif /* _MSC_VER >= 1400 */ | ||
| 42 | 69 | ||
| 43 | #define EVENT_CLOCK(lvalue) \ | 70 | #define EVENT_CLOCK(lvalue) \ |
| 44 | BEGIN \ | 71 | BEGIN \ |