[pypy-commit] pypy py3k: Get rid of HAVE_CLOCK as it should be present for all supported platforms.
marky1991
pypy.commits at gmail.com
Fri Jul 22 04:35:24 EDT 2016
Author: Mark Young <marky1991 at gmail.com>
Branch: py3k
Changeset: r85805:1cb5b55f850c
Date: 2016-07-16 18:07 -0400
http://bitbucket.org/pypy/pypy/changeset/1cb5b55f850c/
Log: Get rid of HAVE_CLOCK as it should be present for all supported
platforms.
diff --git a/pypy/module/time/__init__.py b/pypy/module/time/__init__.py
--- a/pypy/module/time/__init__.py
+++ b/pypy/module/time/__init__.py
@@ -1,6 +1,7 @@
from pypy.interpreter.mixedmodule import MixedModule
-from .interp_time import CLOCK_CONSTANTS, HAS_CLOCK_GETTIME, cConfig
+from .interp_time import (CLOCK_CONSTANTS, HAS_CLOCK_GETTIME, cConfig,
+ HAS_MONOTONIC)
import os
_WIN = os.name == "nt"
@@ -19,7 +20,6 @@
'strftime': 'interp_time.strftime',
'sleep' : 'interp_time.sleep',
'_STRUCT_TM_ITEMS': 'space.wrap(interp_time._STRUCT_TM_ITEMS)',
- 'monotonic': 'interp_time.monotonic',
'perf_counter': 'interp_time.perf_counter',
'process_time': 'interp_time.process_time',
}
@@ -28,6 +28,8 @@
interpleveldefs['clock_gettime'] = 'interp_time.clock_gettime'
interpleveldefs['clock_settime'] = 'interp_time.clock_settime'
interpleveldefs['clock_getres'] = 'interp_time.clock_getres'
+ if HAS_MONOTONIC:
+ interpleveldefs['monotonic'] = 'interp_time.monotonic'
if os.name == "posix":
interpleveldefs['tzset'] = 'interp_time.tzset'
diff --git a/pypy/module/time/app_time.py b/pypy/module/time/app_time.py
--- a/pypy/module/time/app_time.py
+++ b/pypy/module/time/app_time.py
@@ -38,7 +38,7 @@
time.time(info)
elif name == "monotonic" and hasattr(time, "monotonic"):
time.monotonic(info)
- elif name == "clock" and hasattr(time, "clock"):
+ elif name == "clock":
time.clock(info)
elif name == "perf_counter":
time.perf_counter(info)
diff --git a/pypy/module/time/interp_time.py b/pypy/module/time/interp_time.py
--- a/pypy/module/time/interp_time.py
+++ b/pypy/module/time/interp_time.py
@@ -163,7 +163,6 @@
has_gettimeofday = platform.Has('gettimeofday')
has_clock_gettime = platform.Has('clock_gettime')
CLOCK_PROF = platform.DefinedConstantInteger('CLOCK_PROF')
- HAVE_CLOCK = platform.DefinedConstantInteger("HAVE_CLOCK")
CLOCK_CONSTANTS = ['CLOCK_HIGHRES', 'CLOCK_MONOTONIC', 'CLOCK_MONOTONIC_RAW',
'CLOCK_PROCESS_CPUTIME_ID', 'CLOCK_REALTIME',
@@ -232,7 +231,6 @@
HAS_CLOCK_GETTIME = cConfig.has_clock_gettime
HAS_CLOCK_HIGHRES = cConfig.CLOCK_HIGHRES is not None
HAS_CLOCK_MONOTONIC = cConfig.CLOCK_MONOTONIC is not None
-HAS_CLOCK = _WIN or cConfig.HAVE_CLOCK
HAS_MONOTONIC = (_WIN or _MACOSX or
(HAS_CLOCK_GETTIME and (HAS_CLOCK_HIGHRES or HAS_CLOCK_MONOTONIC)))
clock_t = cConfig.clock_t
@@ -1036,29 +1034,28 @@
return space.wrap(cpu_time / rposix.CLOCK_TICKS_PER_SECOND)
return clock(space)
-if HAS_CLOCK:
- _clock = external('clock', [], clock_t)
- def clock(space, w_info=None):
- """clock() -> floating point number
+_clock = external('clock', [], clock_t)
+def clock(space, w_info=None):
+ """clock() -> floating point number
- Return the CPU time or real time since the start of the process or since
- the first call to clock(). This has as much precision as the system
- records."""
- if _WIN:
- try:
- return win_perf_counter(space, w_info=w_info)
- except ValueError:
- pass
- value = _clock()
- # Is this casting correct?
- if value == rffi.cast(clock_t, -1):
- raise oefmt(space.w_RuntimeError,
- "the processor time used is not available or its value"
- "cannot be represented")
- if w_info is not None:
- _setinfo(space, w_info,
- "clock()", 1.0 / CLOCKS_PER_SEC, True, False)
- return space.wrap((1.0 * value) / CLOCKS_PER_SEC)
+ Return the CPU time or real time since the start of the process or since
+ the first call to clock(). This has as much precision as the system
+ records."""
+ if _WIN:
+ try:
+ return win_perf_counter(space, w_info=w_info)
+ except ValueError:
+ pass
+ value = _clock()
+ # Is this casting correct?
+ if value == rffi.cast(clock_t, -1):
+ raise oefmt(space.w_RuntimeError,
+ "the processor time used is not available or its value"
+ "cannot be represented")
+ if w_info is not None:
+ _setinfo(space, w_info,
+ "clock()", 1.0 / CLOCKS_PER_SEC, True, False)
+ return space.wrap((1.0 * value) / CLOCKS_PER_SEC)
def _setinfo(space, w_info, impl, res, mono, adj):
More information about the pypy-commit
mailing list