Issue #1040026: Fix os.times result on systems where HZ is incorrect.
This commit is contained in:
parent
c252d9bc08
commit
710fb8bf45
|
@ -225,6 +225,8 @@ Library
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #1040026: Fix os.times result on systems where HZ is incorrect.
|
||||||
|
|
||||||
- Issue #4228: Pack negative values the same way as 2.4 in struct's L format.
|
- Issue #4228: Pack negative values the same way as 2.4 in struct's L format.
|
||||||
|
|
||||||
- Security Issue #2: imageop did not validate arguments correctly and could
|
- Security Issue #2: imageop did not validate arguments correctly and could
|
||||||
|
|
|
@ -5748,10 +5748,6 @@ posix_symlink(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_TIMES
|
#ifdef HAVE_TIMES
|
||||||
#ifndef HZ
|
|
||||||
#define HZ 60 /* Universal constant :-) */
|
|
||||||
#endif /* HZ */
|
|
||||||
|
|
||||||
#if defined(PYCC_VACPP) && defined(PYOS_OS2)
|
#if defined(PYCC_VACPP) && defined(PYOS_OS2)
|
||||||
static long
|
static long
|
||||||
system_uptime(void)
|
system_uptime(void)
|
||||||
|
@ -5777,6 +5773,8 @@ posix_times(PyObject *self, PyObject *noargs)
|
||||||
(double)system_uptime() / 1000);
|
(double)system_uptime() / 1000);
|
||||||
}
|
}
|
||||||
#else /* not OS2 */
|
#else /* not OS2 */
|
||||||
|
#define NEED_TICKS_PER_SECOND
|
||||||
|
static long ticks_per_second = -1;
|
||||||
static PyObject *
|
static PyObject *
|
||||||
posix_times(PyObject *self, PyObject *noargs)
|
posix_times(PyObject *self, PyObject *noargs)
|
||||||
{
|
{
|
||||||
|
@ -5787,11 +5785,11 @@ posix_times(PyObject *self, PyObject *noargs)
|
||||||
if (c == (clock_t) -1)
|
if (c == (clock_t) -1)
|
||||||
return posix_error();
|
return posix_error();
|
||||||
return Py_BuildValue("ddddd",
|
return Py_BuildValue("ddddd",
|
||||||
(double)t.tms_utime / HZ,
|
(double)t.tms_utime / ticks_per_second,
|
||||||
(double)t.tms_stime / HZ,
|
(double)t.tms_stime / ticks_per_second,
|
||||||
(double)t.tms_cutime / HZ,
|
(double)t.tms_cutime / ticks_per_second,
|
||||||
(double)t.tms_cstime / HZ,
|
(double)t.tms_cstime / ticks_per_second,
|
||||||
(double)c / HZ);
|
(double)c / ticks_per_second);
|
||||||
}
|
}
|
||||||
#endif /* not OS2 */
|
#endif /* not OS2 */
|
||||||
#endif /* HAVE_TIMES */
|
#endif /* HAVE_TIMES */
|
||||||
|
@ -8707,6 +8705,15 @@ INITFUNC(void)
|
||||||
|
|
||||||
statvfs_result_desc.name = MODNAME ".statvfs_result";
|
statvfs_result_desc.name = MODNAME ".statvfs_result";
|
||||||
PyStructSequence_InitType(&StatVFSResultType, &statvfs_result_desc);
|
PyStructSequence_InitType(&StatVFSResultType, &statvfs_result_desc);
|
||||||
|
#ifdef NEED_TICKS_PER_SECOND
|
||||||
|
# if defined(HAVE_SYSCONF) && defined(_SC_CLK_TCK)
|
||||||
|
ticks_per_second = sysconf(_SC_CLK_TCK);
|
||||||
|
# elif defined(HZ)
|
||||||
|
ticks_per_second = HZ;
|
||||||
|
# else
|
||||||
|
ticks_per_second = 60; /* magic fallback value; may be bogus */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
Py_INCREF((PyObject*) &StatResultType);
|
Py_INCREF((PyObject*) &StatResultType);
|
||||||
PyModule_AddObject(m, "stat_result", (PyObject*) &StatResultType);
|
PyModule_AddObject(m, "stat_result", (PyObject*) &StatResultType);
|
||||||
|
|
Loading…
Reference in New Issue