diff options
| author | Richard Brooksby | 2012-09-12 14:21:35 +0100 |
|---|---|---|
| committer | Richard Brooksby | 2012-09-12 14:21:35 +0100 |
| commit | 13da97d0f2d3b45defc106b7f0adb3a45b3a4cee (patch) | |
| tree | a2a1c07e1bc65d6de92c6beaf87591395943c46c /mps/code | |
| parent | 2547d178297217c6553ac5ccc49e99d2cb0d32af (diff) | |
| download | emacs-13da97d0f2d3b45defc106b7f0adb3a45b3a4cee.tar.gz emacs-13da97d0f2d3b45defc106b7f0adb3a45b3a4cee.zip | |
Removing dependency on microsoft c run-time __aullshr by treating the event clock as a struct in some circumstances.
Copied from Perforce
Change: 179444
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/eventcnv.c | 14 | ||||
| -rw-r--r-- | mps/code/eventcom.h | 61 |
2 files changed, 49 insertions, 26 deletions
diff --git a/mps/code/eventcnv.c b/mps/code/eventcnv.c index 8d22af1b898..fcd569add74 100644 --- a/mps/code/eventcnv.c +++ b/mps/code/eventcnv.c | |||
| @@ -80,7 +80,8 @@ static void everror(const char *format, ...) | |||
| 80 | va_list args; | 80 | va_list args; |
| 81 | 81 | ||
| 82 | fflush(stdout); /* sync */ | 82 | fflush(stdout); /* sync */ |
| 83 | fprintf(stderr, "%s: @%"PRIuLONGEST" ", prog, (ulongest_t)eventTime); | 83 | fprintf(stderr, "%s: @", prog); |
| 84 | EVENT_CLOCK_PRINT(stderr, eventTime); | ||
| 84 | va_start(args, format); | 85 | va_start(args, format); |
| 85 | vfprintf(stderr, format, args); | 86 | vfprintf(stderr, format, args); |
| 86 | fprintf(stderr, "\n"); | 87 | fprintf(stderr, "\n"); |
| @@ -605,10 +606,13 @@ static void readLog(EventProc proc) | |||
| 605 | printf("(t"); | 606 | printf("(t"); |
| 606 | break; | 607 | break; |
| 607 | case 'C': | 608 | case 'C': |
| 608 | /* FIXME: This attempted to print the event stats on a row that | 609 | { |
| 609 | resembled a kind of final event, but the event clock no longer runs | 610 | /* FIXME: This attempted to print the event stats on a row that |
| 610 | monotonically upwards. */ | 611 | resembled a kind of final event, but the event clock no longer runs |
| 611 | EVENT_CLOCK_PRINT(stdout, eventTime+1); | 612 | monotonically upwards. */ |
| 613 | EventClock last = eventTime + 1; | ||
| 614 | EVENT_CLOCK_PRINT(stdout, last); | ||
| 615 | } | ||
| 612 | break; | 616 | break; |
| 613 | } | 617 | } |
| 614 | reportEventResults(totalEventCount); | 618 | reportEventResults(totalEventCount); |
diff --git a/mps/code/eventcom.h b/mps/code/eventcom.h index cc78a45d09d..d108609715c 100644 --- a/mps/code/eventcom.h +++ b/mps/code/eventcom.h | |||
| @@ -42,44 +42,63 @@ | |||
| 42 | 42 | ||
| 43 | typedef unsigned __int64 EventClock; | 43 | typedef unsigned __int64 EventClock; |
| 44 | 44 | ||
| 45 | typedef union EventClockUnion { | ||
| 46 | struct { | ||
| 47 | unsigned low, high; | ||
| 48 | } half; | ||
| 49 | unsigned __int64 whole; | ||
| 50 | } EventClockUnion; | ||
| 51 | |||
| 45 | #if _MSC_VER >= 1400 | 52 | #if _MSC_VER >= 1400 |
| 46 | 53 | ||
| 47 | #pragma intrinsic(__rdtsc) | 54 | #pragma intrinsic(__rdtsc) |
| 48 | 55 | ||
| 56 | #define EVENT_CLOCK(lvalue) \ | ||
| 57 | BEGIN \ | ||
| 58 | (lvalue) = __rdtsc(); \ | ||
| 59 | END | ||
| 60 | |||
| 49 | #else /* _MSC_VER < 1400 */ | 61 | #else /* _MSC_VER < 1400 */ |
| 50 | 62 | ||
| 51 | /* Fake the __rdtsc intrinsic for old Microsoft C versions. */ | 63 | /* 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 */ | ||
| 69 | 64 | ||
| 70 | #define EVENT_CLOCK(lvalue) \ | 65 | #define EVENT_CLOCK(lvalue) \ |
| 71 | BEGIN \ | 66 | BEGIN \ |
| 72 | (lvalue) = __rdtsc(); \ | 67 | EventClockUnion ecu; \ |
| 68 | __asm { \ | ||
| 69 | __asm __emit 0fh __asm __emit 031h ; rdtsc \ | ||
| 70 | mov ecu.half.high, edx \ | ||
| 71 | mov ecu.half.low, eax \ | ||
| 72 | } \ | ||
| 73 | (lvalue) = ecu.whole; \ | ||
| 73 | END | 74 | END |
| 74 | 75 | ||
| 75 | #define EVENT_CLOCK_PRINT(stream, clock) fprintf(stream, "%llX", clock) | 76 | #endif /* _MSC_VER < 1400 */ |
| 76 | 77 | ||
| 77 | #if defined(MPS_ARCH_I3) | 78 | #if defined(MPS_ARCH_I3) |
| 79 | |||
| 80 | /* We can't use a shift to get the top half of the 64-bit event clock, | ||
| 81 | because that introduces a dependency on `__aullshr` in the C run-time. */ | ||
| 82 | |||
| 83 | #define EVENT_CLOCK_PRINT(stream, clock) \ | ||
| 84 | fprintf(stream, "%08lX%08lX", \ | ||
| 85 | (*(EventClockUnion *)&(clock)).half.high, \ | ||
| 86 | (*(EventClockUnion *)&(clock)).half.low) | ||
| 87 | |||
| 78 | #define EVENT_CLOCK_WRITE(stream, clock) \ | 88 | #define EVENT_CLOCK_WRITE(stream, clock) \ |
| 79 | WriteF(stream, "$W$W", (WriteFW)((clock) >> 32), (WriteFW)clock, NULL) | 89 | WriteF(stream, "$W$W", \ |
| 90 | (*(EventClockUnion *)&(clock)).half.high, \ | ||
| 91 | (*(EventClockUnion *)&(clock)).half.low, \ | ||
| 92 | NULL) | ||
| 93 | |||
| 80 | #elif defined(MPS_ARCH_I6) | 94 | #elif defined(MPS_ARCH_I6) |
| 95 | |||
| 96 | #define EVENT_CLOCK_PRINT(stream, clock) \ | ||
| 97 | fprintf(stream, "%016lX", (clock)); | ||
| 98 | |||
| 81 | #define EVENT_CLOCK_WRITE(stream, clock) \ | 99 | #define EVENT_CLOCK_WRITE(stream, clock) \ |
| 82 | WriteF(stream, "$W", (WriteFW)(clock), NULL) | 100 | WriteF(stream, "$W", (WriteFW)(clock), NULL) |
| 101 | |||
| 83 | #endif | 102 | #endif |
| 84 | 103 | ||
| 85 | #endif /* Microsoft C on Intel */ | 104 | #endif /* Microsoft C on Intel */ |