[Python-checkins] CVS: python/dist/src/Modules _hotshot.c,1.13,1.14 timemodule.c,2.120,2.121
Mark Hammond
mhammond@users.sourceforge.net
2002年2月11日 20:02:35 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv18534
Modified Files:
_hotshot.c timemodule.c
Log Message:
Ensure we also build on VC7. Involves replacing largeint.h helper functions with msvc's native 64 bit integers.
Index: _hotshot.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** _hotshot.c 8 Feb 2002 21:27:50 -0000 1.13
--- _hotshot.c 12 Feb 2002 04:02:33 -0000 1.14
***************
*** 15,19 ****
#ifdef MS_WIN32
#include <windows.h>
- #include <largeint.h>
#include <direct.h> /* for getcwd() */
typedef __int64 hs_time;
--- 15,18 ----
Index: timemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v
retrieving revision 2.120
retrieving revision 2.121
diff -C2 -d -r2.120 -r2.121
*** timemodule.c 16 Jan 2002 11:04:06 -0000 2.120
--- timemodule.c 12 Feb 2002 04:02:33 -0000 2.121
***************
*** 52,56 ****
/* 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 */
--- 52,55 ----
***************
*** 145,178 ****
#if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(__BORLANDC__)
! /* Due to Mark Hammond */
static PyObject *
time_clock(PyObject *self, PyObject *args)
{
! static LARGE_INTEGER ctrStart;
! static LARGE_INTEGER divisor = {0,0};
! LARGE_INTEGER now, diff, rem;
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() */
return PyFloat_FromDouble(clock());
}
}
! 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));
}
--- 144,174 ----
#if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(__BORLANDC__)
! /* Due to Mark Hammond and Tim Peters */
static PyObject *
time_clock(PyObject *self, PyObject *args)
{
! 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 (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((LARGE_INTEGER*)&now);
! diff = (double)(now - ctrStart);
! return PyFloat_FromDouble(diff / divisor);
}