Ensure we also build on VC7. Involves replacing largeint.h helper functions with msvc's native 64 bit integers.
diff --git a/Modules/_hotshot.c b/Modules/_hotshot.c
index f88629d..1eecc7e 100644
--- a/Modules/_hotshot.c
+++ b/Modules/_hotshot.c
@@ -14,7 +14,6 @@
*/
#ifdef MS_WIN32
#include <windows.h>
-#include <largeint.h>
#include <direct.h> /* for getcwd() */
typedef __int64 hs_time;
#define GETTIMEOFDAY(P_HS_TIME) \
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 6841b0f..b009ea1 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -51,7 +51,6 @@
#if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(__BORLANDC__)
/* Win32 has better clock replacement
XXX Win64 does not yet, but might when the platform matures. */
-#include <largeint.h>
#undef HAVE_CLOCK /* We have our own version down below */
#endif /* MS_WIN32 && !MS_WIN64 */
@@ -144,36 +143,33 @@
#endif /* HAVE_CLOCK */
#if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(__BORLANDC__)
-/* Due to Mark Hammond */
+/* Due to Mark Hammond and Tim Peters */
static PyObject *
time_clock(PyObject *self, PyObject *args)
{
- static LARGE_INTEGER ctrStart;
- static LARGE_INTEGER divisor = {0,0};
- LARGE_INTEGER now, diff, rem;
+ static LONG_LONG ctrStart;
+ static double divisor = 0.0;
+ LONG_LONG now;
+ double diff;
+ assert(sizeof(LONG_LONG) == sizeof(LARGE_INTEGER));
if (!PyArg_ParseTuple(args, ":clock"))
return NULL;
- if (LargeIntegerEqualToZero(divisor)) {
- QueryPerformanceCounter(&ctrStart);
- if (!QueryPerformanceFrequency(&divisor) ||
- LargeIntegerEqualToZero(divisor)) {
- /* Unlikely to happen -
- this works on all intel machines at least!
- Revert to clock() */
+ if (divisor == 0.0) {
+ LONG_LONG freq;
+ QueryPerformanceCounter((LARGE_INTEGER*)&ctrStart);
+ if (!QueryPerformanceFrequency((LARGE_INTEGER*)&freq) ||
+ freq == 0) {
+ /* Unlikely to happen - this works on all intel
+ machines at least! Revert to clock() */
return PyFloat_FromDouble(clock());
}
+ divisor = (double)freq;
}
- QueryPerformanceCounter(&now);
- diff = LargeIntegerSubtract(now, ctrStart);
- diff = LargeIntegerDivide(diff, divisor, &rem);
- /* XXX - we assume both divide results fit in 32 bits. This is
- true on Intels. First person who can afford a machine that
- doesnt deserves to fix it :-)
- */
- return PyFloat_FromDouble((double)diff.LowPart +
- ((double)rem.LowPart / (double)divisor.LowPart));
+ QueryPerformanceCounter((LARGE_INTEGER*)&now);
+ diff = (double)(now - ctrStart);
+ return PyFloat_FromDouble(diff / divisor);
}
#define HAVE_CLOCK /* So it gets included in the methods */