Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Doc/library/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ Functions
:c:func:`QueryPerformanceCounter`. The resolution is typically better than one
microsecond.

VxWorks doesn't support this fucntion.
Comment thread
pxinwr marked this conversation as resolved.
Resolved

.. deprecated:: 3.3
The behaviour of this function depends on the platform: use
:func:`perf_counter` or :func:`process_time` instead, depending on your
Expand Down
8 changes: 6 additions & 2 deletions Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def check_ns(sec, ns):
check_ns(time.clock_gettime(time.CLOCK_REALTIME),
time.clock_gettime_ns(time.CLOCK_REALTIME))

@unittest.skipUnless(hasattr(time, 'clock'),
'need time.clock()')
def test_clock(self):
with self.assertWarns(DeprecationWarning):
time.clock()
Expand Down Expand Up @@ -549,8 +551,10 @@ def test_localtime_failure(self):
self.assertRaises(ValueError, time.ctime, float("nan"))

def test_get_clock_info(self):
clocks = ['clock', 'monotonic', 'perf_counter', 'process_time', 'time']

if hasattr(time, 'clock'):
clocks = ['clock', 'monotonic', 'perf_counter', 'process_time', 'time']
else:
clocks = ['monotonic', 'perf_counter', 'process_time', 'time']
Comment thread
pxinwr marked this conversation as resolved.
Resolved
for name in clocks:
if name == 'clock':
with self.assertWarns(DeprecationWarning):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add time module support and fix test_time faiures for VxWorks.
19 changes: 12 additions & 7 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ perf_counter(_Py_clock_info_t *info)
return _PyFloat_FromPyTime(t);
}

#if defined(MS_WINDOWS) || defined(HAVE_CLOCK)
#if (defined(MS_WINDOWS) || defined(HAVE_CLOCK)) && !defined(__VXWORKS__)
#define PYCLOCK
static PyObject*
pyclock(_Py_clock_info_t *info)
Expand Down Expand Up @@ -765,7 +765,7 @@ time_strftime(PyObject *self, PyObject *args)
return NULL;
}

#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX)
#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) || defined(__VXWORKS__)
Comment thread
pxinwr marked this conversation as resolved.
Resolved
if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) {
PyErr_SetString(PyExc_ValueError,
"strftime() requires year in [1; 9999]");
Expand Down Expand Up @@ -1005,18 +1005,23 @@ time_mktime(PyObject *self, PyObject *tup)
{
return NULL;
}
#ifndef _AIX
buf.tm_wday = -1; /* sentinel; original value ignored */
tt = mktime(&buf);
#else

#if defined(_AIX) || (defined(__VXWORKS__) && !defined(_WRS_CONFIG_LP64))
Comment thread
pxinwr marked this conversation as resolved.
Resolved
/* year < 1902 or year > 2037 */
if ((buf.tm_year < 2) || (buf.tm_year > 137)) {
/* Issue #19748: On AIX, mktime() doesn't report overflow error for
* timestamp < -2^31 or timestamp > 2**31-1. */
* timestamp < -2^31 or timestamp > 2**31-1. VxWorks has the same
* issue when working in 32 bit mode. */
PyErr_SetString(PyExc_OverflowError,
"mktime argument out of range");
return NULL;
}
#endif

#ifndef _AIX
Comment thread
pxinwr marked this conversation as resolved.
Resolved
buf.tm_wday = -1; /* sentinel; original value ignored */
tt = mktime(&buf);
#else
year = buf.tm_year;
/* year < 1970 - adjust buf.tm_year into legal range */
while (buf.tm_year < 70) {
Expand Down