summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-07-24 19:23:53 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-07-24 19:23:53 (GMT)
commitf3923e9dd7a49bc2bc8600b3e0bb147b70e2de28 (patch)
treec1169f33e644b6d8925c13a9292c513ecdb8b995 /Modules/posixmodule.c
parent4c668965539d21d62688d6e40fa785341e956e1d (diff)
downloadcpython-f3923e9dd7a49bc2bc8600b3e0bb147b70e2de28.zip
cpython-f3923e9dd7a49bc2bc8600b3e0bb147b70e2de28.tar.gz
cpython-f3923e9dd7a49bc2bc8600b3e0bb147b70e2de28.tar.bz2
Issue #15413: os.times() had disappeared under Windows.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index b99a5fe..bbf9baf 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7453,8 +7453,11 @@ static PyStructSequence_Desc times_result_desc = {
static PyTypeObject TimesResultType;
+#ifdef MS_WINDOWS
+#define HAVE_TIMES /* mandatory, for the method table */
+#endif
-#if defined(HAVE_TIMES) || defined(MS_WINDOWS)
+#ifdef HAVE_TIMES
static PyObject *
build_times_result(double user, double system,
@@ -7492,10 +7495,6 @@ Return an object containing floating point numbers indicating process\n\
times. The object behaves like a named tuple with these fields:\n\
(utime, stime, cutime, cstime, elapsed_time)");
-#endif
-
-
-#ifdef HAVE_TIMES
#if defined(PYCC_VACPP) && defined(PYOS_OS2)
static long
system_uptime(void)
@@ -7520,26 +7519,6 @@ posix_times(PyObject *self, PyObject *noargs)
(double)0 /* t.tms_cstime / HZ */,
(double)system_uptime() / 1000);
}
-#else /* not OS2 */
-#define NEED_TICKS_PER_SECOND
-static long ticks_per_second = -1;
-static PyObject *
-posix_times(PyObject *self, PyObject *noargs)
-{
- struct tms t;
- clock_t c;
- errno = 0;
- c = times(&t);
- if (c == (clock_t) -1)
- return posix_error();
- return build_times_result(
- (double)t.tms_utime / ticks_per_second,
- (double)t.tms_stime / ticks_per_second,
- (double)t.tms_cutime / ticks_per_second,
- (double)t.tms_cstime / ticks_per_second,
- (double)c / ticks_per_second);
-}
-#endif /* not OS2 */
#elif defined(MS_WINDOWS)
static PyObject *
posix_times(PyObject *self, PyObject *noargs)
@@ -7562,8 +7541,29 @@ posix_times(PyObject *self, PyObject *noargs)
(double)0,
(double)0);
}
+#else /* Neither Windows nor OS/2 */
+#define NEED_TICKS_PER_SECOND
+static long ticks_per_second = -1;
+static PyObject *
+posix_times(PyObject *self, PyObject *noargs)
+{
+ struct tms t;
+ clock_t c;
+ errno = 0;
+ c = times(&t);
+ if (c == (clock_t) -1)
+ return posix_error();
+ return build_times_result(
+ (double)t.tms_utime / ticks_per_second,
+ (double)t.tms_stime / ticks_per_second,
+ (double)t.tms_cutime / ticks_per_second,
+ (double)t.tms_cstime / ticks_per_second,
+ (double)c / ticks_per_second);
+}
#endif
+#endif /* HAVE_TIMES */
+
#ifdef HAVE_GETSID
PyDoc_STRVAR(posix_getsid__doc__,