@@ -7453,8 +7453,11 @@ static PyStructSequence_Desc times_result_desc = {
74537453
74547454static PyTypeObject TimesResultType ;
74557455
7456+ #ifdef MS_WINDOWS
7457+ #define HAVE_TIMES /* mandatory, for the method table */
7458+ #endif
74567459
7457- #if defined( HAVE_TIMES ) || defined( MS_WINDOWS )
7460+ #ifdef HAVE_TIMES
74587461
74597462static PyObject *
74607463build_times_result (double user , double system ,
@@ -7492,10 +7495,6 @@ Return an object containing floating point numbers indicating process\n\
74927495times. The object behaves like a named tuple with these fields:\n\
74937496 (utime, stime, cutime, cstime, elapsed_time)" );
74947497
7495- #endif
7496-
7497-
7498- #ifdef HAVE_TIMES
74997498#if defined(PYCC_VACPP ) && defined(PYOS_OS2 )
75007499static long
75017500system_uptime (void )
@@ -7520,26 +7519,6 @@ posix_times(PyObject *self, PyObject *noargs)
75207519 (double )0 /* t.tms_cstime / HZ */ ,
75217520 (double )system_uptime () / 1000 );
75227521}
7523- #else /* not OS2 */
7524- #define NEED_TICKS_PER_SECOND
7525- static long ticks_per_second = -1 ;
7526- static PyObject *
7527- posix_times (PyObject * self , PyObject * noargs )
7528- {
7529- struct tms t ;
7530- clock_t c ;
7531- errno = 0 ;
7532- c = times (& t );
7533- if (c == (clock_t ) - 1 )
7534- return posix_error ();
7535- return build_times_result (
7536- (double )t .tms_utime / ticks_per_second ,
7537- (double )t .tms_stime / ticks_per_second ,
7538- (double )t .tms_cutime / ticks_per_second ,
7539- (double )t .tms_cstime / ticks_per_second ,
7540- (double )c / ticks_per_second );
7541- }
7542- #endif /* not OS2 */
75437522#elif defined(MS_WINDOWS)
75447523static PyObject *
75457524posix_times (PyObject * self , PyObject * noargs )
@@ -7562,8 +7541,29 @@ posix_times(PyObject *self, PyObject *noargs)
75627541 (double )0 ,
75637542 (double )0 );
75647543}
7544+ #else /* Neither Windows nor OS/2 */
7545+ #define NEED_TICKS_PER_SECOND
7546+ static long ticks_per_second = -1 ;
7547+ static PyObject *
7548+ posix_times (PyObject * self , PyObject * noargs )
7549+ {
7550+ struct tms t ;
7551+ clock_t c ;
7552+ errno = 0 ;
7553+ c = times (& t );
7554+ if (c == (clock_t ) - 1 )
7555+ return posix_error ();
7556+ return build_times_result (
7557+ (double )t .tms_utime / ticks_per_second ,
7558+ (double )t .tms_stime / ticks_per_second ,
7559+ (double )t .tms_cutime / ticks_per_second ,
7560+ (double )t .tms_cstime / ticks_per_second ,
7561+ (double )c / ticks_per_second );
7562+ }
75657563#endif
75667564
7565+ #endif /* HAVE_TIMES */
7566+
75677567
75687568#ifdef HAVE_GETSID
75697569PyDoc_STRVAR (posix_getsid__doc__ ,
0 commit comments